diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | gnu/xml/dom/DomDocument.java | 23 | ||||
-rw-r--r-- | gnu/xml/dom/ls/SAXEventSink.java | 2 | ||||
-rw-r--r-- | gnu/xml/stream/XMLParser.java | 22 |
4 files changed, 50 insertions, 5 deletions
@@ -1,3 +1,11 @@ +2007-05-04 Chris Burdess <dog@gnu.org> + + Fixes PR #31814 + * gnu/xml/dom/DomDocument.java, + gnu/xml/dom/ls/SAXEventSink.java: Don't default attribute when mode is + #IMPLIED and value is not specified. + * gnu/xml/stream/XMLParser.java: Add debugging info. + 2007-05-03 Keith Seitz <keiths@redhat.com> * gnu/classpath/jdwp/Jdwp.java (notify): Rewrite to call diff --git a/gnu/xml/dom/DomDocument.java b/gnu/xml/dom/DomDocument.java index 5d06a428b..bcc729335 100644 --- a/gnu/xml/dom/DomDocument.java +++ b/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 = ""; diff --git a/gnu/xml/dom/ls/SAXEventSink.java b/gnu/xml/dom/ls/SAXEventSink.java index 364c576d1..0a165aafb 100644 --- a/gnu/xml/dom/ls/SAXEventSink.java +++ b/gnu/xml/dom/ls/SAXEventSink.java @@ -138,6 +138,7 @@ public class SAXEventSink doc = new DomDocument(); doc.setStrictErrorChecking(false); doc.setBuilding(true); + doc.setDefaultAttributes(false); ctx = doc; final String FEATURES = "http://xml.org/sax/features/"; @@ -185,6 +186,7 @@ public class SAXEventSink { doc.setStrictErrorChecking(true); doc.setBuilding(false); + doc.setDefaultAttributes(true); DomDoctype doctype = (DomDoctype) doc.getDoctype(); if (doctype != null) { diff --git a/gnu/xml/stream/XMLParser.java b/gnu/xml/stream/XMLParser.java index fae4afec8..c1eee946e 100644 --- a/gnu/xml/stream/XMLParser.java +++ b/gnu/xml/stream/XMLParser.java @@ -4598,6 +4598,28 @@ public class XMLParser } return false; } + + public String toString() + { + StringBuffer buf = new StringBuffer(getClass().getName()); + buf.append('['); + buf.append("name="); + buf.append(name); + if (value != null) + { + buf.append(",value="); + buf.append(value); + } + if (type != null) + { + buf.append(",type="); + buf.append(type); + } + if (specified) + buf.append(",specified"); + buf.append(']'); + return buf.toString(); + } } |