Hello,
can someone please explain to me why the one stylesheet given below
works, but the other not?
<!-- This stylesheet works -->
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html><head></head><body>
<xsl:apply-templates/>
</body></html>
</xsl:template>
<xsl:template match="extern">
<xsl:variable name="vPart" select="@part"/>
<xsl:apply-templates select="document(@file)/content/*[name()=$vPart]"/>
</xsl:template>
</xsl:stylesheet>
<!-- This stylesheet does not work -->
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html><head></head><body>
<xsl:apply-templates/>
</body></html>
</xsl:template>
<xsl:template match="extern">
<xsl:apply-templates select="document(@file)/content/*[name()=@part]"/>
</xsl:template>
</xsl:stylesheet>
The stylesheet work on this file:
<?xml version="1.0"?>
<content>
<extern file="extern_resource.xml" part="parta"/>
</content>
and use this file also:
<!-- extern_resource.xml -->
<?xml version="1.0"?>
<content>
<parta>This is the content part a</parta>
<partb>This is the content part b</partb>
</content>