diff options
Diffstat (limited to 'libjava/classpath/gnu/xml/dom/DomDocument.java')
-rw-r--r-- | libjava/classpath/gnu/xml/dom/DomDocument.java | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/libjava/classpath/gnu/xml/dom/DomDocument.java b/libjava/classpath/gnu/xml/dom/DomDocument.java index 5d06a428be4..bcc729335d5 100644 --- a/libjava/classpath/gnu/xml/dom/DomDocument.java +++ b/libjava/classpath/gnu/xml/dom/DomDocument.java @@ -87,6 +87,7 @@ public class DomDocument private final DOMImplementation implementation; private boolean checkingCharacters = true; boolean checkingWellformedness = true; + private boolean defaultAttributes = true; boolean building; // if true, skip mutation events in the tree @@ -155,7 +156,15 @@ public class DomDocument public void setCheckingCharacters(boolean flag) { checkingCharacters = flag; - } + } + + /** + * Sets whether to default attributes for new elements. + */ + public void setDefaultAttributes(boolean flag) + { + defaultAttributes = flag; + } /** * <b>DOM L1</b> @@ -607,7 +616,8 @@ public class DomDocument domElement.localName = null; element = domElement; } - defaultAttributes(element, name); + if (defaultAttributes) + setDefaultAttributes(element, name); return element; } @@ -652,11 +662,12 @@ public class DomDocument } Element element = new DomElement(this, namespaceURI, name); - defaultAttributes(element, name); + if (defaultAttributes) + setDefaultAttributes(element, name); return element; } - private void defaultAttributes(Element element, String name) + private void setDefaultAttributes(Element element, String name) { DomDoctype doctype = (DomDoctype) getDoctype(); if (doctype == null) @@ -671,9 +682,11 @@ public class DomDocument for (Iterator i = info.attributes(); i != null && i.hasNext(); ) { DTDAttributeTypeInfo attr = (DTDAttributeTypeInfo) i.next(); + String value = attr.value; + if ("#IMPLIED".equals(attr.mode) && value == null) + continue; DomAttr node = (DomAttr) createAttribute(attr.name); - String value = attr.value; if (value == null) { value = ""; |