[xsd-users] Accessing the xml:base attribute using cxx-parser.

Boris Kolpackov boris at codesynthesis.com
Wed Nov 28 02:30:40 EST 2007


Hi Jeroen,

Jeroen N. Witmond [Bahco] <jnw at xs4all.nl> writes:

> As a companion to my webpage about accessing the xml:base attribute using
> cxx-tree [1] I have created a new page about doing the same with
> cxx-parser.
>
> http://www.xs4all.nl/~jnw/codesynthesis/xmlnamespace/parser.html

Nice. I've added this link to the C++/Parser page in the wiki:

http://wiki.codesynthesis.com/Parser


> Having completed this, I wonder why the C++/Parser Mapping Getting Started
> Guide [2] does not open with a reference to cxx-parser options
> --generate-print-impl and --generate-test-driver. I was very pleased when
> I found out about them before having written any code. :)

We were afraid some people may think of this as a blatant self-
promotion ;-). Seriously though, these options are discussed in
Section 2.3 of the "Hello World" chapter, as soon as the reader
has an idea what the C++/Parser mapping is about.


> I also wonder if I have missed any magic to do with cxx-parser what the
> customization of anyType achieves for cxx-tree.

There are a couple of ways to save typing, especially if you have a
lot of parsers that need to handle xml:* attributes. Both ways use
C++ mixin idiom to add xml:base attribute parsing to other parsers.

The first example[1] provides implementation of the _any_attribute()
function as a mixin. It is based on and is very similar to your
parser-wildcard example.

The second example[2] uses the low-level _attribute() callback to
intercept all attributes. It then handles xml:base itself and
delegates parsing of other attributes to the original implementation.
One advantage of this approach is that it will support xml:base
even if the schema does not allow it (provided you have disabled
validation in the underlying XML parser or is using validation in
the generated code).

[1] http://codesynthesis.com/~boris/tmp/lax-pimpl-any-mixin.hpp
[2] http://codesynthesis.com/~boris/tmp/lax-pimpl-intercept-mixin.hpp

Boris




More information about the xsd-users mailing list