Lowercase conversion in XSL

前端 未结 2 831
花落未央
花落未央 2021-01-18 15:24

I have an XML like



 Jack
 Dawson



        
相关标签:
2条回答
  • 2021-01-18 15:54

    To convert a string to lower case or uppercase you can use the XPath 1.0 function translate:

    First define your alphabets for lower case and upper case letters. Note that the position of each pair of characters needs to be the same:

    <xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
    <xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
    

    Then you can convert to upper case:

    <xsl:value-of select="translate($toconvert,$lcletters,$ucletters)"/>
    

    or to lower case

    <xsl:value-of select="translate($toconvert,$ucletters,$lcletters)"/>
    
    0 讨论(0)
  • 2021-01-18 16:14

    emp[lower-case(fname)=lower-case($srchStr)]

    Or, if you have XPath 1.0 only, you may try using translate like here: http://geekswithblogs.net/TimH/archive/2006/07/06/84229.aspx

    Be warned though, the example with translate would not work on names with accents (like mine :)

    0 讨论(0)
提交回复
热议问题