[GCC-XML]GCC-XML DTD

Paul Ross cadocs at paulross.demon.co.uk
Sun Jul 13 18:00:44 EDT 2003


I posted an early stab at a GCC_XML DTD yesterday but it contained a 
number of errors. Here is a better version that I have validated 
against a number of representative GCC_XML files and they all seem OK.

One issue I didn't realise was that some type and return attributes 
can't be relied upon to have an IDREF because of the 'c' 'v' and 'r' 
qualifier that is appended to the ID. I have changed these attributes 
to CDATA where the validation was reporting errors in the test data 
(and commented in the DTD accordingly). This change might have to be 
done in other parts of the DTD as well.

I guess the other way would to change the GCC_XML schema so that a 
type can always be an IDREF so instead of:

<ReferenceType id="_234" type="_456c"/>

To:

<ReferenceType id="_234" type="_456" const="1"/>

This would mean changing xml_print_type_attribute(), 
xml_print_returns_attribute() and xml_print_throw_attribute() in 
xml.c to:

   if (CP_TYPE_CONST_P (t)) { fprintf (xdi->file, " const=\"1\""); }
   if (CP_TYPE_VOLATILE_P (t)) { fprintf (xdi->file, " volatile=\"1\""); }
   if (CP_TYPE_RESTRICT_P (t)) { fprintf (xdi->file, " restrict=\"1\""); }

I am not sure that this offers any particular advantage other than 
stricter validation.

Another suggestion might be to include the GCC_XML version as an 
attribute at the root something like:

<GCC_XML version="0.4.2">

Which might be an advantage if working with files (such as legacy 
files) that come from mixed versions of GCC_XML.

Anyway here is version 0.2 of the DTD.

Regards,

Paul.

<!-- GCC_XML 0.4.2 DTD  Version 0.2  -->
<!-- Written by Paul Ross 2003-07-13 -->
<!ATTLIST Argument default CDATA #IMPLIED>
<!ATTLIST Argument name CDATA #IMPLIED>
<!-- type can not be an IDREF as it might be "_4c" etc. which will be 
an invalid id -->
<!ATTLIST Argument type CDATA #REQUIRED>

<!ATTLIST ArrayType id ID #REQUIRED>
<!ATTLIST ArrayType max CDATA #REQUIRED>
<!ATTLIST ArrayType min CDATA #FIXED "0">
<!ATTLIST ArrayType type IDREF #REQUIRED>

<!ATTLIST Class abstract (0 | 1) "0">
<!ATTLIST Class bases CDATA #IMPLIED>
<!ATTLIST Class context IDREF #REQUIRED>
<!ATTLIST Class id ID #REQUIRED>
<!ATTLIST Class incomplete (0 | 1) "0">
<!ATTLIST Class location CDATA #REQUIRED>
<!ATTLIST Class members CDATA #IMPLIED>
<!ATTLIST Class name CDATA #REQUIRED>

<!ATTLIST Constructor access (public | private | protected) "public">
<!ATTLIST Constructor context CDATA #REQUIRED>
<!ATTLIST Constructor extern (0 | 1) "0">
<!ATTLIST Constructor id ID #REQUIRED>
<!ATTLIST Constructor location CDATA #REQUIRED>
<!ATTLIST Constructor name CDATA #REQUIRED>

<!ATTLIST Converter const (0 | 1) "0">
<!ATTLIST Converter context IDREF #REQUIRED>
<!ATTLIST Converter extern (0 | 1) "0">
<!ATTLIST Converter id ID #REQUIRED>
<!ATTLIST Converter location CDATA #REQUIRED>
<!ATTLIST Converter name CDATA #REQUIRED>
<!ATTLIST Converter returns IDREF #REQUIRED>

<!ATTLIST Destructor access (public | private | protected) "public">
<!ATTLIST Destructor context IDREF #REQUIRED>
<!ATTLIST Destructor extern (0 | 1) "0">
<!ATTLIST Destructor id ID #REQUIRED>
<!ATTLIST Destructor location CDATA #REQUIRED>
<!ATTLIST Destructor name CDATA #REQUIRED>
<!ATTLIST Destructor virtual (0 | 1) "0">

<!ATTLIST EnumValue init CDATA #REQUIRED>
<!ATTLIST EnumValue name CDATA #REQUIRED>

