|
next
|
Subject: Key() returning empty node Author: Renuka Devi Date: 24 May 2006 03:10 AM
|
Hi ,
I am a newbie to XSLT and am having trouble retrieving nodes using keys.There are five nodes in the XML (2 nodes named DSL,
2 nodes named Fiber, 1 node named Dial).
The key() function is retrieving an empty node for Fiber along with the other Fiber nodes.
There are many keys defined in the XSL with different key names but the key values are same.
eg:
<xsl:key name="dslWithSameUser" match="DSL" use="UserId/@original_value"/>
<xsl:key name="dialWithSameUser" match="Dial" use="UserId/@original_value"/>
<xsl:key name="fiberWithSameUser" match="Fiber" use="UserId/@original_value"/>
when I say,
<xsl:apply-templates select="RetrieveElement/DSL[(generate-id(.) = generate-id(key('dslWithSameUser',UserId/@original_value)[1]))]" mode="uniqueUserName"/>
<xsl:apply-templates select="RetrieveElement/Dial[(generate-id(.) = generate-id(key('dialWithSameUser',UserId/@original_value)[1]))]" mode="uniqueUserName"/>
<xsl:apply-templates select="RetrieveElement/Fiber[(generate-id(.) = generate-id(key('fiberWithSameUser',UserId/@original_value)[1]))]" mode="uniqueUserName"/>
The DSL and Dial nodes are retrieved but the Fiber nodes are not retrieved.
When I tried the following,
<xsl:variable name="nodes1" select="key('fiberWithSameUser',UserId/@original_value)"/>
<xsl:for-each select="$nodes1">
<xsl:comment>
<xsl:text>The name of this node is </xsl:text>
<xsl:value-of select="name()"/>
</xsl:comment>
</xsl:for-each>
I get an empty node as the first node in the variable nodes1. So the apply templates for Fiber is never happening. Any one knows what the problem actually is? The wierdest of all is if i shift the apply-templates of Fiber above DSL and Dial, Fiber gets retrieved but DSl and Dial are not. Any help will be greatly appreciated.
regards,
K.Renuka
|
|
|