Re: [xsl] Can grouping here the solution ?

Subject: Re: [xsl] Can grouping here the solution ?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 22 Nov 2011 16:02:53 +0000
On 22/11/2011 15:53, Echlin, Robert wrote:
Wow. I would have thought that "text()" would return the text, not a
sequence of nodes. That's really counter intuitive. Rob

First warp your brain to work like xpath, then it is really intuitive.

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.

<foo> 1 3 </foo>

has one text node child

<foo> 1<!-- 2--> 3 </foo>

has two text node children, so foo/text() returns 1 or 2 nodes,

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.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________

Current Thread