我有一个要求,我需要将其从大写转换为小写。但是第一个字母应该保持大写。
输入:<LineStatus>DELETED</LineStatus>
预期输出:<LineStatus>Deleted</LineStatus>
以下是代码
`<xsl:template match="/">
<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:value-of select="translate(DELETED, $smallcase, $uppercase)" />
</xsl:template>`
这将输出为deleted
我尝试了<xsl:value-of select="translate(substring(DELETED,1,1), $smallcase, $uppercase)" />
之类的内容,但它为我提供了输出d
有人可以提供建议吗?
更新
我创建了一个模板,我正在这样做
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<<xsl:variable name="LineStatus" select="//OrderResponse/OrderResponseBody/OrderResponseDetails/OrderResponseProductLineItem/LineStatus/text()"/>
<xsl:variable name="change"><xsl:value-of select="substring($LineStatus, 1, 1)"/></xsl:variable>
<xsl:variable name="RSRIden" select="/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='OrderResponse']/*[local-name()='OrderResponseBody']/*[local-name()='OrderResponseDetails']/*[local-name()='OrderResponseProductLineItem']/*[local-name()='SpecialInstructions' and @*[local-name()='InstructionType' and normalize-space(.) = 'PostingInstructions']]"/>
<xsl:variable name="RSRDescri" select="/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='OrderResponse']/*[local-name()='OrderResponseBody']/*[local-name()='OrderResponseDetails']/*[local-name()='OrderResponseProductLineItem']/*[local-name()='SpecialInstructions' and @*[local-name()='InstructionType' and normalize-space(.) = 'ShipperInstructions']]"/>
<xsl:template name="Reject-Status">
<ResponseStatus>
<ResponseStatusReasonIdentifier Agency="ResponseCode">
<xsl:value-of select="$RSRIden"/>
</ResponseStatusReasonIdentifier>
<ResponseStatusReasonDescription>
<xsl:value-of select="$RSRDescri"/>
</ResponseStatusReasonDescription>
</ResponseStatus>
<!--<LineStatus><xsl:value-of select="translate($change,$uppercase,$smallcase)" /></LineStatus>-->
</xsl:template>
</xsl:stylesheet>
更改为此并正常工作
<LineStatus><xsl:value-of select="substring($LineStatus, 1, 1)"/><xsl:value-of select="translate(substring($LineStatus,2),$uppercase,$smallcase)" /></LineStatus>
答案 0 :(得分:2)
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:template match="/">
<xsl:value-of select="substring(LineStatus, 1, 1)"/>
<xsl:value-of select="translate(substring(LineStatus, 2), $uppercase, $lowercase)" />
</xsl:template>