@@ -240,6 +240,7 @@ public void convert(org.jsoup.nodes.Document in, Document out) {
240240 */
241241public void convert (org .jsoup .nodes .Element in ,Document out ) {
242242W3CBuilder builder =new W3CBuilder (out );
243+ builder .namespaceAware =namespaceAware ;
243244org .jsoup .nodes .Document inDoc =in .ownerDocument ();
244245if (inDoc !=null ) {
245246if (!StringUtil .isBlank (inDoc .location ())) {
@@ -333,11 +334,12 @@ public String asString(Document doc) {
333334/**
334335 * Implements the conversion by walking the input.
335336 */
336- protected class W3CBuilder implements NodeVisitor {
337+ protected static class W3CBuilder implements NodeVisitor {
337338private static final String xmlnsKey ="xmlns" ;
338339private static final String xmlnsPrefix ="xmlns:" ;
339340
340341private final Document doc ;
342+ private boolean namespaceAware =true ;
341343private final Stack <HashMap <String ,String >>namespacesStack =new Stack <>();// stack of namespaces, prefix => urn
342344private Node dest ;
343345private Syntax syntax =Syntax .xml ;// the syntax (to coerce attributes to). From the input doc if available.