Home » Modeling » EMF » Not enforcing order/multiplicity in an xsd:sequence
Not enforcing order/multiplicity in an xsd:sequence [message #492935] |
Thu, 22 October 2009 12:21 |
Ben Tenne Messages: 50 Registered: October 2009 |
Member |
|
|
Consider the following XSD fragment:
<xs:sequence maxOccurs="unbounded">
<xs:element name="fruit" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="cake" type="xs:int" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
So, this requires that a single fruit is followed by a single cake, but any number of pairs can be included (i.e. fruit, cake - or, fruit, cake, fruit, cake, fruit, cake - etc.).
If I wrap this in a complexType and transform that to EMF, I end up with a class with getFruit() and getCake() methods that return lists. So far, so good. However, when I come to serialize that class, the multiplicity and ordering of the fruits and cakes are not enforced, leading to XML that is considered invalid against the schema, such as:
<?xml version="1.0" encoding="UTF-8"?>
<x2:Repeater xmlns:x2="http://x2">
<cake>22</cake>
<fruit>Banana</fruit>
<fruit>Apple</fruit>
<fruit>Orange</fruit>
<cake>75</cake>
</x2:Repeater>
Any comments welcomed.
Apologies if I've overlooked something, but I couldn't find any existing references to this problem.
Thanks,
Ben.
[Updated on: Thu, 22 October 2009 12:23] Report message to a moderator
|
|
|
Re: No enforcing order/multiplicity in an xsd:sequence [message #492943 is a reply to message #492935] |
Thu, 22 October 2009 12:50 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Ben,
In https://bugs.eclipse.org/bugs/show_bug.cgi?id=51210 there is a
prototype implementation for capturing more complex particle constraints
such as the one you show here. There just never seems time to complete
this...
Ben Tenne wrote:
> Consider the following XSD fragment:
>
> <xs:sequence maxOccurs="unbounded">
> <xs:element name="fruit" type="xs:string" minOccurs="1"
> maxOccurs="1"/>
> <xs:element name="cake" type="xs:int" minOccurs="1" maxOccurs="1"/>
> </xs:sequence>
>
> So, this requires that a single fruit is followed by a single cake,
> but any number of pairs can be included (i.e. fruit, cake - or, fruit,
> cake, fruit, cake, fruit, cake - etc.).
>
> If I wrap this in a complexType and transform that to EMF, I end up
> with a class with getFruit() and getCake() methods that return lists.
There's also the overall feature for controlling the mixed order, right?
> So far, so good. However, when I come to serialize that class, the
> multiplicity and ordering of the fruits and cakes are not enforced,
> leading to XML that is considered invalid against the schema, such as:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <x2:Repeater xmlns:x2="http://x2">
> <cake>22</cake>
> <fruit>Banana</fruit>
> <fruit>Apple</fruit>
> <fruit>Orange</fruit>
> <cake>75</cake>
> </x2:Repeater>
>
> Any comments welcomed.
>
> Apologies if I've overlooked something, but I couldn't find any
> existing references to this problem.
>
> Thanks,
> Ben.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Goto Forum:
Current Time: Wed Sep 25 13:28:08 GMT 2024
Powered by FUDForum. Page generated in 0.08342 seconds
|