Subject: Re: [xsl] key( 'myKey', 'key', $current) searches only the sub tree from $current From: Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx> Date: Sat, 23 Feb 2008 16:15:59 +0000 |
>>>>> "Johannes" == Johannes Neubauer <johannes.neubauer@xxxxxxxxxxxxxxxxx> writes: Johannes> Hi, I have a <xsl:key> that maps unique attribute values Johannes> of sibling-elements to the respective element. When I Johannes> use the key() function in a <xsl:function> I have to Johannes> submit a node as a third argument, so that it's clear Johannes> which source document is used (there's no context node Johannes> in functions available). Johannes> So I tried this: Johannes> xsl:key: <xsl:key match="book" name="myKey" use="@id"/> Johannes> function call in XPath: key('myKey', '100', $current) (: Johannes> $current is the context node supplied as a parameter to Johannes> the xsl:function :) Johannes> source doc: <test> ~ <book id="100"/> ~ <book id="101"/> Johannes> ~ <book id="102"/> ~ <book id="103"/> </test> Johannes> But I find the respective book element only if it is Johannes> $current. When I change the function call to this: Johannes> key('myKey', '100', root($current)) Johannes> I find it independent from which element $current is, it Johannes> has to be from the right source document only. Johannes> "XSLT 2.0 3rd edition" from Michael Kay page 574 says, Johannes> that the supplied ~ third argument must not be the Johannes> document node, but any node of the source document. Johannes> Is this a bug in Saxon or one of the things that changed Johannes> in the spec after publishing the book? I didn't find the Johannes> part in the online documentation, where the xslt Johannes> functions are described. It's 16.3.2. "The third argument is used to identify the selected subtree. If the argument is present, the selected subtree is the set of nodes that have $top as an ancestor-or-self node. If the argument is omitted, the selected subtree is the document containing the context node. This means that the third argument effectively defaults to /." which is not what you described. If Michael's 3rd edition (I only have the 2nd edition - from years back) says what you described, then best buy the fourth edition when it comes out. -- Colin Adams Preston Lancashire
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] key( 'myKey', 'key', $cur, Johannes Neubauer | Thread | [xsl] inline XML <emphasis>, Thomas Kielczewski |
RE: [xsl] key( 'myKey', 'key', $cur, Michael Kay | Date | Re: [xsl] key( 'myKey', 'key', $cur, Johannes Neubauer |
Month |