[xsd-users] Please help on this C++ code test_parser.cxx
Boris Kolpackov
boris at codesynthesis.com
Fri Dec 8 09:21:28 EST 2006
Hi Paul,
Ac22750085 at yahoo.com <ac22750085 at yahoo.com> writes:
> Attached please find a jar file test_parser.jar which includes
> your example for hello.xsd and my schema file cart_conf.xsd
Thanks. In the future please refrain from sending generated code and
executables -- XML file, schema file and your implementation are usually
enough.
> I have generated the header file cart_conf.hxx and the
> template file cart_conf.txx successfully for the cart_conf.xsd
> schema file then I mimic your test program driver.cxx and
> wrote a test program called test_parser.cxx and tried to print
> out the information cart_conf_version, cartconf_name and
> cartconf_revision out from the cart_conf.xml file
> but it only prints out the debug statements.
>
> [...]
>
> Could you look the program test_parser.cxx to see what I did wrong
It does not work because you parser structure does not correspond to
the document structure. For example, you are trying to parse a root
element of the document with the header_infoType parser.
Here is a working parser for the root element to get you started:
struct cartconf_parser: cartconf<void,
string, //cart_conf_version
void,
void,
void,
void>
{
virtual void
cart_conf_version (const string& v)
{
cout << "version: " << v << endl;
}
};
xml_schema::string string_p;
cartconf_parser cartconf_p;
cartconf_p.cart_conf_version_parser (string_p);
xml_schema::document<void> doc_p (cartconf_p, "cartconf");
Now in order to get to the name and revision, you will first need to
implement a parser for cart_header and plug it into cartconf after the
version. Only then you can get to the header_infoType parser which
should be plugged to the cart_header parser.
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/20061208/aa6b739a/attachment.pgp
More information about the xsd-users
mailing list