[xsd-users] C++/Parser: parsing of <xsd:attribute>

Boris Kolpackov boris at codesynthesis.com
Tue Aug 22 14:23:22 EDT 2006


Hi Robert,

Boucher, Robert J <Robert.Boucher at ca.com> writes:

> 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.

There are two most likely causes of this:

1. You did not override the hooks. This usually happens when the
   signatures in the generated parser template and the one you
   use in the implementation do not match:

   struct ItemTypeImpl: ItemType<void,
                                 std::string, // doc
                                 std::string, // name (1)
                                 bool> // create (2)
   {

     // Make sure the type matches (1).
     //
     virtual void name (const std::string&);

     // Make sure the type matches (2).
     //
     virtual void name (const bool&);
   };


2. You did not set the parsers for name and create. Continuing the
   above example, make sure you have something like this in your
   code:

   xml_schema::string string_parser;
   xml_schema::boolean bool_parser;
   ItemTypeImpl item_parser;

   item_parser.doc_parser (string_parser);
   item_parser.name_parser (string_parser);
   item_parser.create_parser (bool_parser);


If none of these help, then we will need a small test case that reproduces
the problem. A schema, a test XML instance and a simple test driver would
be enough.

hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20060822/ea68084b/attachment.pgp


More information about the xsd-users mailing list