How to change the first letter to lowercase using XPath or XSLT

I am using wso2esb-4.8.1.

I want to change my first request letter to lowercase. I get the request parameters as follows:

 <property name="Methodname" expression="//name/text()" scope="default" type="STRING"/>

So I get names like

GetDetails, CallQuerys, ChangeService ...

While I want to change all names like this:

getDetails, callQuerys, changeService ...

If I wanted the upper or lower case of the whole name, I could use the XPath fn:upper-case()and functions fn:lower-case(), but my requirement is different.

How can I change all first letters only in lower case?

Is this possible with XPath or XSLT?

+4
source share
2

XPath 1.0:

<property name="Methodname" scope="default" type="STRING" 
          expression="concat(translate(substring(//name/text(), 1, 1), 
                                       'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 
                                       'abcdefghijklmnopqrstuvwxyz'), 
                             substring(//name/text(), 2))"/>

XPath 2.0:

<property name="Methodname" scope="default" type="STRING" 
          expression="concat(lower-case(substring(//name/text(), 1, 1)), 
                             substring(//name/text(), 2))"/>
+4

kjhughes answer/this , , , :

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="@*|node()">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
        </xsl:template>

    <xsl:template match="@name[ancestor::property]">
        <xsl:attribute name="name">
            <xsl:value-of select="concat(translate(substring(., 1, 1), 
                           'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 
                           'abcdefghijklmnopqrstuvwxyz'), substring(., 2))"/>
        </xsl:attribute>
    </xsl:template>

</xsl:stylesheet>
+1

All Articles