la nourriture pour animaux de ligne (LF) à partir du noeud XML en utilisant XSLT
Question
Je suit dans un nœud XML:
<TR_Comment>XXX YYY ZZZ
</TR_Comment>
(comme vous pouvez le voir il y a un saut de ligne)
Mon XSLT est très simple:
<xsl:value-of select="a:Common/a:TR_Comment"/>
Comment puis-je supprimer l'alimentation en ligne en utilisant XSLT?
La solution
Does normalize-space(a:Common/a:TR_Comment)
do what you want?
If you are really keen on preserving inner whitespace, it can get a bit inelegant. One way is to make a recursive template that uses string-length
and substring
to keep removing characters from the end, one at a time, until there is no trailing whitespace.
Autres conseils
Use:
translate(., ' ', '')
when this expression is evaluated, the result is the string value of the current node from which any NL or CR characters are removed.
Do note that no other characters are deleted or modified, so this is a more precise solution and may be preferrable in some cases over normalize-space()