[xsd-users] Getting the tag name in a cxx-parser post_<Type> method

Wood, Matthew D matthew.d.wood at intel.com
Mon Feb 7 23:19:33 EST 2011


I'm attempting to parse the XACML 2.0 schema using the XSD/Parser method (http://docs.oasis-open.org/xacml/2.0/access_control-xacml-2.0-policy-schema-os.xsd). I have everything working beautifully, except for one construct that seems to be a bit of a corner-case for the parser.

The schema defines a type AttributeDesignatorType and four derived types ActionAttributeDesignatorType, ResourceAttributeDesignatorType, EnvironmentAttributeDesignatorType, and SubjectAttributeDesignatorType with the following properties:
- AttributeDesignatorType is an abstract type that is never found in actual XML
- All derivatives of AttributeDesignatorType are part of substitution group ExpressionType
- Only SubjectAttributeDesignatorType has additional attributes
- Each derived type has a specific semantic meaning, so they need to be differentiated

The last point causes the parser to generate a parser skeleton for AttributeDesignatorType and SubjectAttributeDesignatorType, with the former parser shared by the three types defining no additional structure and the later parser derived from the former.

At points within the schema where a specific derivative type is reference explicitly, I can infer the tag type based on the element callback of the containing parser. In cases where the derivative type is encountered in the context of a substitution group, I can differentiate the SubjectAttributeDesignatorType due to the extra attributes triggering the unique parser, but the other three derivatives only call the parser for the common AttributeDesignatorType. When I receive the call to post_AttributeDesignatorType (via overridden post_ExpressionType), I need to determine the end tag name to properly interpret the semantics of the document.

This is where I'm stumped.

Setting a breakpoint in the post_AttributeDesignatorType method, I can see that the call sequence triggering the method is from the parser skeleton of the containing element instead of the AttributeDesignatorType parser skeleton, so overriding the _end_element_impl method in the AttributeDesignatorType skeleton and stealing the tag that way won't work. I could override the _end_element_impl method in the containing parser, but I can't see a clean way to do that, and there are multiple points where the structure can appear in the context of a substitution group so it could get really messy from a maintenance standpoint.

Thanks in advance,
Matt




More information about the xsd-users mailing list