[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] xsl:for-each with atomic values and nested xsl:apply-templates
Subject: [xsl] xsl:for-each with atomic values and nested xsl:apply-templates From: "Christian Roth" <roth@xxxxxxxxxxxxxx> Date: Thu, 14 Sep 2006 00:12:56 +0200 |
Hi, trying to figure out what the error with this fragment (XSLT 2) is: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:template match="src"> <xsl:for-each select="tokenize( 'a c', '[ ]')"> <xsl:apply-templates select="/doc/*[current() eq string(@id)]" /> </xsl:for-each> </xsl:template> </xsl:stylesheet> This gives an error, "Cannot select a node here: the context item is an atomic value". I see that the xsl:for-each iterates over a sequence of atomic values (xs:string). So I assume that current() results in an xs:string, which should be comparable to the string(@id) expression. The select="..." expression does not depend on a context node, as it is an absolute path from the document root. xsl:apply-templates results in a sequence and therefore should be no problem in the xsl:for-each body. It's certainly trivial - I just don't see it right now... :-/ An input for the above would e.g. be: <doc> <src /> <elem id="a">A</elem> <elem id="b">B</elem> <elem id="c">C</elem> <elem id="d">D</elem> </doc> The desired output would (probably...) be: AC Regards, Christian
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Bibliography References, David Carlisle | Thread | RE: [xsl] xsl:for-each with atomic , Michael Kay |
[xsl] Bibliography References, siarom egrub | Date | RE: [xsl] Bibliography References, Mark Shellenberger |
Month |