[GCC-XML] XSLT: getting the "object tree" from GCC-XML output

Olli Savolainen os69549 at uta.fi
Wed Jul 28 11:15:19 EDT 2004


Hi,

The files discussed are at: http://www.uta.fi/~os69549/xslt-q/

In our project, we needed to get the constants out of the source files
and into an XML file, in which the configuration values could then be
altered. Those values are then read into our application at runtime. We
didn't want to do this by hand since we would need to do it again every
time the source was altered: GCC-XML seemed like a perfect solution. I
was suprised no one seemed to have done the kind of a transformation we
needed (went through the archives of this mailing list), but I thought
the job wasn't _that_ big so I begun.

We wanted the XML file to look like the hierarchy already present in the
source files: a root class instance would be the xml root element (or
nearby), the children of which would be the member variables of the
class. If a member variable was a class in itself, its children would
then be the children of the equivalent XML element, like this:
something like <object type="classname" name"objectname"><simpleType
name="x" value="y"/><object type="classname"
name"objectname"><simpletype ... />...</object>...</object>

Having started learning XSLT a couple of weeks ago, I'm quite happy with
where I've gotten. There are two major problems I would still need to
work through, and this is where I'm asking for help:

i. Having to tokenize the members of each class and trying to get the
arrays of objects like required (see the XSLT file) seems to require
lots of recursion depth. xsltproc choked on it ["xsltApplyOneTemplate:
loop found?? try increasing xsltMaxDepth (--maxdepth)" after 45mins,
didn't try this yet], but with msxml4 it takes about 2 minutes to
process. I'm considering using some kind of an XSLT extension, but I've
no experience using those.

ii. however, looping through the array elements doesn't work with msxml
either: it seems to <xsl:apply-templates> only for the first round of
the loop.

Note: in our XML format <device> is the equivalent for a member
variable that is an instance of a class, <array> is an array and
<property> is a "simple" type.

Thank you for any help,
Olli Savolainen





More information about the gccxml mailing list