aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/gnu/xml/dom/DomDocument.java
diff options
context:
space:
mode:
authorMark Wielaard <mark@gcc.gnu.org>2005-11-15 23:20:01 +0000
committerMark Wielaard <mark@gcc.gnu.org>2005-11-15 23:20:01 +0000
commit8f523f3a1047919d3563daf1ef47ba87336ebe89 (patch)
treea5eb7cf42a51869cc8aa1fad7ad6a90cca47fdd8 /libjava/classpath/gnu/xml/dom/DomDocument.java
parent02e549bfaaec38f68307e7f34e46ea57ea1809af (diff)
downloadgcc-8f523f3a1047919d3563daf1ef47ba87336ebe89.zip
gcc-8f523f3a1047919d3563daf1ef47ba87336ebe89.tar.gz
gcc-8f523f3a1047919d3563daf1ef47ba87336ebe89.tar.bz2
Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated. * Makefile.in: Likewise. * scripts/makemake.tcl: Use glob -nocomplain. From-SVN: r107049
Diffstat (limited to 'libjava/classpath/gnu/xml/dom/DomDocument.java')
-rw-r--r--libjava/classpath/gnu/xml/dom/DomDocument.java50
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 dc476b5..29b8dc7 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?