1
votes

I am trying to use the current node attribute as a value to match against the name name in my xml. The xml node is the same name as the handle. There are multiple nodes with different names that correspond to the handle.

As its going over a lot of different nodes with different names, i dont want to write a massive choose statement. please look at the xpath inside apply-template - its not working, but is there a way to do such a thing?

<xsl:for-each select="data/navigation/page">
    <xsl:element name="{@handle}">
        <xsl:attribute name="id"><xsl:value-of select="current()/@id"/></xsl:attribute>
        <xsl:value-of select="name"/>
        <xsl:apply-templates select="/data/[current()/@handle]" mode="page"/>
    </xsl:element>
</xsl:for-each>
1
When you say something is "not working", please clarify if you mean there's an error message, and if so what it says; or if the program is giving wrong output, and if so what the output is and what you expected it to be.LarsH

1 Answers

3
votes
<xsl:apply-templates select="/data/[current()/@handle]" mode="page"/>

This is syntactically illegal -- a location step cannot start with a predicate.

Probably you want something like this:

<xsl:apply-templates select="/data/*[name()=current()/@handle]" mode="page"/>