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)
In the same way:
<xsl:if test="translate(DB/@dbtype, $smallcase, $uppercase) = 'ORACLE'">
Well if you're using XSLT 2.0+ then you can use
http://saxonica.com/documentation/functions/intro/lower-case.xml
i.e.
<xsl:if test="lower-case(product/@name)='oracle'">
something
</xsl:if>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With