I have a sample xml file like this,
<doc>
<p>text1 text2 </p>
<p>text1 text2 </p>
<p>text1 text2 </p>
</doc>
this sample xml, first <p>
has space whitespace character ( 
), second <p>
has tab whitespace whitespace character (	
) and third <p>
has space non-breaking whitespace character ( 
).
I need to remove the any white spaces appearing just before closing tag.
So, expected output should be,
<doc>
<p>text1 text2</p>
<p>text1 text2</p>
<p>text1 text2</p>
</doc>
By using xslt normalize-space() I can remove unnecessary spaces and tab characters but not non-breaking whitespace characters.
<xsl:template match="p/text()">
<xsl:value-of select="normalize-space()"/>
</xsl:template>
Any suggestions how can I normalize all white spaces including non-breaking white spaces in xslt?
translate()
of those to a normal space before calling thenormalize-space
– Stefan Hegny