Skip to content

Commit

Permalink
Make Dom4J parse all adjacent text in content as one text.
Browse files Browse the repository at this point in the history
  • Loading branch information
Björn Ekryd committed May 24, 2022
1 parent 1af479a commit 64311fe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 1 addition & 0 deletions sorter/src/main/java/sortpom/XmlProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public XmlProcessor(WrapperFactory factory) {
public void setOriginalXml(final InputStream originalXml) throws DocumentException, SAXException {
SAXReader parser = new SAXReader();
parser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
parser.setMergeAdjacentText(true);
originalDocument = parser.read(originalXml);
}

Expand Down
3 changes: 1 addition & 2 deletions sorter/src/test/java/sortpom/sort/LineSeparatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ void formattingXmlWithLineEndingsShouldResultInOneLineBreakAtEnd(String lineSepa
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + lineSeparator + "<Gurka />" + lineSeparator,
actual);
}

@Test
void linesInContentShouldBePreserved() throws Exception {
SortPomImplUtil.create()
.lineSeparator("\r\n")
.testFiles("/MultilineContent_input.xml", "/MultilineContent_expected.xml");
}

}

0 comments on commit 64311fe

Please sign in to comment.