Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[che-dev] XML: line endings normalization problem

Hi.
I met the problem parsing XML with XMLTree
on Windows OS. The problem is about how to parse line separators(\r\n)?

XMLTree provides abilities to modify and search information in xml document without affecting an
existing formatting, comments etc.
In the other hand XML spec says that all combinations of \r\n, or single \r should be
 replaced with \n while parsing XML document.
As XMLTree is built on top of standard java parser it follows spec as well.

So actually the problem:
when we have content which contains combination of \r\n or \r it will be replaced with \n
but source content still contains \r\n and it is impossible to detect which is the right
positions of xml document elements, therefore it is impossible to modify content properly.

The solution which i have found is to replace all \r\n and then \r with single
\n before parsing the actual content, then if it is necessary to write modified content
all inclusions of \n will be replaced with system line separator. This solution is pretty close
to git client solution, which replaces \r\n with \n on Windows OS as well.

Do you guys know any other solution for this "normalization problem"?


Back to the top