|
Re: EMF: mixed complex type generates invalid XML [message #1075493 is a reply to message #1075465] |
Mon, 29 July 2013 14:18 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Rob,
Comments below.
On 29/07/2013 3:25 PM, Rob Mising name wrote:
> Hi Ed,
>
> I have stumbled accross a small issue with mixed that I would be very
> grateful of your opinion and assistance.
>
> If I have a schema as follows:
>
> <xs:element name="student">
> <xs:complexType mixed="true">
> <xs:sequence>
> <xs:element name="name" type="xs:string"/>
> <xs:element name="age" type="xs:positiveInteger"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
>
> It will generate all the classes OK, so if I then code something like:
>
> studentType createStudent =
> MixedContentFactory.eINSTANCE.createstudentType();
> createStudent.setName("Bully Bogywart");
> createStudent.setAge(new BigInteger("18"));
The order will be recorded in the feature map...
>
>
> then I will get the expected XML of:
>
> <content:student xmlns:content="http://example.com/MixedContent">
> <name>Bully Bogywart</name>
> <age>18</age>
> </content:student>
>
>
> However, if I set the elements in a more random order:
>
> studentType createStudent =
> MixedContentFactory.eINSTANCE.createstudentType();
> createStudent.setAge(new BigInteger("18"));
> createStudent.setName("Bully Bogywart");
>
>
> Then it will generate the following XML:
>
> <content:student xmlns:content="http://example.com/MixedContent">
> <age>18</age>
> <name>Bully Bogywart</name>
> </content:student>
Yes, it's unfortunate but there's no information recorded about the
"correct" order: https://bugs.eclipse.org/bugs/show_bug.cgi?id=51210
>
>
> Which seems to reflect the order in which they were added, but not the
> valid order as specified in the schema.
Yes.
>
> Do you have any ideas or pointers as to what might be causing this?
It's just the way it is. XML Schema allows all sorts of complexity in
the particle structure that's not recorded, not checked, and not
available for trying to maintain a correct order. It's an unfortunate
limitation of the current design.
>
> Thanks
>
> Rob
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03282 seconds