Subject: Re: [xsl] Can grouping here the solution ?|
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 22 Nov 2011 16:02:53 +0000
Wow. I would have thought that "text()" would return the text, not a sequence of nodes. That's really counter intuitive. Rob
You say "return the text" but elements don't have "text" they have a sequence of child nodes, and text() works like comment() or node() or * and returns the sequence of nodes of that node type.
has two text node children, so foo/text() returns 1 or 2 nodes, respectively.
In both cases however the string value is " 1 3 " but that is returned by string(foo) not foo/text().
so if you go string-length(foo/text()) in xpath1 that's 2 (the length of " 1" as the second text node is silently discarded. In xpath 2 it's an error as string-length should only get a single item not a sequence of length 2.
If you go string-length(foo) then that is 5 in xpath 1 or 2, being the length of the string value of foo.
________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.