[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Error: XPTY0020: Leading '/' cannot select the roo
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|