|
Re: xsi:nil handling in EMF [message #1275139 is a reply to message #1275066] |
Sat, 22 March 2014 15:28 |
Ed Merks 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/
|
|
|
Powered by
FUDForum. Page generated in 0.03172 seconds