views:

289

answers:

2

hi guys, i have this block of xslt if-else case and was wondering if there's a way for me to do straight comparison with unicode character?

Something along the lines of the code shown below? Or does xslt have some built in function which i can use for this purpose? i.e. change the unicode into html entities and compare via that method?

Of course if there's a better way please fire away. Thanks.

<xsl:choose>
         <xsl:when test="status">
          <xsl:if test="status='تم المحاولة'">
           <font color="#00CC00"><xsl:value-of select="status" /></font><br/>
       <!--a href="/Elearning_Platform/xfiles/reports/view_reports.modcgi?asm_lid={@lom_id}&amp;did={@dispatch_id}&amp;rm_student_id={@person_id}&amp;report_type=2">[View Results]</a-->
          </xsl:if>
</xsl:when>
         <xsl:otherwise>
          &nbsp;
         </xsl:otherwise>
        </xsl:choose>
+1  A: 

If both the source XML and the XSLT are declared as UTF-8 encoded i believe this shouldnt be a problem. If your parser supports EXSLT you can call url-decode(status) directly this resource has some examples + makes a good read about encoding in XSLT in general.

Martijn Laarman
Would work with UTF-16 too.
MSalters
well actually i tried to do direct xsl:if test var=[some arabic text], but it didn't work. And i'm using putty, could this be the cause? thanks.
melaos
I do not think that the encoding of the source XML and the XSLT program matter. XSLt works on the infoset, not on the text representation.
bortzmeyer
+1  A: 

The answer is positive.

More precisely, any character that can be used within an XML document, can be used as part of an argument to an XPath equality comparison operator.

Dimitre Novatchev