Input:
<?xml version="1.0" encoding="UTF-8" ?>
<Customer>
<FName>Vijender Reddy</FName>
<Address>Hyderabad </Address>
<Id>122 2222</Id>
</Customer>
Output:
<Customer>
<FName>VijenderReddy</FName>
<Address>Hyderabad</Address>
<Id>1222222</Id>
</Customer>
我们需要删除所有元素值中的空格。
答案 0 :(得分:1)
即使在XSLT 1.0中也很容易,因为translate(., ' ', '')
将删除所有空格,因此编写两个模板,第一个是身份转换模板,复制不变,不需要更改,第二个执行转换:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Customer/*[not(*)]">
<xsl:copy>
<xsl:value-of select="translate(., ' ', '')"/>
</xsl:copy>
</xsl:template>
</xsl:transform>