M
Martin Hunter
Hi All,
I've written some XSLT and am using Apache Xalan 2.6 (Java version) to
process it.
I'm having trouble obtaining the name of nodes on the attribute axis
of an element. Both the name() and local-name() xpath functions return
a blank string.
Here is my code. This function is designed to spit out an exact copy
of the node parameter, and its children, bar text content of elements.
It is part of a larger stylesheet.
<xsl:template name="buildRecursive">
<xslaram name="theNode" />
<xsl:for-each select="$theNode">
<xsl:element name="{name(self::node())}">
<xsl:for-each select="attribute::*">
<xsl:attribute name="{name()}">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:for-each>
<xsl:for-each select="child::node()">
<xsl:call-template name="buildRecursive">
<xsl:with-param name="theNode" select="." />
</xsl:call-template>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</xsl:template>
The XML content being processed is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<document-resultset>
<folder>
<reference>dir</reference>
<document>
<reference>doc1.xml</reference>
<version>0</version>
<content>
<some-rubbish><bloke nom="l'homme"/></some-rubbish>
</content>
</document>
<document>
<reference>doc2.xml</reference>
<version>0</version>
<content>
<some-content hi="hi"/>
</content>
</document>
</folder>
</document-resultset>
Any ideas why this doesn't work?
Best regards,
Martin Hunter.
I've written some XSLT and am using Apache Xalan 2.6 (Java version) to
process it.
I'm having trouble obtaining the name of nodes on the attribute axis
of an element. Both the name() and local-name() xpath functions return
a blank string.
Here is my code. This function is designed to spit out an exact copy
of the node parameter, and its children, bar text content of elements.
It is part of a larger stylesheet.
<xsl:template name="buildRecursive">
<xslaram name="theNode" />
<xsl:for-each select="$theNode">
<xsl:element name="{name(self::node())}">
<xsl:for-each select="attribute::*">
<xsl:attribute name="{name()}">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:for-each>
<xsl:for-each select="child::node()">
<xsl:call-template name="buildRecursive">
<xsl:with-param name="theNode" select="." />
</xsl:call-template>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</xsl:template>
The XML content being processed is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<document-resultset>
<folder>
<reference>dir</reference>
<document>
<reference>doc1.xml</reference>
<version>0</version>
<content>
<some-rubbish><bloke nom="l'homme"/></some-rubbish>
</content>
</document>
<document>
<reference>doc2.xml</reference>
<version>0</version>
<content>
<some-content hi="hi"/>
</content>
</document>
</folder>
</document-resultset>
Any ideas why this doesn't work?
Best regards,
Martin Hunter.