Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated.
* Makefile.in: Likewise.
* scripts/makemake.tcl: Use glob -nocomplain.
From-SVN: r107049
This commit is contained in:
@@ -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)))
|
||||
if (doctype != null)
|
||||
{
|
||||
return element;
|
||||
}
|
||||
else if (element.userIdAttrs != 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?
|
||||
|
||||
Reference in New Issue
Block a user