Subject: RE: [xsl] XSLT 2.0: Cast does not allow an empty sequence From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Thu, 19 Jul 2007 09:09:02 +0100 |
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: [xsl] 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" ≠ "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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XSLT 2.0: Cast does not allo, Sam Byland | Thread | Re: [xsl] XSLT 2.0: Cast does not , Sam Byland |
RE: [xsl] [xslt 2.0] Difference bet, Michael Kay | Date | RE: [xsl] [xslt 2.0] Local function, Michael Kay |
Month |