<!ATTLIST Enumeration access (public | private | protected) "public">
<!ATTLIST Enumeration context CDATA #REQUIRED>
<!ATTLIST Enumeration id ID #REQUIRED>
<!ATTLIST Enumeration location CDATA #REQUIRED>
<!ATTLIST Enumeration name CDATA #REQUIRED>

<!ATTLIST Field access (public | private | protected) "public">
<!ATTLIST Field context IDREF #REQUIRED>
<!ATTLIST Field id ID #REQUIRED>
<!ATTLIST Field location CDATA #REQUIRED>
<!ATTLIST Field name CDATA #REQUIRED>
<!-- type can not be an IDREF as it might be "_440v" etc. which will 
be an invalid id -->
<!ATTLIST Field type CDATA #REQUIRED>

<!ATTLIST File id ID #REQUIRED>
<!ATTLIST File name CDATA #REQUIRED>

<!ATTLIST Function context IDREF #REQUIRED>
<!ATTLIST Function extern (0 | 1) "0">
<!ATTLIST Function id ID #REQUIRED>
<!ATTLIST Function location CDATA #REQUIRED>
<!ATTLIST Function name CDATA #REQUIRED>
<!-- type can not be an IDREF as it might be "_440c" etc. which will 
be an invalid id -->
<!ATTLIST Function returns CDATA #REQUIRED>

<!ATTLIST FunctionType id ID #REQUIRED>
<!ATTLIST FunctionType returns IDREF #REQUIRED>

<!ATTLIST FundamentalType id ID #REQUIRED>
<!ATTLIST FundamentalType name CDATA #REQUIRED>

<!ATTLIST Method access (public | private | protected) "public">
<!ATTLIST Method const (0 | 1) "0">
<!ATTLIST Method context IDREF #REQUIRED>
<!ATTLIST Method extern (0 | 1) "0">
<!ATTLIST Method id ID #REQUIRED>
<!ATTLIST Method location CDATA #REQUIRED>
<!ATTLIST Method name CDATA #REQUIRED>
<!ATTLIST Method pure_virtual (0 | 1) "0">
<!-- type can not be an IDREF as it might be "_440c" etc. which will 
be an invalid id -->
<!ATTLIST Method returns CDATA #REQUIRED>
<!ATTLIST Method static (0 | 1) "0">
<!ATTLIST Method virtual (0 | 1) "0">

<!ATTLIST MethodType basetype IDREF #REQUIRED>
<!ATTLIST MethodType id ID #REQUIRED>
<!-- type can not be an IDREF as it might be "_440c" etc. which will 
be an invalid id -->
<!ATTLIST MethodType returns CDATA #REQUIRED>

<!ATTLIST Namespace context IDREF #IMPLIED>
<!ATTLIST Namespace id ID #REQUIRED>
<!ATTLIST Namespace members CDATA #IMPLIED>
<!ATTLIST Namespace name CDATA #REQUIRED>

<!ATTLIST OperatorFunction context IDREF #REQUIRED>
<!ATTLIST OperatorFunction extern (0 | 1) "0">
<!ATTLIST OperatorFunction id ID #REQUIRED>
<!ATTLIST OperatorFunction location CDATA #REQUIRED>
<!ATTLIST OperatorFunction name CDATA #REQUIRED>
<!ATTLIST OperatorFunction returns IDREF #REQUIRED>

<!ATTLIST OperatorMethod access (public | private | protected) "public">
<!ATTLIST OperatorMethod const (0 | 1) "0">
<!ATTLIST OperatorMethod context IDREF #REQUIRED>
<!ATTLIST OperatorMethod extern (0 | 1) "0">
<!ATTLIST OperatorMethod id ID #REQUIRED>
<!ATTLIST OperatorMethod location CDATA #REQUIRED>
<!ATTLIST OperatorMethod name CDATA #REQUIRED>
<!ATTLIST OperatorMethod pure_virtual (0 | 1) "0">
<!ATTLIST OperatorMethod returns IDREF #REQUIRED>
<!ATTLIST OperatorMethod virtual (0 | 1) "0">

<!ATTLIST PointerType id ID #REQUIRED>
<!-- type can not be an IDREF as it might be "_4c" etc. which will be 
an invalid id -->
<!ATTLIST PointerType type CDATA #REQUIRED>

