diff options
| author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-15 23:20:01 +0000 |
|---|---|---|
| committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-15 23:20:01 +0000 |
| commit | 3b3101d8b5ae4f08a16c0b7111da6cad41bbd282 (patch) | |
| tree | a5eb7cf42a51869cc8aa1fad7ad6a90cca47fdd8 /libjava/classpath/gnu/xml/dom | |
| parent | 7e55c49d7d91ef9f09e93c1100119b1ab3652446 (diff) | |
| download | ppe42-gcc-3b3101d8b5ae4f08a16c0b7111da6cad41bbd282.tar.gz ppe42-gcc-3b3101d8b5ae4f08a16c0b7111da6cad41bbd282.zip | |
Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated.
* Makefile.in: Likewise.
* scripts/makemake.tcl: Use glob -nocomplain.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107049 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/gnu/xml/dom')
| -rw-r--r-- | libjava/classpath/gnu/xml/dom/DomDocument.java | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/libjava/classpath/gnu/xml/dom/DomDocument.java b/libjava/classpath/gnu/xml/dom/DomDocument.java index dc476b582ac..29b8dc72e53 100644 --- a/libjava/classpath/gnu/xml/dom/DomDocument.java +++ b/libjava/classpath/gnu/xml/dom/DomDocument.java @@ -210,13 +210,15 @@ public class DomDocument */ public Element getElementById(String id) { - DomDoctype doctype = (DomDoctype) getDoctype(); - - if (doctype == null || !doctype.hasIds() - || id == null || id.length() == 0) + if (id == null || id.length() == 0) { return null; } + DomDoctype doctype = (DomDoctype) getDoctype(); + if (doctype != null && !doctype.hasIds()) + { + doctype = null; + } // yes, this is linear in size of document. // it'd be easy enough to maintain a hashtable. @@ -233,25 +235,39 @@ public class DomDocument if (current.getNodeType() == ELEMENT_NODE) { DomElement element = (DomElement) current; - DTDElementTypeInfo info = - doctype.getElementTypeInfo(current.getNodeName()); - if (info != null && - id.equals(element.getAttribute(info.idAttrName))) - { - return element; - } - else if (element.userIdAttrs != null) + if (doctype != null) { - for (Iterator i = element.userIdAttrs.iterator(); - i.hasNext(); ) + DTDElementTypeInfo info = + doctype.getElementTypeInfo(current.getNodeName()); + if (info != null && + id.equals(element.getAttribute(info.idAttrName))) { - Node idAttr = (Node) i.next(); - if (id.equals(idAttr.getNodeValue())) + return element; + } + else if (element.userIdAttrs != null) + { + for (Iterator i = element.userIdAttrs.iterator(); + i.hasNext(); ) { - return element; + Node idAttr = (Node) i.next(); + if (id.equals(idAttr.getNodeValue())) + { + return element; + } } } } + // xml:id + String xmlId = element.getAttribute("xml:id"); + if (xmlId == null) + { + xmlId = element.getAttributeNS(XMLConstants.XML_NS_URI, + "id"); + } + if (id.equals(xmlId)) + { + return element; + } } // descend? |

