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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Limitation to variable value i... (3)
-> + Using xsl to transfer XML data... (2)
-> + Moving data from one xml file ... (3)
-> - Key() returning empty node (2)
-> ->Key() returning empty nod...
-> + Query in Xpath (2)
-> + Curly braces to substitute val... (4)
-> + Not grouping all nodes (3)
-> + Simplifying this long if state... (6)
-> + "Select" - help (4)
-> + xsl:result-document and Xalan (3)
-> + Native Java types and extensio... (3)
-> - Deleate element except one of ... (1)
-> + text() function and xalan - lo... (3)
-> + Testing an Elements child Tag ... (2)
-> + transfer xml into xslt (3)
-> + Help! Transform flat XML recor... (5)
-> + Dynamic Transformations (4)
-> + Converting XML to HTML (2)
-> + Need Help --- A Special Sum Qu... (11)
-> + XML to XML transformation (3)
-- Previous [1441-1460] [1461-1480] [1481-1500] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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

   
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.