[GCC-XML]ID attribute
Jason Stanek
jstanek at iastate.edu
Wed Mar 17 03:42:28 EST 2004
Greetings again,
After conferring with various colleagues, I have come to this
conclusion. Many XML parsers assume that if an id attribute is specified,
it should be searchable with the getElementById. Some do not (Java DOM for
instance).
My good friend Yogy Namara was kind enough to devote his time explaining a
bit about XML to me. It seems that to specify an attribute as searchable
by getElementById, the ID attribute-type must be specified in the DTD. I
could not find a DTD in the XML document generated by GCC-XML, but when I
added one - all of my problems went away.
Currently, the beginning of the generated XML document looks like this:
<?xml version="1.0"?>
<GCC_XML>
If I change it to the following, I can use getElementById to search for any
Element by its id attribute:
<?xml version="1.0"?>
<!DOCTYPE GCC_XML [
<!ATTLIST Namespace id ID #REQUIRED>
<!ATTLIST Variable id ID #REQUIRED>
<!ATTLIST Field id ID #REQUIRED>
<!ATTLIST Method id ID #REQUIRED>
<!ATTLIST ReferenceType id ID #REQUIRED>
<!ATTLIST Class id ID #REQUIRED>
<!ATTLIST Struct id ID #REQUIRED>
<!ATTLIST FundamentalType id ID #REQUIRED>
<!ATTLIST PointerType id ID #REQUIRED>
<!ATTLIST ArrayType id ID #REQUIRED>
<!ATTLIST Typedef id ID #REQUIRED>
<!ATTLIST CvQualifiedType id ID #REQUIRED>
<!ATTLIST Constructor id ID #REQUIRED>
<!ATTLIST Destructor id ID #REQUIRED>
<!ATTLIST OperatorFunction id ID #REQUIRED>
<!ATTLIST OperatorMethod id ID #REQUIRED>
<!ATTLIST Enumeration id ID #REQUIRED>
<!ATTLIST Union id ID #REQUIRED>
<!ATTLIST File id ID #REQUIRED>
]>
<GCC_XML>
I dont know if these are all of the types of elements. If there are others
with a searchable id, they should be added. How difficult would it be to
make these changes to the source? Is this something that could warrant a
re-release? It sure would help me out a lot.
Thanks.
-Jason
At 01:55 AM 03/17/2004, mdupont wrote:
>Jason Stanek wrote:
>
>>Greetings,
>>
>>I'm new to GCCXML and to XML in general. I've been working on some DOM
>>Java code to read in the XML data and then perform some lookups and the
>>like. I'm trying to use the Document.getElementById function of DOM to
>>lookup various classes, methods, etc. But unfortunately, it always
>>returns null. In the javadoc it mentions that elementID must be set for
>>this to work. It also says the existence of an id attribute does not
>>mean I can look the element up with getElementById.
>According to the xml spec, the xmlid must be unique in the document, and a
>alphanumberic name.
>It also has to be set.
>
> >I'm unsure if I am supposed to programmatically set elementID or if this
> is something that should be specified in the >XML file. Is anyone
> familiar with this problem or have any suggestions?
>
>Please provide a snippet of the xml that you are looking to find, Is the
>id not set?
>
>mike
More information about the gccxml
mailing list