Subject: Re: [xsl] [string to node] From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sun, 21 Feb 2010 20:36:39 -0500 |
> > In both cases it seems as though $a contains only 1 thing, a > > string. (You can test that it is not a node set by using $a in > > the select= of a for-each -- you should get a runtime error, > > since it is a string.) > > No, it's a result tree fragment, not a string.
Oh, right. Thanks for the correction. (He says with his tail between his legs.) But if I understand correctly, as a result tree fragment, only those operations that can be performed on strings are permitted (i.e., can't do path stuff or predicates), and you can't use a result tree fragment as the value of select=
of for-each (or apply- templates, for that matter), because a result tree fragment is not a node-set, even though when you do get to use one it behaves as node- set. (And select= of for-each and apply-templates takes a node-set.)
And because a result tree fragment is always a "root" node (in this case a single text() node),
<xsl:variable name="a"> <xsl:value-of select="..."/> </xsl:variable>
count($a) will always return 1, right?
<xsl:variable name="b"> <c> <d/> </c> <c> <d/> </c> <c> <d/> </c> </xsl:variable>
Further, I think that if the variable is built using select= instead of content, the variable is a node-set instead of a result tree fragment, right? I.e., <xsl:variable name="a" select="//dd"/> <xsl:value-of select="count($a)"/> should return 3 (or however many <dd> were in the input instance).
But what then would <xsl:value-of select="$a"/> return? I just tried it on my test input, and it returned "one".
-- XSLT/XQuery training: after http://XMLPrague.cz 2010-03-15/19 XSLT/XQuery training: San Carlos, California 2010-04-26/30 Principles of XSLT for XQuery Writers: San Francisco,CA 2010-05-03 XSLT/XQuery/UBL/Code List training: Trondheim,Norway 2010-06-02/11 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] [string to node], Syd Bauman | Thread | Re: [xsl] [string to node], David Carlisle |
Re: [xsl] [string to node], Syd Bauman | Date | Re: [xsl] generating unique random , Wolfgang Laun |
Month |