[xsd-users] how to parse class attributes and data types

Boris Kolpackov boris at codesynthesis.com
Mon Jan 11 10:05:18 EST 2016


Hi Martin,

Martin Landa <landa.martin at gmail.com> writes:

> Basically I am trying to write a program which reads XML file and prints
> information about xsd class attributes and their data types.
> My program should print:
> 
> 1) number of items - in this case 2
> 2) and item attributes and their types (based on xsd definition).
> id -> participantIdAttrType
> jm -> stringType
> pr -> stringType
> ...
> psc -> postCodeType

XSD's primary goal is to generate a C++ object model based on the XML Schema
which can then be used to load the corresponding XML documents. As such, it
doesm't retain any information about XML Schema in C++ (for 99% of the
applications that would be an unnecessary bloat).

There is (probably) a way to achieve what you want: the C++ object model
can be optionally associated with the underlying Xerces-C++ DOM nodes.
And Xerces-C++ DOM nodes can be optionally associated with what is called
Post-Schema Validation Infoset (PSVI) which is essentially the XML Schema
"fragment" (e.g., a type) that was used to validate this XML fragment.

This is all fairly complicated (especially working with Xerces-C++ PSVI)
and really outside the main use of XSD (in fact, chances are, you are
better off with pure Xerces-C++). So if you want to go this route, you
will have to figure all this out yourself. Good luck.

Boris



More information about the xsd-users mailing list