<!ATTLIST ReferenceType id ID #REQUIRED>
<!-- type can not be an IDREF as it might be "_4c" etc. which will be 
an invalid id -->
<!ATTLIST ReferenceType type CDATA #REQUIRED>

<!ATTLIST Struct access (public | private | protected) "public">
<!ATTLIST Struct bases CDATA #IMPLIED>
<!ATTLIST Struct context IDREF #REQUIRED>
<!ATTLIST Struct id ID #REQUIRED>
<!ATTLIST Struct incomplete (0 | 1) "0">
<!ATTLIST Struct location CDATA #REQUIRED>
<!ATTLIST Struct members CDATA #IMPLIED>
<!ATTLIST Struct name CDATA #REQUIRED>

<!ATTLIST Typedef context IDREF #REQUIRED>
<!ATTLIST Typedef id ID #REQUIRED>
<!ATTLIST Typedef location CDATA #REQUIRED>
<!ATTLIST Typedef name CDATA #REQUIRED>
<!-- type can not be an IDREF as it might be "_2244c" etc. which will 
be an invalid id -->
<!ATTLIST Typedef type CDATA #REQUIRED>

<!ATTLIST Unimplemented id ID #REQUIRED>
<!ATTLIST Unimplemented node CDATA #REQUIRED>
<!ATTLIST Unimplemented tree_code (187 | 190 | 193) #REQUIRED>
<!ATTLIST Unimplemented tree_code_name (template_type_parm | 
typename_type | using_decl) #REQUIRED>

<!ATTLIST Union bases CDATA #REQUIRED>
<!ATTLIST Union context IDREF #REQUIRED>
<!ATTLIST Union id ID #REQUIRED>
<!ATTLIST Union location CDATA #REQUIRED>
<!ATTLIST Union members CDATA #REQUIRED>
<!ATTLIST Union name CDATA #REQUIRED>

<!ATTLIST Variable access (public | private | protected) "public">
<!ATTLIST Variable context IDREF #REQUIRED>
<!ATTLIST Variable extern (0 | 1) "0">
<!ATTLIST Variable id ID #REQUIRED>
<!ATTLIST Variable init CDATA #IMPLIED>
<!ATTLIST Variable location CDATA #REQUIRED>
<!ATTLIST Variable name CDATA #REQUIRED>
<!-- type can not be an IDREF as it might be "_4c" etc. which will be 
an invalid id -->
<!ATTLIST Variable type CDATA #REQUIRED>

<!ELEMENT Argument EMPTY>
<!ELEMENT Ellipsis EMPTY>
<!ELEMENT ArrayType EMPTY>
<!ELEMENT Class EMPTY>
<!ELEMENT Constructor (Argument | Ellipsis)*>
<!ELEMENT Converter EMPTY>
<!ELEMENT Destructor EMPTY>
<!ELEMENT EnumValue EMPTY>
<!ELEMENT Enumeration (EnumValue)+>
<!ELEMENT Field EMPTY>
<!ELEMENT File EMPTY>
<!ELEMENT Function (Argument | Ellipsis)*>
<!ELEMENT FunctionType (Argument | Ellipsis)*>
<!ELEMENT FundamentalType EMPTY>
<!ELEMENT Method (Argument | Ellipsis)*>
<!ELEMENT MethodType (Argument | Ellipsis)*>
<!ELEMENT Namespace EMPTY>
<!ELEMENT OperatorFunction (Argument | Ellipsis)*>
<!ELEMENT OperatorMethod (Argument | Ellipsis)*>
<!ELEMENT PointerType EMPTY>
<!ELEMENT ReferenceType EMPTY>
<!ELEMENT Struct EMPTY>
<!ELEMENT Typedef EMPTY>
<!ELEMENT Unimplemented EMPTY>
<!ELEMENT Union EMPTY>
<!ELEMENT Variable EMPTY>
<!ELEMENT GCC_XML (ArrayType | Class | Constructor | Converter | 
Destructor | Enumeration | Field | File | Function | FunctionType | 
FundamentalType | Method | MethodType | Namespace | OperatorFunction 
| OperatorMethod | PointerType | ReferenceType | Struct | Typedef | 
Unimplemented | Union | Variable)+>




More information about the gccxml mailing list