Reputation: 81
I try to delete the last character in the balises of a XML with XSL
For example
<hello>
...
<essai1>essai1</essai1>
...
<essai2>essai2 .</essai2>
...
</hello>
I would like the result unless point
<hello>
...
<essai1>essai1</essai1>
...
<essai2>essai2 </essai2>
...
</hello>
Could you help me ? Thanks, Arnaud
Upvotes: 0
Views: 1069
Reputation: 117018
The question is a bit too broad, IMHO. The following stylesheet will remove a trailing period from any text node in the entire document, leaving everything else as is:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()[substring(., string-length()) ='.']">
<xsl:value-of select="substring(., 1, string-length() - 1)"/>
</xsl:template>
</xsl:stylesheet>
Upvotes: 1