Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
Ben Tenne is currently offline Ben TenneFriend
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 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
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/
Re: No enforcing order/multiplicity in an xsd:sequence [message #492951 is a reply to message #492943] Thu, 22 October 2009 13:31 Go to previous message
Ben Tenne is currently offline Ben TenneFriend
Messages: 50
Registered: October 2009
Member
Thanks Ed. Actually, I'd seen that Bugzilla entry, but hadn't appeciated that it's an instance of the same issue.

Cheers,
Ben.
Previous Topic:java.util.ConcurrentModificationException in AdapterFactoryContentProvide
Next Topic:Problem with href
Goto Forum:
  


Current Time: Fri Apr 19 12:41:21 GMT 2024

Powered by FUDForum. Page generated in 0.01901 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top