[xsd-users] XSD Parsing with different schema files

Boris Kolpackov boris at codesynthesis.com
Wed Nov 23 10:48:04 EST 2011


Hi Dominik,

Lickert, Dominik (LEN, DivHG) <DLickert at testo.de> writes:

> I have a problem with the parsing of a Microsoft Visio files. I save my
> flow chart as *.vdx, which is a XML format.
> 
> I build source- and header codes with the XSD-tool and the XSD-schema-files
> of Microsoft Visio. There are three different schema files for Microsoft
> Visio, which are all needed for the edition 2010. They are not linked to
> each other, they are separated. So the XSD-tool generates three different
> source- and header codes. The solution of the problem is to link these three
> XSD-schema-files together. I think this is possible with the command line
> attributes of the XSD-tool. I tried it with the command line attributes
> "namespace-map" and "polymorphic", but without success.
> 
> There is only in one of the three source code files a parse function.
> When I parse my Visio file, with this parse function, it doesn't find
> all elements. Elements of the two other XSD-schema-files are ignored
> by the parse function. Even all elements in the same level and behind
> this element of a other schema file are also ignored. The reason for
> that is, the for-loop is broken, when an element of a other XSD-schema-
> file occurs.

It is hard to say exactly why it doesn't work without seeing some
concrete examples of the schema types/elements involved. However,
generally, if the schemas are separate (you say they are not "linked"
by which I assume you mean that there is no xsd:include or xsd:import
directive that includes/imports one schema into another), then the
only way one schema can use elements from another is indirectly
via a wildcard (xsd:any). That is, one schema defines a wildcard
and another defines elements which will be substituted for this
wildcard. If that's the case, then it is possible to "parse" these
elements using parsing code generated from another schema. For sample
code that shows how to do this, refer to the 'wildcard' example in
the examples/cxx/tree/ directory in the XSD distribution.

Actually, there is another case where unrelated schemas can in some
sense use each other indirectly. In this situation one of the schemas
uses one of the built-in types (normally xsd:anyType) as a base and
other schemas extend or restrict this type. The resulting combination
can then be used with XML Schema polymorphism (xsi:type). However,
this should work our of the box in XSD, provided you have compiled
your schemas with the --generate-polymorphic option, marked the base
type as polymorphic with the --polymorphic-type option, and linked
all the resulting source files into your application.

Boris



More information about the xsd-users mailing list