Project

Profile

Help

Different result between java and command line when calli... » call-named-template.xsl

Andy Walshe, 2018-07-17 12:48

 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="urn:my:test:stuff"
xmlns:myt="urn:my-templates"
exclude-result-prefixes="myt">
<xsl:output omit-xml-declaration="yes" />
<xsl:strip-space elements="*" />
<xsl:output indent="yes" />

<myt:template-members>
<myt:second-level/>
<myt:second-again/>
</myt:template-members>

<xsl:variable name="template-list" select="document('')//myt:template-members" />

<xsl:template match="/first">
<FirstElem>
<xsl:apply-templates/>
</FirstElem>
</xsl:template>

<xsl:template name="second-level" match="myt:second-level" mode="call-template">
<xsl:element name="SecondLevelElem"/>
</xsl:template>

<xsl:template name="second-again" match="myt:second-again" mode="call-template">
<xsl:element name="SecondAgain"/>
</xsl:template>

<xsl:template match="/first/second-level|/first/second-again">
<xsl:variable name="template-name" select="local-name()" />
<xsl:apply-templates select="$template-list/myt:*[local-name() = $template-name]" mode="call-template"/>
</xsl:template>

</xsl:stylesheet>
(2-2/4)