[xsd-users] Accessing xml:base: Migration to xsd 3.2.0

Jeroen N. Witmond [Bahco] jnw at xs4all.nl
Tue Dec 2 09:54:05 EST 2008


Hi Boris,

Boris Kolpackov <boris at codesynthesis.com> wrote:
> Jeroen N. Witmond [Bahco] <jnw at xs4all.nl> writes:
>
>> - In file custom-xmlbase/xml-base.cpp[1, item 3][3] I noticed that in
>>   constructor 'xml_base::xml_base(::xsd::cxx::tree::type& type,
>>   ::xml_schema::flags f)' the call to '::xsd::cxx::xml::dom::parser<
>>   wchar_t > p' now takes two additional boolean arguments. I assume
>>   based on the code generated by xsd for program explicit[1, top left]
>>   that in this case these booleans should be true.  Is this correct?
>
> This is what happens when you rely on implementation details. The
> dom::parser class is not really meant for public use. We have made
> some optimizations for 3.2.0 and its c-tor has changed to include
> two flags indicating whether the element being parsed is expected
> to have elements and attributes, respectively.

Thanks for your clarification. On the web[1], I've changed the description
and the source code accordingly.

A question: For now, I've set both flags to true. I've noticed that it
also seems to work when I set the first flag to false, and the second flag
to true. Should I be using this setting instead?

When I set both flags to false. I get a segmentation error.

>> - When compiling the sources for programs parser-datamodel[2, bottom
>>   left] and parser-anytype[2, bottom right] I get warnings and errors
>>   like:
>>
>> [...]
>>
>>     'xsd::cxx::parser::parser_base<char>' is an ambiguous base of
>>     'metadox::foo_type_pimpl'
>
> Hm, this is the result of our work on reducing the use of virtual
> inheritance. While it helped a lot in minimizing object code size,
> it made the technique that you are using unavailable. I can see
> two ways to resolve this off the top of my head. First would be to
> override _start_element() and _end_element() in each _pimpl class.
>
> The second approach is to use a class template, for example:
>
> template <typename B>
> struct common_base: virtual B
> {
>   virtual void
>   _start_element (const xml_schema::ro_string& ns,
>                   const xml_schema::ro_string& n);
>
>   virtual void
>   _end_element (const xml_schema::ro_string& ns,
>                 const xml_schema::ro_string& n);
> };
>
> You would then add it to your _pimpl classes like so:
>
> class foo_pimpl: common_base<foo_pskel>
> {
>   ...
> };

On the web[2], I've changed the description and the source code to use the
second approach. It seems (in parser-anytype) that I can use the same
template class for both simple and complex types, and also to override
_attribute() and _any_atribute().

For the record: Starting in xsd version 3.1.0.b3, _start_element() takes
three arguments:
    virtual void
    _start_element (const ::xml_schema::ro_string& ns,
                    const ::xml_schema::ro_string& n,
                    const ::xml_schema::ro_string* type);

Thanks for your help!

Jeroen.

[1] http://www.xs4all.nl/~jnw/codesynthesis/xmlnamespace/index.html
[2] http://www.xs4all.nl/~jnw/codesynthesis/xmlnamespace/parser.html





More information about the xsd-users mailing list