Hello,
I have a function that must return a xs:string, or raise an error, if
result value can not be computed, or is empty-sequence.
Here is function :
B <xsl:function name="conf:getConfVar" as="xs:string">
B B B <xsl:param name="conf" as="element(els-conf:conf)"/>
B B B <xsl:param name="varName" as="xs:string"/>
B B B <xsl:sequence select="
B B B B B if (exists($conf/els-conf:variable[@name=$varName]))
B B B B B then $conf/els-conf:variable[@name=$varName]/@value
B B B B B else (
B B B B B B B error(
B B B B B B B B B $conf:ERROR_MISSING_ENTRY,
B B B B B B B B B concat('Entry ',$varName,' is missing in environment
configuration')
B B B B B B B )
B B B B B )
B B B B B "/>
B </xsl:function>
When a variable does not exist in $conf, I expect an error being raised,
and expect to catch it in a xsl:try / xsl:catch.
But, in this case, I get this :
XTTE0780: Conditional expression: The condition is not satisfied, so an
empty sequence is returned, but this is not allowed as the result of
call to conf:getConfVar
in xsl:sequence/@select ....
* I understand that error() function never return a value, so return
value does not satisfies xsl:function/@as constrint. Is it correct ?
* How could I write this, as I want the return type being xs:string,
and not xs:string?, and I want my error to be raised when entry is
missing ?
Best regards,
Christophe
|