Subject: Re: [xsl] strong typed variable with restriction ? From: Michael Kay <mike@xxxxxxxxxxxx> Date: Wed, 02 Feb 2011 11:21:59 +0000 |
I have a xsl:function which : - must return a element() - has a string param "foobar".
I typed $foobar as xs:string but I'd like to restrict the possible values to "foo" or "bar".
I know it's possible to define such a constrain in a xsd schema, but is there a way to do that in xpath2 ?
<xsl:import-schema> <xs:schema targetNamespace="urn:local:foobar"> <xs:simpleType name="foobarType"> <xs:restriction base="xs:string"> <xs:enumeration value="foo"/> <xs:enumeration value="bar"/> </xs:restriction> </xs:simpleType> </xs:schema> </xsl:import-schema>
<xsl:function name="igs:get-css-rule" as="element()"> <xsl:param name="foobar" as="fb:foobarType"/> ....
This typing is important because the returned element() is selected from a xsl:choose on $foobar value (with no otherwise) :
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
sequence will be returned, but this is not allowed [...]
Michael Kay Saxonica
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] strong typed variable wit, Matthieu Ricaud-Duss | Thread | Re: [xsl] strong typed variable wit, Matthieu Ricaud-Duss |
Re: [xsl] strong typed variable wit, Martin Honnen | Date | Re: [xsl] strong typed variable wit, Matthieu Ricaud-Duss |
Month |