xsl-list
[Top] [All Lists]

Re: [xsl] Error: XPTY0020: Leading '/' cannot select the root node of the tree containing the context item: the context item is an atomic value

2011-01-10 05:43:01
Dietrich Bollmann wrote:

   <xsl:key name="index" match="//*[@id]" use="./@id" />

   <xsl:template match="/">
     <body>
       <xsl:for-each select="tokenize(example/bar/@ids, ',')">
         <xsl:value-of select="."/>:<xsl:value-of
select="key('index', .)" />

I get the following error:

---
$ saxon -s:example.xml -xsl:example-b.xsl

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
Failed to compile stylesheet. 1 error detected.

Use
  <xsl:variable name="d1" select="/"/>
outside of the for-each, then use
    key('index', ., $d1)
inside of the for-each.

--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--