2017-04-18 2 views
0

다음 xml이 있습니다.XSL - 악센트 부호가있는 문자를 어떻게 대문자로합니까?

<surname>\`{a}bcd efgh</surname> 

첫 번째 문자를 대문자로 변환하고 다음 형식으로 출력하고 싶습니다.

<surname>\`{A}bcd Efgh</surname> 

난 당신이 문자열에 편지를 선두를 찾기 위해 analyze-string를 사용할 수있는 다음 코드를

<xsl:sequence select="string-join(for $x in tokenize($textone,'\s') return my:titleCase($x),' ')"/> 
+0

귀하의 샘플 코드는 더 악센트 문자를 포함하지 않는이 XSLT를 사용해보십시오. 실제로 'á'와'è '와 같은 글자를 대문자로 쓰는 데 도움이 필요합니까? –

답변

1

을 사용하고 있습니다.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
       xmlns:my="my-functions"> 
<xsl:output method="text" /> 

<xsl:function name="my:titleCase"> 
    <xsl:param name="string"/> 
    <xsl:analyze-string select="$string" regex="^([^A-Za-z]*)([A-Za-z])(.*)$"> 
    <xsl:matching-substring> 
     <xsl:value-of select="concat(regex-group(1), upper-case(regex-group(2)), regex-group(3))" /> 
    </xsl:matching-substring> 
    </xsl:analyze-string> 
</xsl:function> 

<xsl:template match="text()"> 
<xsl:variable name="textone" select="." /> 
<xsl:sequence select="string-join(for $x in tokenize($textone,'\s') return my:titleCase($x),' ')"/> 
</xsl:template> 
</xsl:stylesheet> 
+0

늦게 답장을 보내 주셔서 진심으로 감사드립니다. 당신의 도움을 주셔서 감사합니다 – Kevin

관련 문제