I have the following file log.xml
:
<entry>
<message>Line 1
Line 2 and so on</message>
</entry>
On CentOS 5.4 using xmlstarlet 1.0.1 if I run the following command, while removing linefeed in message
:
xml sel -t -m //entry -v "translate(message,'
' ,'@')" log.xml
The result is:
Line 1@ Line 2 and so on
On CentOS 6 using xmlstarlet:
1.3.1
compiled against libxml2 2.7.6, linked with 20706
compiled against libxslt 1.1.26, linked with 10126
I'll receive:
Line 1
Line 2 nd so on
Note "and" converted to nothing. I suppose it's not problem of xmlstarlet, but rather some change in libxslt.
Any ideas how to fix it?
UPDATE
Added problem with transform of letter "a" to nothing.
You can solve this in a general way by defining a variable containing the value of a line break:
--var linebreak -n --break
Then use that variable as the second argument of the translate function:
xml sel -t -m //entry
--var linebreak -n --break
-v "translate(message, \$linebreak ,'@')"
log.xml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With