[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Error: XPTY0020: Leading '/' cannot select the root node of the tree containing the context item: the context item is an atomic value
Subject: Re: [xsl] Error: XPTY0020: Leading '/' cannot select the root node of the tree containing the context item: the context item is an atomic value From: Dietrich Bollmann <diresu@xxxxxx> Date: Mon, 10 Jan 2011 21:34:05 +0900 |
Hello Michael, Martin, and Andrew, Thanks to your help it works perfectly now! I am impressed: less than ten minutes later three perfect answers :) Thank you very much, Dietrich On Mon, 2011-01-10 at 11:44 +0000, Andrew Welch wrote: > Hi, > > You get this error: > > > Error on line 12 of example-b.xsl: > > XPTY0020: Leading '/' cannot select the root node of the tree > > containing the context item: > > the context item is an atomic value > > ...because here within the for-each the "context item" is each of the > items in the sequence of tokenized values (strings): > > > <xsl:for-each select="tokenize(example/bar/@ids, ',')"> > > <xsl:value-of select="."/>: <xsl:value-of > > select="key('index', .)" /> > > When you make the key call, it must be applied to an input tree... > which by default is the tree containing the context node. As there is > no context node here, it causes the error. The solution is to store a > reference to the input doc outside of the for-each (say as a top-level > element), and then reference that in the key: > > <xsl:variable name="input" select="."/> > > with > > key('index', ., $input)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Error: XPTY0020: Leading , Andrew Welch | Thread | [xsl] xml to xhtml namespace proble, Szabo, Patrick \(LNG |
Re: [xsl] Error: XPTY0020: Leading , Andrew Welch | Date | [xsl] xml to xhtml namespace proble, Szabo, Patrick \(LNG |
Month |