Re: [xsl] Unanticipated Results from text()

Subject: Re: [xsl] Unanticipated Results from text()
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 26 Feb 2007 17:16:33 GMT
> Loss of whitespace isn't what concerns me, it's the loss of the
> non-whitespace that has me puzzled.

it's loss of whitespace that is causing your problem though, as once you
have lost the white space the numbering of the other text nodes is
changed accordingly.

If you have

<y> abc </y>

and with x as the current node go


then text() selects the node set of text child nodes, which in a
conforming system is a set of two nodes with values
"(newline)" and "(newline)test(newline)"

normalize-space() requires a string input so (in xpath 1) silently
discards all but the first node in document order, and takes teh string
value of that node.

So in a conforming system, normalize-space gets passed "(newline)" and
returns ""

If however MSXML has thrown away the white space already then

the input is essentially this:

<x><y> abc </y>

so now text() just selects one text node child, with value


and the string value of that gets passed to  normalize-space which then
returns "test".


Current Thread