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

Re: key with restricting the scope of use attribute

Subject: Re: key with restricting the scope of use attribute
From: Dan Diebolt <dandiebolt@xxxxxxxxx>
Date: Fri, 11 May 2001 06:48:35 -0700 (PDT)
restricting key xsl
Using my original XML, consider just two nodes in the
traversal: root/a[1]/b[1] and root/c/a[1]/b[1]. Now
compare the difference between using two different keys: 
MyKey1 is built from just @x:@y and MyKey2 is built from
generate-id():@x:@y. If while at each of these two nodes
I determine I need to retreive all nodes matching @x:@y='1:1'
then, the second key returns some "out-of-context" nodes
that happen to have @x:@y='1:1'. Maybe my working is inartful,
but does this help clarify what I am trying to do? The procedure
does work, but as you can see it is complicated and that is why
I am asking for advice.

Dan

MyKey1:@id=1
------------------------
MyKey2:@id=1
MyKey2:@id=4
MyKey2:@id=6
MyKey2:@id=7
MyKey2:@id=9
MyKey2:@id=17
MyKey2:@id=18
MyKey2:@id=21
------------------------
------------------------
MyKey1:@id=9
------------------------
MyKey2:@id=1
MyKey2:@id=4
MyKey2:@id=6
MyKey2:@id=7
MyKey2:@id=9
MyKey2:@id=17
MyKey2:@id=18
MyKey2:@id=21

Regards,

Dan
----------------
<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:key name="MyKey1" match="a/b" use="concat(generate-id(),':',@x,':',@y)"/>
<xsl:key name="MyKey2" match="a/b" use="concat(@x,':',@y)"/>

<xsl:template match="/">
 <xsl:apply-templates select="/root/a[1]/b[1]"/>
 <hr/><hr/>
 <xsl:apply-templates select="/root/c/a[1]/b[1]"/>
</xsl:template>

<xsl:template match="a/b">
 <xsl:for-each select="key('MyKey1',concat(generate-id(),':','1:1'))">
  MyKey1:@id=<xsl:value-of select="@id"/><br/>
 </xsl:for-each>
 <hr/>
 <xsl:for-each select="key('MyKey2','1:1')">
  MyKey2:@id=<xsl:value-of select="@id"/><br/>
 </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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-2013 All Rights Reserved.