[xsd-users] inline namespaces

Boris Kolpackov boris at codesynthesis.com
Sun Feb 2 22:32:43 EST 2014


Hi Ray,

Ray Lischner <rlischner at proteuseng.com> writes:
 
> Perhaps the --namespace-regex option can use a magic character in
> the C++ namespace to mean "make this inline"

I don't see why we can't support this. One tricky question is how
do we refer to names in inline namespaces from other generated
files?

For example, let's say we mapped XML namespace foo to C++ namespace
foo::v1 (v1 is inline). I think for all the code that is generated
for XML namespace foo we should use the long form (foo::v1::object).
However, if we have another schema with XML namespace bar that imports
foo, we could use foo::v1::object or foo::object. And I think both
variants could be desirable in different situations. In fact, one
could come up with a scenario where both approaches are used at the
same time depending on the importing namespace.

We could achieve the short version (foo::object) by simply using
a different namespace mapping (e.g., foo=foo instead of foo=foo::v1)
when compiling other schemas. While a bit inconvenient (have to
specify two mappings for the same namespace), it will work for
the separate compilation (file-per-schema) mode. It won't work
for the file-per-type mode where all the schemas are compiled
at once. Though in this case I don't think it makes much sense
to use the short variant, since this mode is normally used in the
"intertwined blob" kind of schemas where "schema A uses schema B"
statements don't apply.

So perhaps we should keep it simple and let the user use a
different mapping for different schemas, if desired. This is
already quite an "advanced" area so a bit of extra inconvenience
won't be too bad. Plus it will keep the XSD compiler really
simple (we won't have to distinguish between different namespaces
where the symbol is referenced and eliminating inline namespace
in certain cases).

What do you think?

Boris



More information about the xsd-users mailing list