Re: [xsl] xsl:sequence

Subject: Re: [xsl] xsl:sequence
From: "tom tom" <tomxsllist@xxxxxxxxxxx>
Date: Thu, 10 Aug 2006 16:32:41 +0100
I understand what you are saying. I would have thought using xsl:value-of to obtain the text from

<p><i>This</i> is <b>bold</b> text</p>

is pretty bad practice though and unextensible in the future. Recursively processing the elements would allow you to b tags to be converted to, say, spans in the future should they be required.

I have a feeling your going to disagree with me but just in case you don't then is this an argument for not using value-of for anything?

Or does the 'without doing a lot of work that the system has already done' argument still hold?

From: David Carlisle <davidc@xxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] xsl:sequence
Date: Wed, 9 Aug 2006 13:05:52 +0100

> My point is that if xsl:sequence can mimic xsl:value-of behavior in this way
> whats the point of using xsl:value-of ever?

xsl:value-of returns the string value of an element, and that isn't
obtainable from xsl:sequence (without doing a lot of work that the
system has already done) The string-value of an element is designed to
produce the "right" text in cases where XML is being used as originally
designed as a markup language marking up a text flow.

See the example I showed earlier

<p><i>This</i> is <b>bold</b> text</p>

the string value of that paragraph is "This is bold text" and that is
what <xsl:value-of select="p"/> returns.

<xsl:sequence select="p/text()"/> returns the sequence of child text
nodes, that is the sequence of two text nodes " is " and " text"  this
collection of words that happened not to be marked up isn't usually very

The functions of xsl:sequence and xsl:value-of are almost completely
different and usually it's clear which you should use.
xsl:copy-of and xsl:sequence of are much closer, as the difference is
that copy-of makes a copy, but in most situations where you need to
copy, for example copying nodes from the input tree to the result, there
is an implied copy operation anyway so the distinction between
xsl:copy-of and xsl:sequence is hidden.


Windows Live Messenger has arrived. Click here to download it for free!

Current Thread