1 <?xml version="1.0"?> 2 <!-- 3 Copyright (C) 2005 Paul Boddie <paul@boddie.org.uk> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 --> 19 <xsl:stylesheet version="1.0" 20 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 21 xmlns:axsl="http://www.w3.org/1999/XSL/TransformAlias" 22 xmlns:template="http://www.boddie.org.uk/ns/xmltools/template" 23 xmlns:dyn="http://exslt.org/dynamic" 24 extension-element-prefixes="dyn"> 25 26 <xsl:output indent="yes"/> 27 <xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/> 28 29 <xsl:param name="element-id"/> 30 31 32 33 <!-- Start at the top, finding only the specified element. --> 34 35 <xsl:template match="/"> 36 <axsl:stylesheet version="1.0" 37 xmlns:dyn="http://exslt.org/dynamic" 38 extension-element-prefixes="dyn"> 39 40 <axsl:output indent="yes"/> 41 <axsl:param name="element-path"/> 42 43 <!-- NOTE: Hard-coded doctypes to hopefully satisfy JavaScript code. --> 44 <!-- doctype-public="-//W3C//DTD XHTML 1.1//EN" 45 doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" --> 46 47 <axsl:template match="/"> 48 49 <!-- Include the remaining attributes. --> 50 <xsl:apply-templates select="@*"/> 51 52 <!-- Process the elements. --> 53 <xsl:for-each select="//*[@template:id=$element-id]"> 54 <axsl:for-each select="dyn:evaluate($element-path)"> 55 <xsl:copy> 56 <xsl:apply-templates select="@*|node()"/> 57 </xsl:copy> 58 </axsl:for-each> 59 </xsl:for-each> 60 61 </axsl:template> 62 </axsl:stylesheet> 63 </xsl:template> 64 65 66 67 <!-- Replicate unknown elements. --> 68 69 <xsl:template match="@*|node()"> 70 <xsl:copy> 71 <xsl:apply-templates select="@*|node()"/> 72 </xsl:copy> 73 </xsl:template> 74 75 </xsl:stylesheet>