[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: For-each and keys()

Subject: Re: For-each and keys()
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 2 Aug 2006 16:06:45 +0100
Re:  For-each and keys()
> XSL goes something like:
its easier if you post the actual (short) code that you have run in the
xslt processor.

> <xsl:variable name="$Definitions" select="Document(Disabilities.xml)" />
That's a syntax error, document() doesn't have a D and expects a string
document('disabilities.xml') and the variable name does not start with $.

                                       
> <xsl:variable name="$Var" select="Document(Records.xml)" />
same here.


>> <xsl:for-each select="$Definitions">
>>   <xsl:value-of select="count(key('oldID',$current))" />
>> </xsl:for-each>

>I really don't understand this.

key() returns all the nodes that match the key _in the current document_
so if you want to look up keys in a different document then (in xslt1)
you need touse  xsl:for-each  to make that document current.
In XSLT2 you could equivalently go
<xsl:value-of select="$Definitions/count(key('oldID',$current))
or
<xsl:value-of select="count(key('oldID',$current,$Definitions))

> I really don't understand this.  I should mention there are many other
> branches within $Definitions besides /disabilities.

If $Definitions is defined using document() then it will represent a
well formed document so there can be at most one top level element
(presumably <disabilities>) so I do not see what you can mean by "other
branches"

David

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.