#101 XPath function 'translate' can't process '&#xD'

closed-invalid
nobody
main code (54)
5
2013-02-01
2013-01-31
Volker
No

To remove line breaks from a string you can't use

translate(comment,'
', ' ')

See http://xmlplease.com/whitespace for more examples.

Discussion

  • Volker
    Volker
    2013-01-31

    Tested version:

    xmlstarlet --version
    1.3.1
    compiled against libxml2 2.7.8, linked with 20708
    compiled against libxslt 1.1.26, linked with 10126

     
  • Noam Postavsky
    Noam Postavsky
    2013-02-01

    Interpreting 
 to mean carriage return is performed by the XML parser, but the arguments to xmlstarlet's sel and ed subcommands are just plain strings, not XML. If you want a newline pass a newline:

    # in bash
    $'translate(comment, "\n", " ")'

    # in powershell.exe
    "translate(comment, '`n', ' ')"

    :: in cmd.exe
    "translate(comment, '"^

    "', ' ')"

     
  • Noam Postavsky
    Noam Postavsky
    2013-02-01

    • status: open --> closed-invalid