I am using xsl:evaluate to get the value an XPath points to.
Example code:
<xsl:variable name="input" as="xs:string">
<xsl:evaluate xpath="$someXPath" context-item="."/>
</xsl:variable>
It works fine, but if the XPath I am passing to xsl:evaluate is wrong and points to nothing I get this error when it tries to assign the empty value to the $input variable:
XTTE0570 An empty sequence is not allowed as the value of variable
$input
I also tried it this way (adding as="xs:string" to xsl:evaluate)
<xsl:variable name="input" as="xs:string">
<xsl:evaluate xpath="$Variable[@type=$EXnn]/@element" context-item="$Attribut" as="xs:string"/>
</xsl:variable>
but I get the same type of error:
Dynamic error in expression {myXPath} called using xsl:evaluate.
Caused by net.sf.saxon.trans.XPathException: An empty sequence is not allowed as the
result of the expression {myXPath} evaluated by xsl:evaluate
How should I deal with the case where the XPath does not return anything?
question from:
https://stackoverflow.com/questions/65926515/dealing-with-empty-sequence-returned-by-xslevaluate 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…