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

RE: [XSLT2] Different results using xsl:copy-of and x

Subject: RE: [XSLT2] Different results using xsl:copy-of and xsl:sequence with Saxon 7.8
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 17 Nov 2003 20:36:07 -0000
using xsl copy of
Dimitre, could you please send me a repro for this? It's definitely a
bug but I can't easily reproduce it without the full stylesheet.

It's a bug related to tail call optimization. Functions whose body
consists solely of a sequence of xsl:param, xsl:variable, and
xsl:sequence are compiled differently from those that include
instructions like xsl:copy-of, with heavier optimization.

Thanks,

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Dimitre Novatchev
> Sent: 14 November 2003 21:43
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  [XSLT2] Different results using xsl:copy-of 
> and xsl:sequence with Saxon 7.8
> 
> 
> I have this code:
> 
> func-allTrue.xsl:
> ------------------
> <xsl:stylesheet version="2.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:fxl="http://fxsl.sf.net/"
> xmlns:allTrue-And="allTrue-And"
> exclude-result-prefixes="fxl xs allTrue-And"
> >
>   <xsl:import href="func-foldl.xsl"/>
> 
>   <xsl:function name="fxl:allTrue" as="xs:boolean" >
>     <xsl:param name="pList" as="xs:boolean*"/>
> 
>     <xsl:variable name="vAnd" 
> select="document('')/*/allTrue-And:*[1]"/>
> 
>     <xsl:copy-of select="fxl:foldl($vAnd, true(), $pList)"/>
>   </xsl:function>
> 
>   <allTrue-And:allTrue-And/>
>   <xsl:template name="And" match="allTrue-And:*" as="xs:boolean">
>     <xsl:param name="arg1" as="xs:boolean"/>
>     <xsl:param name="arg2"  as="xs:boolean"/>
>     <xsl:sequence select="$arg1 and $arg2"/>
>   </xsl:template>
> 
> </xsl:stylesheet>
> 
> This stylesheet defines an xsl:function fxl:allTrue
> 
> I apply the allTrue function as follows:
> 
> <xsl:stylesheet version="2.0"  
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>  xmlns:xs="http://www.w3.org/2001/XMLSchema"
>  xmlns:fxl="http://fxsl.sf.net/"
>  exclude-result-prefixes="fxl xs"
> >
>   <xsl:import href="func-allTrue.xsl"/>
> 
>   <xsl:output omit-xml-declaration="yes"/>
> 
>   <!-- This transformation must be applied to:
>         boolNodes.xml
>      -->
> 
>   <xsl:template match="/">
>     <xsl:variable name="allTrue"
>          select="fxl:allTrue(/*/*/text())"/>
> 
>     <xsl:value-of select="$allTrue"/>
> 
>     <xsl:if test="not($allTrue)">
>       <xsl:text>Not </xsl:text>
>     </xsl:if>
>     <xsl:value-of select="'all nodes contents are true in:'"/>
>     <xsl:text>&#xA;</xsl:text>
>     <xsl:copy-of select="/*/*"/>
>   </xsl:template>
> </xsl:stylesheet>
> 
> When applied on this source.xml:
> 
> <t>
>   <a>1</a>
>   <b>1</b>
>   <c>0</c>
>   <d>1</d>
> </t>
> 
> the correct result is produced:
> 
> falseNot all nodes contents are true in: 
> <a>1</a><b>1</b><c>0</c><d>1</d>
> 
> 
> The problem:
> 
> In the code of allTrue I replace xsl:copy-of with 
> xsl:sequence like this:
> 
>       <xsl:copy-of select="fxl:foldl($vAnd, true(), $pList)"/>
> 
> with
> 
>     <xsl:sequence select="fxl:foldl($vAnd, true(), $pList)"/>
> 
> I run the same test again and get a dynamic error:
> 
> "Dynamic error in function fxl:allTrue
> Dynamic error in function fxl:allTrue
> Error at variable on line 17 of
> file:/E:/xml/msxml/XML%20SDK/Samples/Tests/Generic/FP/Fxsl/XSL
T2/marrowtr.xsl:
  Required type of result of function fxl:allTrue is xs:boolean;
supplied value is java:java.lang.Object Transformation failed: Run-time
errors were reported"

My questions:

What is actually happening here? Is this difference in the behaviour of
xsl:copy and xsl:sequence documented in the WD? Am I not understanding
and using xsl:sequence in a correct way or is this a bug in the XSLT
processor?



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL









 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.