XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Renuka DeviSubject: 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

Posttop
Ivan PedruzziSubject: Key() returning empty node
Author: Ivan Pedruzzi
Date: 24 May 2006 11:55 AM
Hi Renuka,

In order to help you have to provide a complete example (XML + XSLT) and tell us which XSLT processor is used.

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.