xsi:nil handling in EMF [message #1275066] |
Sat, 22 March 2014 08:37  |
Eclipse User |
|
|
|
Hi,
I would like to handle an xsd element with xsi:nil which also has xml-attributes. Is it possible to detect if an EObject
is in fact xsi:nill=true while one or more of its (xml-)attributes has been set?
Maybe test that all the features are unset/notset?
Here is an example test.xsd:
<xsd:complexType name="TargetType">
<xsd:sequence>
<xsd:element name="a" type="xsd:string" />
<xsd:choice>
<xsd:element name="b" type="xsd:double"/>
<xsd:element name="c" type="AddressType" nillable="true" maxOccurs="unbounded"/>
</xsd:choice>
<xsd:element name="d" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="AddressType">
<xsd:sequence>
<xsd:element name="zip" type="xsd:integer"/>
</xsd:sequence>
<xsd:attribute name="label" type="xsd:string"/>
</xsd:complexType>
with this xml:
<n1:targetType xmlns:n1="http://www.test.com/">
<a>Hello</a>
<c label="Say" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<c label="Good">
<zip>20190</zip>
</c>
<c label="Bye" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<d>World</d>
</n1:targetType>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
Re: xsi:nil handling in EMF [message #1275139 is a reply to message #1275066] |
Sat, 22 March 2014 11:28  |
Eclipse User |
|
|
|
Martin,
This type of thing is handled poorly. You can see the uses of
org.eclipse.emf.ecore.xmi.impl.XMLHandler.isNull() in that same class.
I think there's the mistaken assumption that it should simply be
represented as a null value in the model (and multi-valued EReferences
can't contain null, so that doesn't work at all).
On 22/03/2014 5:37 AM, Martin Taal wrote:
> Hi,
> I would like to handle an xsd element with xsi:nil which also has
> xml-attributes. Is it possible to detect if an EObject is in fact
> xsi:nill=true while one or more of its (xml-)attributes has been set?
> Maybe test that all the features are unset/notset?
>
> Here is an example test.xsd:
>
> <xsd:complexType name="TargetType">
> <xsd:sequence>
> <xsd:element name="a" type="xsd:string" />
> <xsd:choice>
> <xsd:element name="b" type="xsd:double"/>
> <xsd:element name="c" type="AddressType" nillable="true"
> maxOccurs="unbounded"/>
> </xsd:choice>
> <xsd:element name="d" type="xsd:string" />
> </xsd:sequence>
> </xsd:complexType>
>
> <xsd:complexType name="AddressType">
> <xsd:sequence>
> <xsd:element name="zip" type="xsd:integer"/>
> </xsd:sequence>
> <xsd:attribute name="label" type="xsd:string"/>
> </xsd:complexType>
>
> with this xml:
> <n1:targetType xmlns:n1="http://www.test.com/">
> <a>Hello</a>
> <c label="Say" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:nil="true" />
> <c label="Good">
> <zip>20190</zip>
> </c>
> <c label="Bye" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:nil="true" />
> <d>World</d>
> </n1:targetType>
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.07074 seconds