Reputation: 1
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>
we need to remove the spaces in the all elements values.
Upvotes: 0
Views: 1218
Reputation: 167426
That is easy even in XSLT 1.0 as translate(., ' ', '')
will remove all spaces so write two templates, the first one being the identity transformation template copying unchanged what does not need change and the second doing the 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>
Online at http://xsltransform.net/pPzifpA.
Upvotes: 1