Skip to content

Commit

Permalink
Keep the W3CBuilder static
Browse files Browse the repository at this point in the history
Ensures API backcompat
  • Loading branch information
jhy committed Jul 3, 2022
1 parent 2b573de commit 7fb6d02
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/org/jsoup/helper/W3CDom.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ public void convert(org.jsoup.nodes.Document in, Document out) {
*/
public void convert(org.jsoup.nodes.Element in, Document out) {
W3CBuilder builder = new W3CBuilder(out);
builder.namespaceAware = namespaceAware;
org.jsoup.nodes.Document inDoc = in.ownerDocument();
if (inDoc != null) {
if (!StringUtil.isBlank(inDoc.location())) {
Expand Down Expand Up @@ -333,11 +334,12 @@ public String asString(Document doc) {
/**
* Implements the conversion by walking the input.
*/
protected class W3CBuilder implements NodeVisitor {
protected static class W3CBuilder implements NodeVisitor {
private static final String xmlnsKey = "xmlns";
private static final String xmlnsPrefix = "xmlns:";

private final Document doc;
private boolean namespaceAware = true;
private final Stack<HashMap<String, String>> namespacesStack = new Stack<>(); // stack of namespaces, prefix => urn
private Node dest;
private Syntax syntax = Syntax.xml; // the syntax (to coerce attributes to). From the input doc if available.
Expand Down

0 comments on commit 7fb6d02

Please sign in to comment.