diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-06-25 21:06:17 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2008-06-25 21:06:17 +0000 |
commit | 8e5f3bc601d1b4b1751dbae7eddb53a2bf300b0d (patch) | |
tree | c7c4b8a8597b7d7ef70bc5f032b6dbc03dd903fc /gnu/xml | |
parent | 87b860d9a0fec9c1ff5777fb3b55433607725617 (diff) | |
download | classpath-8e5f3bc601d1b4b1751dbae7eddb53a2bf300b0d.tar.gz |
2008-06-25 Andrew John Hughes <gnu_andrew@member.fsf.org>
PR classpath/36221:
* gnu/xml/dom/DomAttr.java:
(DomAttr(DomDocument,String,String,String,String)):
New constructor.
* gnu/xml/dom/DomDocument.java:
(createElement(String)): Use new constructor rather than
setting variable directly.
(createAttribute(String)): Likewise.
* gnu/xml/dom/DomElement.java:
(DomElement(DomDocument,String,String,String,String)):
New constructor.
* gnu/xml/dom/DomNsNode.java:
(localName): Make private.
(DomNsNode(short,DomDocument,String,String,String,String)):
New constructor.
* gnu/xml/dom/ls/DomLSParser.java:
(doParse(LSInput)): Set namespace awareness using a method,
not directly.
* gnu/xml/dom/ls/SAXEventSink.java:
(namespaceAware): Make private.
(setNamespaceAware(boolean)): New method.
* gnu/xml/transform/XSLURIResolver.java:
(parse(InputSource,XMLReader)): Parse with namespace awareness on.
Diffstat (limited to 'gnu/xml')
-rw-r--r-- | gnu/xml/dom/DomAttr.java | 32 | ||||
-rw-r--r-- | gnu/xml/dom/DomDocument.java | 8 | ||||
-rw-r--r-- | gnu/xml/dom/DomElement.java | 26 | ||||
-rw-r--r-- | gnu/xml/dom/DomNsNode.java | 29 | ||||
-rw-r--r-- | gnu/xml/dom/ls/DomLSParser.java | 2 | ||||
-rw-r--r-- | gnu/xml/dom/ls/SAXEventSink.java | 7 | ||||
-rw-r--r-- | gnu/xml/transform/XSLURIResolver.java | 1 |
7 files changed, 97 insertions, 8 deletions
diff --git a/gnu/xml/dom/DomAttr.java b/gnu/xml/dom/DomAttr.java index 8ca8a7d79..6a8da8371 100644 --- a/gnu/xml/dom/DomAttr.java +++ b/gnu/xml/dom/DomAttr.java @@ -108,7 +108,37 @@ public class DomAttr // and character data change events and when they happen, // report self-mutation } - + + /** + * Constructs an Attr node associated with the specified document. + * The "specified" flag is initialized to true, since this DOM has + * no current "back door" mechanisms to manage default values so + * that every value must effectively be "specified". + * + * <p>This constructor should only be invoked by a Document as part of + * its createAttribute functionality, or through a subclass which is + * similarly used in a "Sub-DOM" style layer. + * <p> + * With this constructor, the prefix and local part are given explicitly + * rather than being computed. This allows them to be explicitly set to + * {@code null} as required by {@link Document#createAttribute(String)}. + * </p> + * + * @param owner The document with which this node is associated + * @param namespaceURI Combined with the local part of the name, + * this is used to uniquely identify a type of attribute + * @param name Name of this attribute, which may include a prefix + * @param prefix the namespace prefix of the name. May be {@code null}. + * @param localName the local part of the name. May be {@code null}. + */ + protected DomAttr(DomDocument owner, String namespaceURI, String name, + String prefix, String localName) + { + super(ATTRIBUTE_NODE, owner, namespaceURI, name, prefix, localName); + specified = true; + length = 1; + } + /** * <b>DOM L1</b> * Returns the attribute name (same as getNodeName) diff --git a/gnu/xml/dom/DomDocument.java b/gnu/xml/dom/DomDocument.java index bcc729335..b32c6b82d 100644 --- a/gnu/xml/dom/DomDocument.java +++ b/gnu/xml/dom/DomDocument.java @@ -597,6 +597,8 @@ public class DomDocument /** * <b>DOM L1</b> * Returns a newly created element with the specified name. + * The node name of the created element will be equal to {@code name}. + * The namespace, prefix and local name will all be {@code null}. */ public Element createElement(String name) { @@ -612,8 +614,7 @@ public class DomDocument } else { - DomElement domElement = new DomElement(this, null, name); - domElement.localName = null; + DomElement domElement = new DomElement(this, null, name, null, null); element = domElement; } if (defaultAttributes) @@ -813,8 +814,7 @@ public class DomDocument } else { - DomAttr ret = new DomAttr(this, null, name); - ret.localName = null; + DomAttr ret = new DomAttr(this, null, name, null, null); return ret; } } diff --git a/gnu/xml/dom/DomElement.java b/gnu/xml/dom/DomElement.java index 9fd81e970..462cb9178 100644 --- a/gnu/xml/dom/DomElement.java +++ b/gnu/xml/dom/DomElement.java @@ -90,6 +90,32 @@ public class DomElement } /** + * <p> + * Constructs an Element node associated with the specified document. + * This constructor should only be invoked by a Document as part + * of its createElement functionality, or through a subclass which is + * similarly used in a "Sub-DOM" style layer. + * </p> + * <p> + * With this constructor, the prefix and local part are given explicitly + * rather than being computed. This allows them to be explicitly set to + * {@code null} as required by {@link Document#createElement(String)}. + * </p> + * + * @param owner The document with which this node is associated + * @param namespaceURI Combined with the local part of the name, + * this is used to uniquely identify a type of element + * @param name Name of this element, which may include a prefix + * @param prefix the namespace prefix of the name. May be {@code null}. + * @param localName the local part of the name. May be {@code null}. + */ + protected DomElement(DomDocument owner, String namespaceURI, String name, + String prefix, String localName) + { + super(ELEMENT_NODE, owner, namespaceURI, name, prefix, localName); + } + + /** * <b>DOM L1</b> * Returns the element's attributes */ diff --git a/gnu/xml/dom/DomNsNode.java b/gnu/xml/dom/DomNsNode.java index b27514ecb..d3361515b 100644 --- a/gnu/xml/dom/DomNsNode.java +++ b/gnu/xml/dom/DomNsNode.java @@ -54,7 +54,7 @@ public abstract class DomNsNode private String name; private String namespace; private String prefix; - String localName; + private String localName; /** * Constructs a node associated with the specified document, and @@ -76,6 +76,33 @@ public abstract class DomNsNode } /** + * Constructs a node associated with the specified document, and + * with the specified namespace information. The prefix and local part + * are given explicitly rather than being computed. This allows them + * to be explicitly set to {@code null} as required by + * {@link Document#createElement(String)}. + * + * @param owner The document with which this entity is associated + * @param namespaceURI Combined with the local part of the name, + * this identifies a type of element or attribute; may be null. + * If this is the empty string, it is reassigned as null so that + * applications only need to test that case. + * @param name Name of this node, which may include a prefix + * @param prefix the namespace prefix of the name. May be {@code null}. + * @param localName the local part of the name. May be {@code null}. + */ + // package private + DomNsNode(short nodeType, DomDocument owner, String namespaceURI, String name, + String prefix, String localName) + { + super(nodeType, owner); + this.name = name.intern(); + this.prefix = prefix == null ? null : prefix.intern(); + this.localName = localName == null ? null : localName.intern(); + setNamespaceURI(namespaceURI); + } + + /** * <b>DOM L1</b> * Returns the node's name, including any namespace prefix. */ diff --git a/gnu/xml/dom/ls/DomLSParser.java b/gnu/xml/dom/ls/DomLSParser.java index 88f9bae23..f4f555e8c 100644 --- a/gnu/xml/dom/ls/DomLSParser.java +++ b/gnu/xml/dom/ls/DomLSParser.java @@ -253,7 +253,7 @@ public class DomLSParser eventSink = (filter == null) ? new SAXEventSink() : new FilteredSAXEventSink(filter); // configure sink - eventSink.namespaceAware = namespaceAware; + eventSink.setNamespaceAware(namespaceAware); eventSink.ignoreWhitespace = ignoreWhitespace; eventSink.expandEntityReferences = expandEntityReferences; eventSink.ignoreComments = ignoreComments; diff --git a/gnu/xml/dom/ls/SAXEventSink.java b/gnu/xml/dom/ls/SAXEventSink.java index 0a165aafb..1f8de046d 100644 --- a/gnu/xml/dom/ls/SAXEventSink.java +++ b/gnu/xml/dom/ls/SAXEventSink.java @@ -89,7 +89,7 @@ public class SAXEventSink PREDEFINED_ENTITIES.add("apos"); } - boolean namespaceAware; + private boolean namespaceAware; boolean ignoreWhitespace; boolean expandEntityReferences; boolean ignoreComments; @@ -128,6 +128,11 @@ public class SAXEventSink this.locator = locator; } + public void setNamespaceAware(boolean namespaceAware) + { + this.namespaceAware = namespaceAware; + } + public void startDocument() throws SAXException { diff --git a/gnu/xml/transform/XSLURIResolver.java b/gnu/xml/transform/XSLURIResolver.java index fdff28d68..c1379211a 100644 --- a/gnu/xml/transform/XSLURIResolver.java +++ b/gnu/xml/transform/XSLURIResolver.java @@ -301,6 +301,7 @@ class XSLURIResolver { SAXEventSink eventSink = new SAXEventSink(); eventSink.setReader(reader); + eventSink.setNamespaceAware(true); reader.setContentHandler(eventSink); reader.setDTDHandler(eventSink); reader.setProperty("http://xml.org/sax/properties/lexical-handler", |