-
Notifications
You must be signed in to change notification settings - Fork 89
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
Output XML does not preserve whitespace and this is no way configurable #66
Comments
Another option would be |
You can create PR to fix this, but it should be compatible with previous versions and not change the signature of already used method. |
I ran into this issue, as well. I guess I'm ultimately curious about why this package would even prefer to manipulate the whitespace of nodes in the output XML at all. Mutating XML node values is generally frowned upon unless there's an XSD or XSLT provided that explicitly allows or instructs for it. |
@zhengchun: Maybe something like this? func TestOutputXMLWithParentAndMixedContent(t *testing.T) {
s := `<?xml version="1.0" encoding="utf-8"?>
<class_list>
<student xml:space="preserve">
<name>Robert</name>
A+
B-
</student>
</class_list>`
doc, _ := Parse(strings.NewReader(s))
t.Log(doc.OutputXML(true))
n := FindOne(doc, "/class_list/student")
expected := "<name> Robert </name>\n\t\t\tA+\n\t\t\tB-\n\t\t"
if g := doc.OutputXML(true); strings.Index(g, expected) == -1 {
t.Errorf(`expected "%s", obtained "%s"`, expected, g)
}
}
|
…t's parent node has declare a `xml:space="preserve"`.
Please using |
the private function has a preserveSpaces option but this is not exposed in the private method,
I feel like this is a basic feature which would be universally required, can we expose this parameter to the Public function?
outputXML(buf *bytes.Buffer, n *Node, preserveSpaces bool) {
our application turns xml into html and therefore spaces needs to be preserved, as a temp workaround we've hardcoded this value to true, however it seems like a more sustainable approach if this were configurable somehow or whether it could be an extra parameter
The text was updated successfully, but these errors were encountered: