[xsd-users] C++/Parser: parsing of <xsd:attribute>
Boucher, Robert J
Robert.Boucher at ca.com
Tue Aug 22 10:55:20 EDT 2006
Hello!
I have a question on how to properly handle <xsd:attribute> when parsing
a document. I use the following schema:
<xsd:complexType name="ItemType">
<xsd:sequence>
<xsd:element name="doc" type="xsd:string"
minOccurs="0" maxOccurs="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string"
use="optional" />
<xsd:attribute name="create" type="xsd:boolean"
use="optional" default="false" />
</xsd:complexType>
When I generate the templates, I get the following parser hooks in the
ItemType template:
virtual void pre ();
virtual void doc (const _xsd_doc_&);
virtual void name (const _xsd_name_&);
virtual void create (const _xsd_create_&);
virtual _xsd_ItemType_ post ();
However, when I use the template and instantiate it, I can see that the
doc() method is called property, but I never see name() or create() get
called. Tracing the application, I noticed that I can "capture" the
presence of attributes if I provide an implementation of the
_attribute_impl() method. In my testing, I also note the name() and
create() never get called.
So my question is: what is the proper way of parsing attributes? Do I
need to implement _attribute_impl() or is there something else I need to
do to have the parser call the name() & create() methods explicitly?
Thank you very much for your time,
Robert B.
More information about the xsd-users
mailing list