How to parse a string or value of something in xslt

72 views Asked by At

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?

2

There are 2 answers

0
Tim C On BEST ANSWER

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>
0
David Carlisle On

probably the most direct translation of the test would be

<xsl:when test="starts-with(azn_cred_ip_address,'100.')">