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: Andrew Welch <andrew.j.welch@xxxxxxxxx> Date: Mon, 10 Jan 2011 11:44:06 +0000 |
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) -- Andrew Welch http://andrewjwelch.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Error: XPTY0020: Leading , Martin Honnen | Thread | Re: [xsl] Error: XPTY0020: Leading , Dietrich Bollmann |
Re: [xsl] Error: XPTY0020: Leading , Martin Honnen | Date | Re: [xsl] Error: XPTY0020: Leading , Dietrich Bollmann |
Month |