« Specifying null content in your XML Document using nillable and xsi:nil | Main | Customizing any BPEL Project Artifact using <customizeDocument> »

Removing additional whitespaces in your Elements and Attributes

In case your XML elements contain multiple whitespaces within the text, or leading and trailing the text, you could use normalize-space() function to remove the leading and trailing whitespaces, as well as to combine all adjacent intermediary whitespaces into one single whitespace.


For e.g


Input


&lt;input>   1sp 2sp  3sp   4sp     5sp     3sp   end&lt;/input>


XSLT


 &lt;ns1:result>
   &lt;xsl:value-of select="normalize-space(/input)"/>
&lt;/ns1:result>


Result


&lt;result>1sp 2sp 3sp 4sp 5sp 3sp end&lt;/result>

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About This Entry

This page contains a single entry from the blog posted on November 14, 2007 10:30 PM.

The previous post in this blog was Specifying null content in your XML Document using nillable and xsi:nil.

The next post in this blog is Customizing any BPEL Project Artifact using <customizeDocument>.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle