Difference between revisions of "Copy-All.xsl"
Jump to navigation
Jump to search
m |
m |
||
Line 21: | Line 21: | ||
</xsl:stylesheet> | </xsl:stylesheet> | ||
− | + | </nowiki></pre> |
Revision as of 16:38, 19 June 2006
This is a utility XSLT script. It should be placed in the same directory as PipedStylesheets.bash and the other XSLT stylesheets you want to use. (They import this one.) However, in naming this stylesheet make sure to call it 'Copy-All.xsl'. Specifically, make sure you have it capitalised, and that it ends '.xsl' not '.xslt' as the other stylesheets.
You can use this stylesheet as well to copy the entire contents of an XML document *except* do something to some particular elements. The fictional element fooBar is used as an example of how one would do that.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <!-- XSLT Template to copy anything, priority="-1" --> <xsl:template match="@*|node()|text()|comment()|processing-instruction()" priority="-1"> <xsl:copy><xsl:apply-templates select="@*|node()|text()|comment()|processing-instruction()"/></xsl:copy> </xsl:template> <!-- If I was to do something different for an element here is how I'd do it. --> <xsl:template match="fooBar"> <barFoo><xsl:apply-templates/></barFoo> </xsl:template> </xsl:stylesheet>