Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » De-serialization of complex two-model instance(Deserialize xs:any that contains another model instances)
icon9.gif  De-serialization of complex two-model instance [message #558673] Mon, 13 September 2010 21:13 Go to next message
Renat Zubairov is currently offline Renat ZubairovFriend
Messages: 30
Registered: July 2009
Member
I am trying to de-seralize a complex XML document that contains from envelope and multiple individual messages inside it. Envelope has it's own schema and ecore model generated from it, as well as payload (message) also has a schema and dynamically loaded ecore model (I have a custom delegating EPackage.Registry instance registered to ResourceSet).

So in my envelope schema I have:


<complexType name="interchangeMessageType" mixed="false">
<sequence>
...
<any maxOccurs="1" minOccurs="1" namespace="##any" processContents="lax" ecore:name="message" smooks:type="group"/>
...
</sequence>
</complexType>


And in my XML I have:


<?xml version="1.0" encoding="UTF-8"?>
<env:unEdifact xmlns:env="http://smooks.org/EDIFACT/41/Envelope">
<env:UNB>...
<env:interchangeMessage>

<ns1:CUSCAR xmlns:ns1="http://smooks.org/UNEDI/D99AUN/CUSCAR">
<ns1:Beginning_of_message>
...

All packages and namespaces are correctly resolved.

So I would expect in my de-seralized model reference from InterchangeMessageType#getMessage() that would return me (directly of via featuremap) a dynamic ECORE class from my CUSCAR model, however I only get allot of nested AnyTypes/FeatureMaps where features are correct, but types are all AnyType.

What do I do wrong?

Renat

P.S. Schema: https://svn.codehaus.org/milyn/workspaces/zubairov/edi/ecore /model/EDIEnvelope.xsd
Model after schema: https://svn.codehaus.org/milyn/workspaces/zubairov/edi/ecore /model/
Dynamically loaded model: https://svn.codehaus.org/milyn/workspaces/zubairov/edi/ecore /cuscar.ecore
Re: De-serialization of complex two-model instance [message #558690 is a reply to message #558673] Tue, 14 September 2010 02:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30559
Registered: July 2009
Senior Member
Renat,

Comments below.


Renat Zubairov wrote:
> I am trying to de-seralize a complex XML document that contains from
> envelope and multiple individual messages inside it. Envelope has it's
> own schema and ecore model generated from it, as well as payload
> (message) also has a schema and dynamically loaded ecore model (I have
> a custom delegating EPackage.Registry instance registered to
> ResourceSet).
Not sure why you'd need that...
>
> So in my envelope schema I have:
>
>
> <complexType name="interchangeMessageType" mixed="false">
> <sequence>
> ..
> <any maxOccurs="1" minOccurs="1" namespace="##any"
> processContents="lax" ecore:name="message" smooks:type="group"/>
> ..
> </sequence>
> </complexType>
>
>
> And in my XML I have:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <env:unEdifact xmlns:env="http://smooks.org/EDIFACT/41/Envelope">
> <env:UNB>...
> <env:interchangeMessage>
>
> <ns1:CUSCAR xmlns:ns1="http://smooks.org/UNEDI/D99AUN/CUSCAR">
> <ns1:Beginning_of_message>
> ..
>
> All packages and namespaces are correctly resolved.
>
> So I would expect in my de-seralized model reference from
> InterchangeMessageType#getMessage() that would return me (directly of
> via featuremap) a dynamic ECORE class from my CUSCAR model, however I
> only get allot of nested AnyTypes/FeatureMaps where features are
> correct, but types are all AnyType.
That means the combination of namespace and element name is not mapping
to a package with that namespace and a document root with a feature with
that name.
>
> What do I do wrong?
It's hard to say.
>
> Renat
>
> P.S. Schema:
> https://svn.codehaus.org/milyn/workspaces/zubairov/edi/ecore /model/EDIEnvelope.xsd
>
> Model after schema:
> https://svn.codehaus.org/milyn/workspaces/zubairov/edi/ecore /model/
> Dynamically loaded model:
> https://svn.codehaus.org/milyn/workspaces/zubairov/edi/ecore /cuscar.ecore
Is there a package with nsURI http://smooks.org/UNEDI/D99AUN/CUSCAR ?
Re: De-serialization of complex two-model instance [message #558711 is a reply to message #558690] Tue, 14 September 2010 07:50 Go to previous messageGo to next message
Renat Zubairov is currently offline Renat ZubairovFriend
Messages: 30
Registered: July 2009
Member
Hello Ed,

Thnx for quick reply!

> Not sure why you'd need that...

I have around 2000 ecore model which I would like to load on demand, therefore I registered delegating Registry to my resource set that is loading models it's knows about.


>That means the combination of namespace and element name is not mapping
> to a package with that namespace and a document root with a feature with
> that name.

Interesting tip. That mean that in my dynamic ECORE instance I should have a EClass called "DocumentRoot" that should have a feature (reference) with name equal to the name appearing inside my XS:Any elment, right?

That does not however explains why I have not a single instance of my dynaically loaded model, not only root entity but all it's children are replaced with AnyType elements, moreover features are correct --> loaded from dynamic ecore models. Also root feature is correct Sad

I think I found an issue, my DocumentRoot ECclass has Extended Metadata with non-empty "name" detail. I think the problem is that I programmatically creating it. Is there any way to programmatically create it exception ExtendedAnnotation#setDocmentRoot()?

Renat

[Updated on: Tue, 14 September 2010 07:52]

Report message to a moderator

Re: De-serialization of complex two-model instance [message #558824 is a reply to message #558711] Tue, 14 September 2010 14:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30559
Registered: July 2009
Senior Member
Renat,

Comments below.

Renat Zubairov wrote:
> Hello Ed,
>
> Thnx for quick reply!
>
>> Not sure why you'd need that...
>
> I have around 2000 ecore model which I would like to load on demand,
> therefore I registered delegating Registry to my resource set that is
> loading models it's knows about.
You could just register descriptors just like what's done for packagers
registered via plugin.xml.
>
>
>> That means the combination of namespace and element name is not
>> mapping to a package with that namespace and a document root with a
>> feature with that name.
>
> Interesting tip. That mean that in my dynamic ECORE instance I should
> have a EClass called "DocumentRoot" that should have a feature
> (reference) with name equal to the name appearing inside my XS:Any
> elment, right?
It will have to have extended meta data annotations to make it be a
document root. Best to look at a model that's produced from an XML
Schema where you have global element declarations with the right names.
>
> I think I found an issue, my DocumentRoot ECclass has Extended
> Metadata with non-empty "name" detail.
No, that's right. A document root doesn't correspond to any real
complex type in the schema, so it doesn't have a name.
> I think the problem is that I programmatically creating it. Is there
> any way to programmatically create it exception
> ExtendedAnnotation#setDocmentRoot()?
No, I don't think that's the problem. Are you creating it from a schema?
>
> Renat
Re: De-serialization of complex two-model instance [message #558853 is a reply to message #558824] Tue, 14 September 2010 15:39 Go to previous message
Renat Zubairov is currently offline Renat ZubairovFriend
Messages: 30
Registered: July 2009
Member
Hello Ed,

Concerning registering in the EPackage.Descriptor instances in the EPackage.Registry.INSTANCE good idea, will consider that.

The DocumentRoot I construct by hand. In my project I'm using Smooks EDI definition parser to construct ECORE models for UN/EDIFACT definitions. I cleaned up ExtendedMetadata{name} from the DocumentRoot and now I'm getting another exception however I think it went further.

I will write if it work here.

Thnx for your help!

Renat
Previous Topic:[EMF QUERY] How to get result objects, which are not from the type of the FROM clause?
Next Topic:[CDO / Dawn] How to programmatically delete d diagram created with dawn
Goto Forum:
  


Current Time: Wed Oct 23 11:32:59 GMT 2019

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

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

Back to the top