I have a requirement where I need to check DB/@dbtype
== 'oracle' (case insensitive). How can I do that? Here is my code
我需要检查DB/@dbtype = 'oracle'(不区分大小写)。我该怎么做呢?这是我的代码
<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)
请帮助我,如何比较字符串(不区分大小写)
3 个解决方案
#1
15
In the same way:
以同样的方式:
<xsl:if test="translate(DB/@dbtype, $smallcase, $uppercase) = 'ORACLE'">
#2
9
Well if you're using XSLT 2.0+ then you can use
如果你使用的是XSLT 2.0+,那么你可以使用
http://saxonica.com/documentation/functions/intro/lower-case.xml
http://saxonica.com/documentation/functions/intro/lower-case.xml
i.e.
即。
<xsl:if test="lower-case(product/@name)='oracle')">
</xsl:if>
#3
1
<xsl:if test="translate(product/@name, $smallcase, $uppercase) = translate('Oracle', $smallcase, $uppercase)">
stuff
</xsl:if>
#1
15
In the same way:
以同样的方式:
<xsl:if test="translate(DB/@dbtype, $smallcase, $uppercase) = 'ORACLE'">
#2
9
Well if you're using XSLT 2.0+ then you can use
如果你使用的是XSLT 2.0+,那么你可以使用
http://saxonica.com/documentation/functions/intro/lower-case.xml
http://saxonica.com/documentation/functions/intro/lower-case.xml
i.e.
即。
<xsl:if test="lower-case(product/@name)='oracle')">
</xsl:if>
#3
1
<xsl:if test="translate(product/@name, $smallcase, $uppercase) = translate('Oracle', $smallcase, $uppercase)">
stuff
</xsl:if>