嗨,我有字段<name>ATTN Dani</name>
,我需要删除ATTN,但它来了ATTN有时attn或Attn甚至ATtn我怎么能做这个子字符串我做了下面的xslt,但它影响的价值。我不希望如果你知道字符串“ATTN”,但不能确定的情况下开始的价值受到影响如何子字符串不区分大小写
<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:pfx4="http://xmlns.oracle.com/apps/otm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<PARTNER_INBOUND_V2>
<xsl:choose>
<xsl:when test="starts-with(upper-case(//root/name), 'ATTN')">
<IS_ACTIVE>Working</IS_ACTIVE>
<test><xsl:value-of select="normalize-space(substring-after(upper-case(//root/name),'ATTN'))"/></test>
</xsl:when>
<xsl:otherwise>
<IS_ACTIVE>Y</IS_ACTIVE>
</xsl:otherwise>
</xsl:choose>
</PARTNER_INBOUND_V2>
</xsl:template>
</xsl:stylesheet>
您可以尝试使用'translate()'将字符串转换为大写或小写,然后进行比较。看到这个:http://stackoverflow.com/questions/586231/how-can-i-convert-a-string-to-upper-or-lower-case-with-xslt –
顺便说一句,在你的具体例子在这里,你永远不会有一个以'ATTN'开头的名字,因为它在''块中,它特别要求它以'C/O'开头,除非你有多个'name'元素作为根的孩子。 –
Flynn1179
您的样式表示版本1.0,但'大写()'需要XSLT 2.0。在你的问题中更令人困惑的事情。 –