Skip to content
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

Sorting nodes with mixed content can break the content #11

Open
DanielRose opened this issue Mar 31, 2021 · 0 comments
Open

Sorting nodes with mixed content can break the content #11

DanielRose opened this issue Mar 31, 2021 · 0 comments

Comments

@DanielRose
Copy link

XML elements can have several different kinds of child nodes. According to the documentation, that includes Element, Text, Comment, ProcessingInstruction, CDATA, and EntityReference. Always sorting the child nodes can break the content, since the order can be important. For example:

<text>Click on <url target="/home" /> to return to the home page.</text>

Simply sorting this results in

<text>Click on  to return to the home page.<url target="/home" /></text>

which is most probably not wanted.

Thus, only when the child nodes are all elements themselves should sorting occur.

However, this is very strict, so comments should be allowed as well. Since there is no sure way to tell where the comments should be sorted (they may belong to the element above, below, at the start or end of all children or only of the same type, ...), the easiest way is to sort them as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant