2014-10-20 6 views
4

wso2esb-4.8.1을 사용하고 있습니다.XPath 또는 XSLT를 사용하여 첫 글자를 소문자로 바꾸는 방법

첫 번째 문자를 소문자로 변경하고 싶습니다. 나는이 같은 요청 매개 변수를 얻고있다 :

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

을 이런 식으로 내가

GetDetails, CallQuerys, ChangeService 같은 이름을 얻고에서 ...

나는 모든 이름을 변경하고자하는 반면 이렇게하려면 :

getDetails, callQuerys, changeService ...

전체 이름의 대소 문자를 구하려면 XPath의 fn:upper-case()fn:lower-case() 함수를 사용할 수 있지만 요구 사항이 다릅니다.

모든 첫 글자을 소문자로 어떻게 바꿀 수 있습니까?

XPath 또는 XSLT로 가능합니까?

답변

4

의 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))"/> 
1

은 그냥 당신이 아마와 함께 이것을 사용하는 것이 좋습니다,이 answer here/kjhughes 대답에 추가 문서의 나머지 부분을 흠집없는 복사하기위한 ID 변환 :

<?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> 
관련 문제