Is it possible to write out xml based on an "if" "Like" statement or the equivalent of in xslt?
I have an element named "cust_code" If the element starts with a "HE" then I want to write it out, otherwise jump to the next.
Is it possible?
Is it possible to write out xml based on an "if" "Like" statement or the equivalent of in xslt?
I have an element named "cust_code" If the element starts with a "HE" then I want to write it out, otherwise jump to the next.
Is it possible?
If
statements exist in XSLT.
<xsl:if test="...">
...
</xsl:if>
But this is a simple if
, with no alternative.
If you want an equivalent to if ... else ...
or switch ... case ...
, you need to use the following:
<xsl:choose>
<xsl:when test="...">
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
You can have as many when
cases as necessary.
Links: w3school - if and w3school - choose.
As to having an element starting with a specific string, look at the function starts-with
. You can find a good example in this SO answer (just omit the not
from the main answer, as their tests was to find strings not starting with a particular string). You can also look at this answer for more information.