xsl-list
[Top] [All Lists]

Re: [xsl] strong typed variable with restriction ?

2011-02-02 04:48:26
Andrew Welch wrote:
On 2 February 2011 10:16, Matthieu Ricaud-Dussarget
<matthieu(_dot_)ricaud(_at_)igs-cp(_dot_)fr>  wrote:

My code looks like :
<xsl:function name="igs:get-css-rule" as="element()">
<xsl:param name="foobar" as="xs:string"/>  <!--(foo|bar)-->
<xsl:choose>
<xsl:when test="$foobar='foo'">
<xsl:sequence select="igs:get-my-foo-item()"/>
</xsl:when>
<xsl:when test="$css='bar'">
<xsl:sequence select="igs:get-my-bar-item()"/>
</xsl:when>
</xsl:choose>
</xsl:function>

And I get such a parsing  error on my xslt :
  XTTE0570: Conditional expression: If none of the conditions is satisfied,
an empty

You get the error because you must have an xsl:otherwise, you can't
just have xsl:whens.

I am confused, http://www.w3.org/TR/xslt20/#xsl-choose says

<xsl:choose>
  <!-- Content: (xsl:when+, xsl:otherwise?) -->
</xsl:choose>

so in general the xsl:otherwise is optional.

So why is the xsl:otherwise required in the above case, to ensure the result type of the function?



--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
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>
--~--