xsltwebseal

How to parse a string or value of something in xslt


I am new to xslt trying to capture and evaluate the IP address of user through authzrule using xslt. I know the IP can be evaluated by azn_cred_ip_address

<xsl:choose>
<xsl:when test=" azn_cred_ip_address = '100.200.300.400'">!TRUE!</xsl:when>
<xsl:otherwise>!FALSE!</xsl:otherwise>
</xsl:choose>

However the IP is not always the same, but I want to check to see if the first 3 digits are 100. How can I modify the above xslt to see if the IP starts with 100 or not?


Solution

  • You could use substring-before here (as this will also work if the first number is less than 3 digits too.

    <xsl:when test="substring-before(azn_cred_ip_address, '.') = '100'">!TRUE!</xsl:when>