[xsd-users] Adding custom code to getter functions of all types.

Boris Kolpackov boris at codesynthesis.com
Fri Aug 29 04:56:53 EDT 2014


Hi Matthis,

KRAUSE Matthis (AREVA) <matthis.krause at areva.com> writes:

> I would like to be able to generate a log which contains information 
> about which values from an xml file/object model have been accessed 
> and which have not.
> 
> Would it be possible to customize the default behavior in such a way
> to allow for this information to be captured?
> 
> I already looked into generating every type from the schema file as a 
> base class which inherits from a custom class but I don't know if and
> how I would be able to customize the "getter" functions this way.

For this to work you will have to wrap every accessor generated by XSD,
which could be a lot of work/code for any non-trivial schema.

The other option that I thought of is to instrument the runtime (libxsd),
specifically, the 'one', 'optional', and 'sequence' containers that are
used by the generated code to actually store the data. This is doable
but the problem is you won't know the names of the data members that
are stored. The best you could do is print their addresses which will
probably be pretty useless in your case.

The proper way to do this will be to generate some custom code in each
accessor. It will be quite easy if you are prepared to modify and build
the XSD compiler directly.

The other idea that I've been toying with is support for a code generation
plugin in XSD. That would handle your use case perfectly. Would anyone else
be interested in this?

Boris



More information about the xsd-users mailing list