xsdxerces-c

How can I access enumeration ids in XML schema (using xerces-c)?


Supposing I had an XSD that might contain something like this:

<simpleType name="CELESTIAL_IMPORIUM_CATEGORY">
    <restriction base="integer">
        <enumeration id="BELONGING_TO_THE_EMPEROR" value="8001"/>
        <enumeration id="EMBALMED"                 value="8002"/>
        <enumeration id="TRAINED"                  value="8003"/>
        <enumeration id="SUCKLING_PIGS"            value="8004"/>
    </restriction>
</simpleType>

Suppose I wanted to be able to get hold of both enumeration values, and their names (which are in the id attributes). I'm trying to figure out if this is possible.

Supposing a little bit further, I might be using xerces-c (3.1.1, say), and more specifically, be using classes from xercesc/framework/psvi. I've had a preliminary poke about, and things aren't looking promising:

Is there, perhaps, something I'm missing?


Solution

  • I don't think there is anything you're missing (but I am not versed in Xerces-C internals). The XSD spec defines the post-schema-validation infoset and the abstract structure of schema components in some detail, but it does not require that validators provide access to any particular parts of either, and still less does it specify an API for doing so. (At the crucial moment, a WG member from an influential company snarled "We don't need no steenking API specs", and pretty much all the vendors in the room agreed.) So what you have access to is determined by the specific software you're using, as is the API through which you have access to it.

    Even the most thorough of APIs, however, is unlikely to provide access to the values of ID attributes on the xsd:enumeration elements -- the ID attribute doesn't correspond to any part of the simple type component and virtually all designers of APIs for schema information are likely to regard it as an epiphenomenal artifact of the XML representation of the component, without any intrinsic interest.

    If you have access to the schema documents which define the schema you are using, of course, you can always just use normal XML tools to find the IDs you're interested in; that's one of the reasons for making schema documents be XML documents in the first place.