2012-01-20 10 views
10

Tengo un requisito en el que necesito verificar DB/@dbtype == 'oracle' (no distingue entre mayúsculas y minúsculas). ¿Cómo puedo hacer eso? Aquí está mi códigoCómo comprobar si la igualdad de cadenas no es sensible en xsl

<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> 

pensé de convertirlo en minúsculas/mayúsculas y luego verificar en consecuencia, por lo que se utiliza por debajo

<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?--> 

favor me ayude a cabo, cómo comparar las cuerdas (mayúsculas y minúsculas forma)

Respuesta

14

De la misma manera:

<xsl:if test="translate(DB/@dbtype, $smallcase, $uppercase) = 'ORACLE'"> 
1
<xsl:if test="translate(product/@name, $smallcase, $uppercase) = translate('Oracle', $smallcase, $uppercase)"> 
stuff 
</xsl:if> 
Cuestiones relacionadas