Iterating the attribute:: axis with Xalan

Discussion in 'Java' started by Martin Hunter, Aug 9, 2004.

  1. 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.
     
    Martin Hunter, Aug 9, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joey Vendetta
    Replies:
    0
    Views:
    3,454
    Joey Vendetta
    Apr 1, 2004
  2. Replies:
    0
    Views:
    940
  3. Hyunchan Kim
    Replies:
    1
    Views:
    722
    Martin Honnen
    Dec 18, 2003
  4. cvissy
    Replies:
    0
    Views:
    609
    cvissy
    Nov 16, 2004
  5. carl
    Replies:
    5
    Views:
    2,379
    James Kanze
    Nov 25, 2009
Loading...

Share This Page