Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Nested xsd:any loading issues
Nested xsd:any loading issues [message #650064] Fri, 21 January 2011 15:27 Go to next message
Rob Mising name is currently offline Rob Mising nameFriend
Messages: 118
Registered: July 2010
Senior Member
Hi, I've come accross a problem when XML does not appear to be loading correctly when there is a sequence within another sequence both containing an xsd:Any.

If you have a schema as follows:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://example.com/NestedAny" targetNamespace="http://example.com/NestedAny">
	<xs:element name="train" type="TrainType"/>
	<xs:complexType name="TrainType">
		<xs:sequence>
			<xs:element name="line" type="xs:string"/>
			<xs:element name="company" type="xs:string"/>
			<xs:any processContents="lax" minOccurs="1" maxOccurs="1"/>
			<xs:sequence>
				<xs:any processContents="skip" minOccurs="1" maxOccurs="1"/>
			</xs:sequence>
		</xs:sequence>
	</xs:complexType>
</xs:schema>


It will generate the ecore and genmodel as expected, creating two get interfaces (getAny and getAny1) on the TrainType object. However if you try and load the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<n1:train xsi:schemaLocation="http://example.com/NestedAny NestedAny.xsd" xmlns:n1="http://example.com/NestedAny" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<line>String</line>
	<company>String</company>
	<name1>aName1</name1>
	<name2>aName2</name2>
</n1:train>


Then I would have expected <name1> to have been stored into the first xsd:any (as it can only hold one) and then <name2> to have been stored in the second xsd:any. However the current behaviour loads both <name1> and <name2> into the first xsd:any, making something that is invalid (and fails validation).

It seems that the schema is valid according to the spec, does anyone have any ideas with this?

Thanks, Rob
Re: Nested xsd:any loading issues [message #650115 is a reply to message #650064] Fri, 21 January 2011 19:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Rob,

Comments below.

Rob wrote:
> Hi, I've come accross a problem when XML does not appear to be loading
> correctly when there is a sequence within another sequence both
> containing an xsd:Any.
>
> If you have a schema as follows:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns="http://example.com/NestedAny"
> targetNamespace="http://example.com/NestedAny">
> <xs:element name="train" type="TrainType"/>
> <xs:complexType name="TrainType">
> <xs:sequence>
> <xs:element name="line" type="xs:string"/>
> <xs:element name="company" type="xs:string"/>
> <xs:any processContents="lax" minOccurs="1" maxOccurs="1"/>
> <xs:sequence>
> <xs:any processContents="skip" minOccurs="1"
> maxOccurs="1"/>
> </xs:sequence>
> </xs:sequence>
> </xs:complexType>
> </xs:schema>
>
>
> It will generate the ecore and genmodel as expected, creating two get
> interfaces (getAny and getAny1) on the TrainType object. However if
> you try and load the following XML:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <n1:train xsi:schemaLocation="http://example.com/NestedAny
> NestedAny.xsd" xmlns:n1="http://example.com/NestedAny"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <line>String</line>
> <company>String</company>
> <name1>aName1</name1>
> <name2>aName2</name2>
> </n1:train>
I imagine the first wildcard will be set twice.
>
>
> Then I would have expected <name1> to have been stored into the first
> xsd:any (as it can only hold one) and then <name2> to have been stored
> in the second xsd:any. However the current behaviour loads both
> <name1> and <name2> into the first xsd:any, making something that is
> invalid (and fails validation).
I'm not surprised.
>
> It seems that the schema is valid according to the spec, does anyone
> have any ideas with this?
We'd have to be significantly smarter and not just look for an
appropriate feature (there's more than one in this case), but to check
which one is already populated beyond its capacity. I'm not likely to
find time to deal with corners like this anytime in the foreseeable
future. A single wildcard with min/max 2 would handle this fine...
>
> Thanks, Rob


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Nested xsd:any loading issues [message #650317 is a reply to message #650115] Mon, 24 January 2011 11:47 Go to previous messageGo to next message
Rob Mising name is currently offline Rob Mising nameFriend
Messages: 118
Registered: July 2010
Senior Member
Hi Ed,

Thanks for the clarification, I have found another situation for this sort of behaviour, slightly different result:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://example.com/ExtendedAnyMultiple" targetNamespace="http://example.com/ExtendedAnyMultiple">
	<xs:element name="PlaneElement" type="Plane"/>
	<xs:element name="TransportElement" type="Transport"/>
	<xs:complexType name="Transport">
		<xs:sequence>
			<xs:element name="wheels" type="xs:int"/>
			<xs:any processContents="lax" maxOccurs="1" minOccurs="1"/>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="Plane">
		<xs:complexContent>
			<xs:extension base="Transport">
				<xs:sequence>
					<xs:element name="wingtype" type="xs:string"/>
					<xs:any processContents="lax" maxOccurs="1" minOccurs="1"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
</xs:schema>


If you load into the EMF generated from this schema the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<multiple:Plane xmlns:complex="http://example.com/ElmAndComplex" xmlns:multiple="http://example.com/ExtendedAnyMultiple">
	<wheels>3</wheels>
	<complex:myCarElement>
		<colour>red</colour>
	</complex:myCarElement>
	<wingtype>Bi</wingtype>
	<complex:myCarElement>
		<colour>blue</colour>
	</complex:myCarElement>
</multiple:Plane>


Then the first any gets a single value, but the second any does not get a value at all. It also fails to validate the XML.

Thanks, Rob
Re: Nested xsd:any loading issues [message #650381 is a reply to message #650317] Mon, 24 January 2011 16:56 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020100030906020803000604
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Rob,

Yes this is another variation. In general, EMF as it works today, can't
handle the same particle name (or wildcard pattern) appearing more than
once in the content model. We'd need more of state-machine-based
approach to make that work, i.e., like what's in

https://bugs.eclipse.org/bugs/show_bug.cgi?id=51210

(Which looks like something I'll never find time to address.)


Rob wrote:
> Hi Ed,
>
> Thanks for the clarification, I have found another situation for this
> sort of behaviour, slightly different result:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns="http://example.com/ExtendedAnyMultiple"
> targetNamespace="http://example.com/ExtendedAnyMultiple">
> <xs:element name="PlaneElement" type="Plane"/>
> <xs:element name="TransportElement" type="Transport"/>
> <xs:complexType name="Transport">
> <xs:sequence>
> <xs:element name="wheels" type="xs:int"/>
> <xs:any processContents="lax" maxOccurs="1" minOccurs="1"/>
> </xs:sequence>
> </xs:complexType>
> <xs:complexType name="Plane">
> <xs:complexContent>
> <xs:extension base="Transport">
> <xs:sequence>
> <xs:element name="wingtype" type="xs:string"/>
> <xs:any processContents="lax" maxOccurs="1"
> minOccurs="1"/>
> </xs:sequence>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
> </xs:schema>
>
>
> If you load into the EMF generated from this schema the following XML:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <multiple:Plane xmlns:complex="http://example.com/ElmAndComplex"
> xmlns:multiple="http://example.com/ExtendedAnyMultiple">
> <wheels>3</wheels>
> <complex:myCarElement>
> <colour>red</colour>
> </complex:myCarElement>
> <wingtype>Bi</wingtype>
> <complex:myCarElement>
> <colour>blue</colour>
> </complex:myCarElement>
> </multiple:Plane>
>
>
> Then the first any gets a single value, but the second any does not
> get a value at all. It also fails to validate the XML.
>
> Thanks, Rob

--------------020100030906020803000604
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Rob,<br>
<br>
Yes this is another variation.  In general, EMF as it works today,
can't handle the same particle name (or wildcard pattern) appearing
more than once in the content model.  We'd need more of
state-machine-based approach to make that work, i.e., like what's in<br>
<blockquote><a
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=51210">https://bugs.eclipse.org/bugs/show_bug.cgi?id=51210</a><br>
</blockquote>
(Which looks like something I'll never find time to address.)<br>
<br>
<br>
Rob wrote:
<blockquote cite="mid:ihjoh6$nro$1@news.eclipse.org" type="cite">Hi Ed,
<br>
<br>
Thanks for the clarification, I have found another situation for this
sort of behaviour, slightly different result:
<br>
<br>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<br>
&lt;xs:schema xmlns:xs=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>
xmlns=<a class="moz-txt-link-rfc2396E" href="http://example.com/ExtendedAnyMultiple">"http://example.com/ExtendedAnyMultiple"</a>
targetNamespace=<a class="moz-txt-link-rfc2396E" href="http://example.com/ExtendedAnyMultiple">"http://example.com/ExtendedAnyMultiple"</a>&gt;
<br>
    &lt;xs:element name="PlaneElement" type="Plane"/&gt;
<br>
    &lt;xs:element name="TransportElement" type="Transport"/&gt;
<br>
    &lt;xs:complexType name="Transport"&gt;
<br>
        &lt;xs:sequence&gt;
<br>
            &lt;xs:element name="wheels" type="xs:int"/&gt;
<br>
            &lt;xs:any processContents="lax" maxOccurs="1"
minOccurs="1"/&gt;
<br>
        &lt;/xs:sequence&gt;
<br>
    &lt;/xs:complexType&gt;
<br>
    &lt;xs:complexType name="Plane"&gt;
<br>
        &lt;xs:complexContent&gt;
<br>
            &lt;xs:extension base="Transport"&gt;
<br>
                &lt;xs:sequence&gt;
<br>
                    &lt;xs:element name="wingtype"
type="xs:string"/&gt;
<br>
                    &lt;xs:any processContents="lax" maxOccurs="1"
minOccurs="1"/&gt;
<br>
                &lt;/xs:sequence&gt;
<br>
            &lt;/xs:extension&gt;
<br>
        &lt;/xs:complexContent&gt;
<br>
    &lt;/xs:complexType&gt;
<br>
&lt;/xs:schema&gt;
<br>
<br>
<br>
If you load into the EMF generated from this schema the following XML:
<br>
<br>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<br>
&lt;multiple:Plane xmlns:complex=<a class="moz-txt-link-rfc2396E" href="http://example.com/ElmAndComplex">"http://example.com/ElmAndComplex"</a>
xmlns:multiple=<a class="moz-txt-link-rfc2396E" href="http://example.com/ExtendedAnyMultiple">"http://example.com/ExtendedAnyMultiple"</a>&gt;
<br>
    &lt;wheels&gt;3&lt;/wheels&gt;
<br>
    &lt;complex:myCarElement&gt;
<br>
        &lt;colour&gt;red&lt;/colour&gt;
<br>
    &lt;/complex:myCarElement&gt;
<br>
    &lt;wingtype&gt;Bi&lt;/wingtype&gt;
<br>
    &lt;complex:myCarElement&gt;
<br>
        &lt;colour&gt;blue&lt;/colour&gt;
<br>
    &lt;/complex:myCarElement&gt;
<br>
&lt;/multiple:Plane&gt;
<br>
<br>
<br>
Then the first any gets a single value, but the second any does not get
a value at all.  It also fails to validate the XML.
<br>
<br>
Thanks, Rob
<br>
</blockquote>
</body>
</html>

--------------020100030906020803000604--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO] Cross resources references
Next Topic:EMF databinding
Goto Forum:
  


Current Time: Thu Mar 28 14:50:12 GMT 2024

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

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

Back to the top