如何解析 xslt 中的字符串或值

How to parse a string or value of something in xslt

我是 xslt 的新手,尝试使用 xslt 通过 authzrule 捕获和评估用户的 IP 地址。我知道IP可以通过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>

然而IP并不总是相同的,但我想检查前3位数字是否为100。 怎么修改上面的xslt看IP是不是100开头的?

您可以在此处使用 substring-before(因为如果第一个数字也小于 3 位数字,这也有效。

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

可能最直接的测试翻译是

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