Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » xsi:nil handling in EMF
xsi:nil handling in EMF [message #1275066] Sat, 22 March 2014 12:37 Go to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
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 15:28 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33139
Registered: July 2009
Senior Member
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>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO] Help with "rollback" approach, advice/best practices needed
Next Topic:[Oomph] (Some) Imported projects not 'connected' to git
Goto Forum:
  


Current Time: Tue Apr 23 07:53:04 GMT 2024

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

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

Back to the top