OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Problem with getElementById()

[ Lists Home | Date Index | Thread Index ]

9/24/2002 11:49:01 AM, "li, gang" <li_gang@emc.com> wrote:

>I want to get an element by its unique id. I set the attribute "id" to the
>element. But when I called Document.getElementById(), it returns null. I'm
>using Apache Batik DOM implementation. Does anybody ever used it? Or how to
>use it in other packages like Xerces? I looked at Xerces API, but didn't
>find any useful information.

In HTML, the attribute "id" is defined as having the ID type (in principle by
the DTD, but essentially "by magic" as far as browsers are concerned).
Since SVG does have an ID attribute called "id" on every element, I 
dont' know why Batik's DOM doesn't work for you.  Perhaps you have to
explicitly tell it what DTD you're using? Or you're not using SVG data?  
In XML generally, one needs a DTD or schema to tell the parser to tell the 
DOM implementation that a particular attribute has the ID type (and 
the name of the attribute does NOT have to be "id"). 

The DOM Level 2 spec doesn't provide a way to set the "id-ness" of an attribute,
it has to come from the DTD/Schema at parse time. 










 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS