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] exslt:node-set() is underspecified -- more exact definition proposed
by Dimitre Novatchev other posts by this author
May 18 2002 10:52AM messages near this date
[exslt] Non Stable Functions | Re: [exslt] exslt:node-set() is underspecified -- more exact definition proposed
The definition of the exslt:node-set() function as currently found on
http://www.exslt.org/exsl/functions/node-set/index.html is:

"The exsl:node-set function converts a result tree fragment (which is
what you get when you use the content of xsl:variable rather than its
select attribute to give a variable value) into a node set. This
enables you to process the XML that you create within a variable, and
therefore do multi-step processing. 

You can also use this function to turn a string into a text node, which
is helpful if you want to pass a string to a function that only accepts
a node set."

This function's behaviour is underspecified in the sense that different
implementations may exhibit quite different behaviours and thus a
transformation using the exslt:node-set() may be non-portable accross
different XSLT processors implementing EXSL.

For example, the following does not raise a run-time error using Saxon
6.5:

    <xsl:template match="str-split2words-func:*"> 
      <xsl:param name="arg1" select="/.."/> 
      <xsl:param name="arg2"/> 
         
<!--1-->  <xsl:copy-of select="exslt:node-set($arg1)/*[1]"/>
<!--2-->  <xsl:copy-of select="$arg1/word[position() != last()]"/>
      
      <xsl:choose> 
<!--2--> <xsl:when test="contains($arg1/*[1], $arg2)">
<!--2-->    <xsl:if test="string($arg1/word[last()])">
<!--2-->       <xsl:copy-of select="$arg1/word[last()]"/>
           </xsl:if> 
          <word/> 
        </xsl:when> 
        <xsl:otherwise> 
          <word> 
            <xsl:value-of 
<!--2-->       select="concat($arg1/word[last()], $arg2)"/>
          </word> 
        </xsl:otherwise> 
      </xsl:choose> 
    </xsl:template> 


When the above template is instantiated passing to it an RTF as the
value of its parameter $arg1, Saxon 6.5 does not signal any error on
the lines starting with <!--2--> 

Recently Michael Kay provided in 
http://sources.redhat.com/ml/xsl-list/2002-05/msg00928.html 
the following explanation of this behaviour:

"Dimitre, you have discovered a feature in Saxon which I have never
advertised. The saxon:node-set() function really does convert an RTF to
a node set. That's right, it doesn't create a node-set that is a copy
of the RTF, it really changes the RTF into a node-set, so once you have
called saxon:node-set($rtf) you can thereafter use $rtf as a node-set.

(In fact, saxon:node-set() simply unsets the bit that says "the user
isn't allowed to do useful things with this tree").

It might seem a very un-functional way of doing things, but it's
perfectly conformant, because extension functions are allowed to have
side-effects." 

The problem is, that other XSLT processors interprete the lines
starting with <!--2-->  as an attempt to manipulate an RTF as a node-set
and raise an error. 

The present definition of exslt:node-set() does allow such different
behaviour.

Therefore, an XSLT transformation using exslt:node-set() will be
applied successfully on Saxon 6.5 and this same transformation will end
abnormally on other XSLT processors.

This is exactly the opposite of what EXSL was defined to achieve.

In order to correct this situation, I propose the definition of
exslt:node-set() to be changed:

"The exsl:node-set function takes an argument, which is a result tree
fragment and returns a node set, which has exactly the same structure,
names and values nodes. The exslt:node-set() function does not have
side effects, e.g. it does not change the its argument".

Cheers,
Dimitre Novatchev.



__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com
_______________________________________________
exslt mailing list
list@[...].org
http://www.exslt.org/list
Thread:
Dimitre Novatchev
Jeni Tennison
Dimitre Novatchev
Jeni Tennison

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