Iterating the attribute:: axis with Xalan

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">
<xsl:param 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top