[GCC-XML]New cv-qualified type referencing scheme
Tony Cook
tony at bci.gb.com
Thu Oct 16 19:19:42 EDT 2003
Brad,
Could the same be done with the location attribute (e.g.
location="f0:305"). That too violates the ID/IDREF spec when linking to
<File id="f0" ... /> though this might cause an explosion of
intermediate tags if you use your approach!
<QualifiedLocation id="f0:305" file="f0" line="305" />
Lots of <QualifiedLocation ... /> tags will appear. Would an alternative
solution be to add two additional attributes to all elements supporting
the location attribute. E.g.
<...... location="f0:305" file="f0" line="305"/>
So here 'file' is now the nominated IDREF. In my case this addition
would not affect my XSLT stylesheets, though it might affect other
parsers that barf on unexpected attributes ... thoughts?
Here's an XSLT tip for the current situation with cv qualified types. I
use stuff like:
<xsl:variable name="type" select="translate(@type,'cv','')" />
to strip any 'c' or 'v' characters from the not so IDREF'ed 'type'
attribute and then something like:
<xsl:apply-templates select="/GCC_XML/*[@id=$type]" ... />
to select the element with the intended ID. So if you are not planning
XSLT's id() or key() functions for efficiency its not too difficult to
handle the current situation - though potentially slowly.
Cheers, Tony Cook
++++++++++++++++++++++++
Hello GCC-XML Users,
The current GCC-XML dump uses the following technique to reference a
top-level cv-qualified type:
<PointerType id="_1" type="_5"/> <!-- "int*" -->
<PointerType id="_2" type="_5c"/> <!-- "int const*" -->
<PointerType id="_3" type="_5v"/> <!-- "int volatile*" -->
<PointerType id="_4" type="_5cv"/> <!-- "int const volatile*" -->
<FundamentalType id="_5" name="int"/>
In this example, the type attribute of PointerType contains extra
characters to denote top-level cv-qualifiers in the type to which it
points. While this is easy to parse when using a language like C++ or
python, it violates the ID/IDREF specification for XML:
http://www . w3 . org/TR/REC-xml#id
http://www . w3 . org/TR/REC-xml#idref
I'm planning to change the referencing scheme to work like this:
<PointerType id="_1" type="_5"/> <!-- "int*" -->
<PointerType id="_2" type="_5c"/> <!-- "int const*" -->
<PointerType id="_3" type="_5v"/> <!-- "int volatile*" -->
<PointerType id="_4" type="_5cv"/> <!-- "int const volatile*" -->
<FundamentalType id="_5" name="int"/>
<CvQualifiedType id="_5c" type="_5" const="1"/>
<CvQualifiedType id="_5v" type="_5" volatile="1"/>
<CvQualifiedType id="_5cv" type="_5" const="1" volatile="1"/>
In this approach, the three CvQualifiedType elements correspond to the
FundamentalType element with added cv-qualification. They are
referenced
with standard IDREF attributes by other elements.
Backward-compatibility
is maintained by the special form of the ID attributes of
CvQualifiedType
elements.
I'm going to commit the changes for this sometime next week unless
anyone
points out a flaw in the design. Please be prepared to modify your
parsers to handle the new CvQualifiedType element. The elements can be
safely ignored by parsers that already know how to handle the old
referencing scheme. New parsers or XSL transformations will be able to
take advantage of the full ID/IDREF support in XML.
-Brad
More information about the gccxml
mailing list