xsl-list
[Top] [All Lists]

Re: [xsl] Saxon error: "If none of the conditions is satisfied, an empty sequence..."

2011-05-25 10:14:52
Hi,

But is there any reason not to do something much simpler?

<xsl:variable name="seq_position" as="xs:integer?">
  <xsl:number/>
</xsl:variable>

Cheers,
Wendell

On 5/23/2011 7:12 PM, Michael Kay wrote:
On 23/05/2011 23:47, tom a wrote:
Hello,

When attempting to compile a stylesheet containing the following variable
definition:

<xsl:variablename="seq_position"as="xs:integer*">
<xsl:choose>
<xsl:whentest="name() eq 'step1'">
<xsl:sequenceselect="count(preceding-sibling::step1) + 1"/>
</xsl:when>
<xsl:whentest="name() eq 'step2'">
<xsl:sequenceselect="count(preceding-sibling::step2) + 1"/>
</xsl:when>
<xsl:whentest="name() eq 'step3'">
<xsl:sequenceselect="count(preceding-sibling::step3) + 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:sequenceselect="99+1"/><!--trying to placate saxon->
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
I get the error:
"XTTE0570: Conditional expession: If none of the conditions is
satisfied, an
empty sequence
will be returned, but this is not allowed as the value of variable
$seq_position"
I haven't the foggiest idea why this would be. Any help would be most
greatly
appreciated.

I assume you only get the error when the xsl:otherwise branch is absent,
and when the declared type really doesn't allow an empty sequence (for
example, as="xs:integer+" rather than as="xs:integer*"). The reason for
the error is that omitting the otherwise branch is equivalent to writing

<xsl:otherwise><xsl:sequence select="()"/></xsl:otherwise>

and this would give a type error on the grounds that () is not a legal
value for the variable.

However, there have been a number of complaints about this
interpretation of the spec, and I'm going to change it in the next
release so you get a compile time warning, followed by a run-time error
if the otherwise branch is actually selected.

--
======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>