Skip to content

Instantly share code, notes, and snippets.

@nine9ths
Created June 27, 2013 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nine9ths/5872951 to your computer and use it in GitHub Desktop.
Save nine9ths/5872951 to your computer and use it in GitHub Desktop.
Demonstrate differences between xsl:apply-imports and xsl:next-match for controlling import precedence.
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs">
<xsl:template match="foo">
<bar/>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs">
<xsl:import href="test.apply-imports.imported.xsl"/>
<xsl:variable name="test" as="element(foo)">
<foo/>
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates select="$test"/>
</xsl:template>
<xsl:template match="foo">
<test>
<xsl:next-match/> <!-- This will return <baz/> -->
<xsl:apply-imports/> <!-- This will return <bar/> -->
</test>
</xsl:template>
<xsl:template match="*">
<baz/>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment