ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> exslt
exslt
[exslt] exsl:node-set() - remaining issues
by Jeni Tennison other posts by this author
Apr 24 2001 4:21PM messages near this date
[exslt] Site update | RE: [exslt] exsl:node-set() - remaining issues
Hi,

The current definition of exsl:node-set() states that the only types
of objects that can be passed as the argument of exsl:node-set() are
node sets and result tree fragments. It's an error if another type of
object is passed as the argument value.

The main purpose of node-set() extension functions has been to convert
RTFs to node sets for future processing, but I wonder whether it would
be helpful to view exsl:node-set() as a conversion function just like
number(), string() and boolean().  The result of doing this would be
that:

  <xsl:variable name="foo" select="exsl:node-set('bar')" /> 

would be equivalent to:

  <xsl:variable name="baz"> bar</xsl:variable>
  <xsl:variable name="foo" select="exsl:node-set($baz)/text()" /> 

They would both assign to foo a text node with the value 'bar'.
Converting numbers and booleans to a node set would involve converting
them to a single text node with a string value equal to the string
value of the object (so exsl:node-set(1) ->  text node with a string
value of '1' and exsl:node-set(true()) ->  text node with a string
value of 'true' and so on).

Alternatively, you could say that:

  <xsl:variable name="foo" select="exsl:node-set('bar')" /> 

would be equivalent to:

  <xsl:variable name="baz"> bar</xsl:variable>
  <xsl:variable name="foo" select="exsl:node-set($baz)" /> 

In other words, exsl:node-set() when applied to a string, number or
boolean would result in a node set consisting of a single root node
with a child text node whose string value was equal to the string
value of the object.

Now, the plus side of allowing one of these would be that it would
make it easier to deal with the wrong type of value being passed as a
parameter into a template - rather than having to test whether the
value is a result tree fragment or node set, you could convert it into
one, no matter what the type.

The minus side is in looking forward to future versions of XSLT and
the future compatibility of stylesheets.  If future versions of XSLT
allow the implicit conversion of result tree fragments to node sets,
then adapting 1.0 stylesheets to take advantage of that *would* just
involve removing any exsl:node-set() calls.  If exsl:node-set() had
this additional functionality, then it wouldn't be that simple - it
would be harder to tell where it was being used to convert an RTF and
where to convert other types of values.

So, two questions:

 1. would it be useful to be able to convert values other than result
    tree fragments into node sets?

 2. should they be converted into a single text node, or into a root
    node with a text node child?

My inclination is to make the change - if there aren't strong
objections by the end of the week, then I'll do so.
    
Cheers,

Jeni
---
Jeni Tennison
http://www.jenitennison.com/
Thread:
Jeni Tennison
Michael Kay
Jeni Tennison
Michael Kay
Jeni Tennison
Michael Kay

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved