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

RE: XSLT 2.0: Cast does not allow an empty sequence

Subject: RE: XSLT 2.0: Cast does not allow an empty sequence
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 19 Jul 2007 09:09:02 +0100
RE:  XSLT 2.0:  Cast does not allow an empty sequence
Please check whether this still happens with 8.9.0.4. It feels like a bug
that was fixed.

Michael Kay
http://www.saxonica.com/

 

> -----Original Message-----
> From: Sam Byland [mailto:shbyland@xxxxxxxxxxx] 
> Sent: 19 July 2007 02:49
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  XSLT 2.0: Cast does not allow an empty sequence
> 
> Hello again,
> 
> Still debugging the upgrade to XSLT 2.0.  This one took some 
> time to create a reduced stylesheet that still reproduced the 
> error.  The XML instance file (probably irrelevant) is the 
> same as my last post:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <Test>"Hello" &#x2260; "World"</Test>
> 
> Using SaxonB-8.9j, I get the following error:
> 
> <<Error on line 42 of file:/C:/Test/Saxon/Test20.xsl:
> XPTY0004: Cast does not allow an empty sequence 
> Transformation failed: Run-time errors were reported>>
> 
> with the following XSLT:
> 
> <xsl:stylesheet version="2.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>     <xsl:output name="OutHTML" method="html" encoding="windows-1252"/>
> 
>     <xsl:param name="DocumentCode" select=" 'abc11111' "/>
>     <xsl:param name="Flag1" select="boolean( true() or 
> false() )"/> <!-- force to true -->
>     <xsl:param name="Flag2" select="boolean( number( 
> substring( $DocumentCode , 6 , 1 ) ) )"/>
>     <xsl:param name="Flag3" select="substring( $DocumentCode 
> , 6 , 1 )"/>
> 
>     <xsl:variable name="FirstPass" as="document-node()">
>         <xsl:document>
>             <xsl:copy-of select="Test"/>
>         </xsl:document>
>     </xsl:variable>
> 
>     <xsl:template match="Test">
>         <xsl:result-document href="test20.html" format="OutHTML">
>             <xsl:apply-templates select="$FirstPass" mode="SomeMode"/>
>         </xsl:result-document>
>     </xsl:template>
> 
>     <xsl:template match="Test" mode="SomeMode">
>         <html>
>             <head>
>                 <title>test</title>
>             </head>
>             <body>
>                 <p><xsl:call-template name="SomeNamedTemplate"/></p>
>             </body>
>         </html>
>     </xsl:template>
> 
>     <xsl:template name="SomeNamedTemplate">
> 
>         <xsl:variable name="SomeVariable1">
>             <xsl:choose>
>                 <xsl:when test="$Flag3 = '1' and 
> //SomeElement[not(ancestor::Foo)][not(contains(string(Bar),'$'
> ))]">true</xsl:when>
>                 <xsl:when test="$Flag3 != '1' and 
> //SomeElement[not(contains(string(Foo),'$'))]">true</xsl:when>
>             </xsl:choose>
>         </xsl:variable>
> 
>         <xsl:value-of select="$SomeVariable1"/>
> 
>     </xsl:template>
> 
> </xsl:stylesheet>
> 
> *However*, when I try to debug by adding an xsl:message 
> within xsl:variable name="SomeVariable1", the error goes away 
> (?!).  i.e. with this mod:
> 
>         <xsl:variable name="SomeVariable1">
>             <!-- the xsl:message instruction below makes 
> error go away! -->
>             <xsl:message>Flag3: <xsl:value-of 
> select="$Flag3"/>, Cond1: 
> <xsl:value-of
> select="//SomeElement[not(ancestor::Foo)][not(contains(string(
> Bar),'$'))]"/>,
> Cond2: <xsl:value-of
> select="//SomeElement[not(contains(string(Foo),'$'))]"/></xsl:message>
>             <xsl:choose>
>                 <xsl:when test="$Flag3 = '1' and 
> //SomeElement[not(ancestor::Foo)][not(contains(string(Bar),'$'
> ))]">true</xsl:when>
>                 <xsl:when test="$Flag3 != '1' and 
> //SomeElement[not(contains(string(Foo),'$'))]">true</xsl:when>
>             </xsl:choose>
>         </xsl:variable>
> 
> I now get the following in the output, and the transformation 
> continues to the end without any errors:
> 
> <<Flag3: 1, Cond1: , Cond2: >>
> 
> Any thoughts on what is going on here?
> 
> tia,
> 
> ...sam 

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.