[xsd-users] cpp-parser nested elements/attributes
Boris Kolpackov
boris at codesynthesis.com
Sun Apr 16 12:43:32 EDT 2006
Hi Kevin,
Kevin Wooten <kevin at wooten.com> writes:
> I have either misunderstood how to setup a cpp-parser or it seems to be
> quite broken.
It is the latter. I wrote a small test based on your schema and instance
and it confirms that the current release does handle this case properly.
Accidently ;-) we've re-designed the internals quite a bit for the next
release and this happened to fix the problem. The following test:
#include <iostream>
#include <string>
#include "test.hxx"
using std::cerr;
using std::endl;
using std::string;
struct Sub_parser: Sub<void, void, void, string>
{
virtual void
pre ()
{
cerr << "Sub::pre" << endl;
}
virtual void
sub ()
{
cerr << "Sub::sub" << endl;
}
virtual void
sub2 ()
{
cerr << "Sub::sub2" << endl;
}
virtual void
name (string const& n)
{
cerr << "Sub::name: " << n << endl;
}
virtual void
post ()
{
cerr << "Sub::post" << endl;
}
};
struct Test_parser: Test<void, void, string>
{
virtual void
pre ()
{
cerr << "Test::pre" << endl;
}
virtual void
sub ()
{
cerr << "Test::sub" << endl;
}
virtual void
name (string const& n)
{
cerr << "Test::name: " << n << endl;
}
virtual void
post ()
{
cerr << "Test::post" << endl;
}
};
int
main (int argc, char* argv[])
{
if (argc != 2)
{
cerr << "usage: " << argv[0] << " test.xml" << endl;
return 1;
}
try
{
xml_schema::string string_p;
Sub_parser sub_p;
Test_parser test_p;
sub_p.parsers (sub_p, sub_p, string_p);
test_p.parsers (sub_p, string_p);
test_p._parse (argv[1], "", "test");
}
catch (xml_schema::exception const& e)
{
cerr << e << endl;
return 1;
}
catch (std::ios_base::failure const&)
{
cerr << "io failure" << endl;
return 1;
}
}
prints the following on the XML instance you provided:
Test::pre
Test::name: testName
Sub::pre
Sub::name: subName
Sub::pre
Sub::name: nestedName
Sub::post
Sub::sub
Sub::pre
Sub::name: sub2Name
Sub::post
Sub::sub2
Sub::post
Test::sub
Test::post
which I think is the expected behavior. We are hoping to release 2.1.0 in
the next couple of days. If you would like to try the fix before that,
please let me know and I will build you a pre-release binary.
Thanks for reporting this!
-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/20060416/afc02d8e/attachment.pgp
More information about the xsd-users
mailing list