[xsd-users] xml-schema.h

Boris Kolpackov boris at codesynthesis.com
Fri May 9 08:52:00 EDT 2008


Hi Shiva,

Balasubramanyam, Shivakumar <sbalasub at qualcomm.com> writes:

> IMO, the file consists of the of the fundamental type declarations for
> xml-schema and should be rolled with XSD rpm which has files related
> with xsd/cxx/tree/...
>
> May I know the reason why this is not part of XSD (for example
> xsd/core/xml-schema.h or xsd/xml-schema.h)?

The contents of this file depend on the way you generated the code.
Some things that affect it: character type (char/wchar_t), whether
parsing/serialization is enabled (if it is then some extra aliases
are added), binary serialization, etc. Plus it is possible to
customize the built-in types which is captured in the generated
xml-schema.h. This makes it impossible to package it with with
the XSD distribution itself.


> In our project, we have two separate libraries both have xml-schema
> generation. So if the application uses these two libraries we have a
> duplicate declaration issues.

If your libraries can use the same xml-schema.h (e.g., the XSD command
lines use similar options) then you can factor the xml-schema.h file
into a separate (perhaps header-only) library which both of your other
libraries use.

Alternatively, you can keep separate xml-schema.h files (you can
either use different names or include them with directory prefixes,
e.g., foo/xml-schema.h and bar/xml-schema.h). Plus you will need
to change the namespaces that they use for xml_schema. One approach
would be to nest the xml_schema namespace into your library namespace.
For example, if you have two libraries, libfoo and libbar, and they
use foo and bar C++ namespaces respectively, then you can do the
following:

$ xsd cxx-tree --generate-xml-schema --namespace-map \
http://www.w3.org/2001/XMLSchema=foo::xml_schema foo/xml-schema.xsd

$ xsd cxx-tree --generate-xml-schema --namespace-map \
http://www.w3.org/2001/XMLSchema=bar::xml_schema bar/xml-schema.xsd

Then foo/xml-schema.h will look like this:

namespace foo
{
  namespace xml_schema
  {
    ...
  }
}

Boris




More information about the xsd-users mailing list