[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xsl:sequence

Subject: Re: xsl:sequence
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 9 Aug 2006 13:44:10 +0100
xsl traverse xml text nodes
me> xsl:value-of returns the string value of an element, and that isn't
me> obtainable from xsl:sequence (without doing a lot of work that the
me> system has already done)

>  Do you mean that in "to/an/element/string()", 
hey that's cheating:-)

That is exactly the same as value-of (except it returns a string rather
than a text node) but wasn't what I meant here. As that is again just
selecting the element and allowing the system to return its string
value. I was comparing this with selecting
 or more generally
which is what tom tom was suggesting to use in xsl:sequence. So here you
just have sequence of child nodes. it is of course possible to
recursively traverse this sequence until you get to the text node
leaves, and then build up the string "by hand" but it's not often you
want to do that. More often, if value-of doesn't give you what you want
directly then you use apply-templates anyway, which is more flexible:

<xsl:value-of select="p"/> on 
<p><i>This</i> is <b>bold</b> text</p>
gives you a text node "This is bold text" which is fine but

<xsl:value-of select="p"/> on 
<p>This<br/>is an image: <img alt="flower" src="flower.png"/></p>
a text node "Thisis an image "
which is less fine so it's better to go
<xsl:apply-templates select="p"/>
and have
<xsl:template match="br"><xsl:text>&#10;</xsl:text></xsl:template>
<xsl:template match="img">[<xsl:value-of select="@alt"/>]</xsl:template>
then you get
is an image: [flower]"


Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.