如何在 xsl 中检查字符串相等性不区分大小写 [英] How to check for string equality case insensitive in xsl
本文介绍了如何在 xsl 中检查字符串相等性不区分大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个要求,我需要检查 DB/@dbtype
== 'oracle'(不区分大小写).我怎样才能做到这一点?这是我的代码
I have a requirement where I need to check DB/@dbtype
== 'oracle' (case insensitive). How can I do that?
Here is my code
<xsl:choose>
<xsl:when test="DB/@dbtype">
<p>
<dd>
<table border="1">
<tbody>
<tr>
<th>Name</th>
<th>Value</th>
</tr>
<xsl:if test="DB/@dbtype='ORACLE'">
<xsl:for-each select="DB/oracle_props">
<tr>
<td valign="top" ><xsl:value-of select="@name"/></td>
<td valign="top" ><xsl:value-of select="@value"/></td>
</tr>
</xsl:for-each>
</xsl:if>
</tbody>
</table>
</dd>
</p>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="DB"/>
</xsl:otherwise>
</xsl:choose>
我想把它全部转换成小写/大写然后相应地检查,所以我在下面使用
I thought of converting it into all lowercase/uppercase and then check accordingly, so I used below
<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:value-of select="translate(product/@name, $smallcase, $uppercase)"/>
<!--It display in lower case, but how to use this in checking for equality?-->
请帮帮我,如何比较字符串(不区分大小写的方式)
Please help me out, how to compare String (case insensitive way)
推荐答案
同理:
<xsl:if test="translate(DB/@dbtype, $smallcase, $uppercase) = 'ORACLE'">
这篇关于如何在 xsl 中检查字符串相等性不区分大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文