I am using wso2esb-4.8.1.
I wish to change my request first letter to lowercase. I am getting request parameters like this:
<property name="Methodname" expression="//name/text()" scope="default" type="STRING"/>
In this way I am getting names like
GetDetails, CallQuerys, ChangeService...
Whereas I wish to change all the names to be like this:
getDetails, callQuerys, changeService...
If I wanted to upper or lower the case of the entire name, I could use XPath's fn:upper-case()
and fn:lower-case()
functions, but my requirement is different.
How can I change all the first letters only to lowercase?
Is it possible with XPath or XSLT?
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))"/>
Just to add to kjhughes
answer / this answer here, you'll probably want to use this in conjunction with the identity transform to copy the remainder of the document unscathed:
<?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>
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