• 1 reply
  • Latest Post - ‏2013-06-21T12:48:06Z by HermannSW
412 Posts

Pinned topic Testing multiple error condition.

‏2013-06-21T10:17:32Z |

Hello Experts,

If I want to configure XSL to test multiple error conditions in an error rule, will the below statement work properly?

<xsl:when test="dp:variable('var://service/error-code')='0x01130006' or '0x01130007' or '0x01130008 or 0x01130009'">

Or do you suggest some other method?




  • HermannSW
    7629 Posts

    Re: Testing multiple error condition.


    Hello Rahul,

    from the spec:

    "... If one object to be compared is a node-set and the other is a string, then the comparison will be true if and only if there is a node in the node-set such that the result of performing the comparison on the string-value of the node and the other string is true. ..."

    So you can have a nodeset of error values to compare against.

    But please cache the "error-code" value in a variable if you do access that value at many places (which your <xsl:when> suggests).
    Reason is that accessing any "dp:variable()" is much more costly than accessing a XPath VariableReference.

    So this can be what you need:

    <xsl:stylesheet version="1.0"
      <xsl:output omit-xml-declaration="yes" />

      <xsl:variable name="error-code"

      <xsl:variable name="codeset1">

      <xsl:template match="/">
        <xsl:value-of select="$error-code = $codeset1/*"/>


    In your special use case there is an alternative because of the "0x" prefixes for error codes:

      <xsl:variable name="codeset2"
        select=" '0x01130006 0x01130007 0x01130008 0x01130009' "

      <xsl:template match="/">
        <xsl:value-of select="contains($codeset2, $error-code)"/>


    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

    Updated on 2013-06-21T12:53:08Z at 2013-06-21T12:53:08Z by HermannSW