cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Lanch <p...@aldigital.co.uk>
Subject Re: This page was served in ...
Date Tue, 28 Mar 2000 10:19:54 GMT
Mariusz Nowostawski wrote:
> 
> itself. If I have something like:
> 
> <tag1>
> arbitrary text
> </tag1>
> and call text() on the context element I am getting "arbitrary text" as
> expected. If I have:
> 
> <tag1>
> arbitrary text
> <innertag/>
> </tag1>
> 
> text() is still returning expected text. However, if I have:
> 
> <tag1>
> <innertag/>
> arbitrary text
> </tag1>
> 
> text() is returning either empty EOL or some spaces + EOL character. I
> tried child::text() and even going throuhg all children of tag1 via
> for-each but I could not anyhow get exptected "arbitrary text". What
> expression I should use (for Cocoon) to return a concatenation of all text
> nodes? To me child::text() or just text() should work in the last case as
> well - is it an implementation issue or I am missusing text() ?

text() is all the text-node children of the current node (i.e. tag1), so-

<xsl:apply-templates select="text()"/>

-should work.  however, when a node-set is converted to a string, the
result is the string value of just the first node in the set, so-

<xsl:value-of select="text()"/>

-doesn't work when tag1 has more than one text child; actually, it wasn't
guaranteed to work in your first example, because the parser can split a
bit of text in XML into as many text nodes as it likes (because that may be
more efficient for long bits of text).  you could use-

<xsl:value-of select="."/>

-since the string value of an element node is the concatenation of all its
text-node descendants.

-- 

cheers

phil

"When Alkan said, 'How are you?' the question had a total nuance:
he really wanted to know how you were, although at the same time
he was asking the question purely for the sake of social from.
Yet he managed simultaneously to acknowledge both of these
conflicting messages and still reformulated the question so that
it incorporated them and yet was devoid of all assumptions.
Furthermore none of the above seemed to be _implied_."

Mime
View raw message