Skip to content

Commit

Permalink
Basic fix for formatting DTD DocType to avoid breaking DTD content (see
Browse files Browse the repository at this point in the history
  • Loading branch information
angelozerr committed Dec 1, 2018
1 parent 3f1ef89 commit d4bc755
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ private void format(DOMNode node, int level, int end, XMLBuilder xml) {
xml.linefeed();
} else if (node.isDoctype()) {
DOMDocumentType documentType = (DOMDocumentType) node;
xml.startDoctype();
xml.addContentDoctype(documentType.getContent());
xml.startDoctype(documentType.getName());
xml.setDoctypeInternalSubset(documentType.getInternalSubset());
xml.endDoctype();
xml.linefeed();
} else if (node.isText()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,21 @@ public XMLBuilder addContentComment(String content) {
return this;
}

public XMLBuilder startDoctype() {
public XMLBuilder startDoctype(String name) {
xml.append("<!DOCTYPE");
if (name != null) {
xml.append(" ");
xml.append(name);
}
return this;
}

public XMLBuilder addContentDoctype(String content) {
xml.append(content);
public XMLBuilder setDoctypeInternalSubset(String internalSubset) {
if (internalSubset != null) {
xml.append(" [");
xml.append(internalSubset);
xml.append("]");
}
return this;
}

Expand Down

0 comments on commit d4bc755

Please sign in to comment.