Subject: Re: [xsl] key with restricting the scope of use attribute From: Dan Diebolt <dandiebolt@xxxxxxxxx> Date: Fri, 11 May 2001 06:48:35 -0700 (PDT) |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] key with restricting the , David Carlisle | Thread | Re: [xsl] key with restricting the , David Carlisle |
RE: [xsl] xmlspy and copy-of, Michael Kay | Date | Re: [xsl] key with restricting the , David Carlisle |
Month |