-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Writer::new_with_indent() inserts white space into <![CDATA[ content tags #197
Comments
Thanks for opening the issue. Do you have a specification to refer to? This is not obvious to me that the current behavior is wrong. |
Could not find anything concrete in the XML specification, only http://xml.silmaril.ie/whitespace.html which talks about significant and insignificant whitespace. A similar bug was reported to xml-js nashwaan/xml-js#14 where they also decided to not indent CDATA sections. |
Another data point is the PHP DOMDocument output which formats the same way as |
Same with Python import xml.dom.minidom
dom = xml.dom.minidom.parseString('<?xml version="1.0" encoding="UTF-8"?><jobs><job><jobid><![CDATA[00d46e4494e1]]></jobid></job></jobs>')
print(dom.toprettyxml()) <?xml version="1.0" ?>
<jobs>
<job>
<jobid><![CDATA[00d46e4494e1]]></jobid>
</job>
</jobs> Not sure if Python, PHP and xmllint all rely on the same XML parsing library, but I think these are pretty good indicators that quick-xml should do the same. |
FWIW, Altova XMLSpy also reformats this input as @klausi suggested: |
Problem: the pretty print functionality should not insert spaces new lines before and after
<![CDATA[
tags.Example input:
Output with
Writer::new_with_indent(out_file, b" "[0], 2);
This has now changed the content of the jobid tag, which is bad.
Correct with
xmllint --format
:This has correctly preserved the content of the jobid tag.
The text was updated successfully, but these errors were encountered: