[xsde-users] No polymorphism without substitutionGroup?

Boris Kolpackov boris at codesynthesis.com
Mon Jun 24 07:54:49 EDT 2013


Hi Werner,

Werner Haug <werner.haug at agfa.com> writes:

> The software (which I included in a ZIP file) produces the following 
> output on serializing:
> 
> <MSG xmlns:msg="XTest.XBase.Domain.Msg" xmlns:xsd="
> [...]
>
> 
> When parsing the just serialized XML, I get the Parser_exception in line 
> 1, column 163: schema error. unexpected element encountered (which is the 
> xsi:type="msg:MSG_Prep").
> 
> This is the XML I would expect:
> 
> <MSG xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>

In your code I see the following two lines:

xml_schema::document_simpl doc_s (*msgSSkel, 
                                  msgSAggr.root_name (),
                                  true,
                                  MSG_sskel::_static_type ());

doc_s.add_prefix("msg", "XTest.XBase.Domain.Msg");

The first line tells XSD/e that the root element is unqualified, which
is not correct in your case. So we need to change it to pass the root
element namespace in addition to its name:

xml_schema::document_simpl doc_s (*msgSSkel, 
                                  msgSAggr.root_namespace (),
                                  msgSAggr.root_name (),
                                  true,
                                  MSG_sskel::_static_type ());

The second line maps the 'XTest.XBase.Domain.Msg' namespace to the 'msg'
prefix while we want it to be mapped to "no prefix" (default namespace).
So we need to change this lime like so:

doc_s.add_prefix("", "XTest.XBase.Domain.Msg");

Boris



More information about the xsde-users mailing list