Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » cross-resource containment
cross-resource containment [message #418051] Thu, 03 April 2008 23:05 Go to next message
Will Horn is currently offline Will HornFriend
Messages: 265
Registered: July 2009
Senior Member
I read about this feature on a presentation from 2006 EclipseCon. Is it
possible to specify this through XML Schema?

Normally, I use the following for a cross-document reference:

<xs:element name="abc" type="xs:anyURI" use="required"
ecore:reference="ABC"/>

In most cases in my model, the only reason I do not use containment is
that the referenced objects are big and have separate editors (so they
shouldn't all be in the same Resource). However, it would be nice if
the ABC object could call eContainer() and get access to the parent
nonetheless.

I created an ecore model as described in the presentation and exported
XML Schema for it, where I discovered:

<xsd:element ecore:resolveProxies="true" name="abc" type="ABC"/>

Doesn't this mean that the element will be contained in the xml? The
type is no longer xs:anyURI.

Thanks,
Will
Re: cross-resource containment [message #418055 is a reply to message #418051] Fri, 04 April 2008 10:44 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070606030902000608060204
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Will,

Comments below.


Will Horn wrote:
> I read about this feature on a presentation from 2006 EclipseCon. Is
> it possible to specify this through XML Schema?
>
> Normally, I use the following for a cross-document reference:
>
> <xs:element name="abc" type="xs:anyURI" use="required"
> ecore:reference="ABC"/>
>
> In most cases in my model, the only reason I do not use containment is
> that the referenced objects are big and have separate editors (so they
> shouldn't all be in the same Resource). However, it would be nice if
> the ABC object could call eContainer() and get access to the parent
> nonetheless.
You could instead make it a bidirectional reference. I have an
element/attribute on ABC that's the opposite of this abc feature on X.
>
> I created an ecore model as described in the presentation and exported
> XML Schema for it, where I discovered:
>
> <xsd:element ecore:resolveProxies="true" name="abc" type="ABC"/>
>
> Doesn't this mean that the element will be contained in the xml?
Yes. From a schema point of view, cross resource containment is a
tricky issue because within EMF itself, the object might either be
contained or not; since the serialization will be different in each case
it more like you need to describe both forms of the schema to properly
describe the serialization. So support for cross resource containment
really only focused on the XMI serialization support for it, i.e., being
able to use <abc href="..."/> as the syntax for the cross resource
containment. So while I think the immediately above gives the right
model, I'm not sure that a serialization is produced or consumed
"correctly" when using an XMLResourceImpl with an extended metadata
option...

I'm not sure how best to support something like this with a
serialization accurate schema. To make it work with the existing
framework, you'd have to ensure that you've set the following in the
XMLHandler:

hrefAttribute = XMLResource.HREF;

> The type is no longer xs:anyURI.
>
> Thanks,
> Will


--------------070606030902000608060204
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Will,<br>
<br>
Comments below.<br>
<br>
<br>
Will Horn wrote:
<blockquote cite="mid:ft3nt1$klv$1@build.eclipse.org" type="cite">I
read about this feature on a presentation from 2006 EclipseCon.&nbsp; Is it
possible to specify this through XML Schema?
<br>
<br>
Normally, I use the following for a cross-document reference:
<br>
<br>
&lt;xs:element name="abc" type="xs:anyURI" use="required"
ecore:reference="ABC"/&gt;
<br>
<br>
In most cases in my model, the only reason I do not use containment is
that the referenced objects are big and have separate editors (so they
shouldn't all be in the same Resource).&nbsp; However, it would be nice if
the ABC object could call eContainer() and get access to the parent
nonetheless.
<br>
</blockquote>
You could instead make it a bidirectional reference.&nbsp; I have an
element/attribute on ABC that's the opposite of this abc feature on X.<br>
<blockquote cite="mid:ft3nt1$klv$1@build.eclipse.org" type="cite"><br>
I created an ecore model as described in the presentation and exported
XML Schema for it, where I discovered:
<br>
<br>
&lt;xsd:element ecore:resolveProxies="true" name="abc" type="ABC"/&gt;
<br>
<br>
Doesn't this mean that the element will be contained in the xml?&nbsp; </blockquote>
Yes.&nbsp; From a schema point of view, cross resource containment is a
tricky issue because within EMF itself, the object might either be
contained or not; since the serialization will be different in each
case it more like you need to describe both forms of the schema to
properly describe the serialization.&nbsp; So support for cross resource
containment really only focused on the XMI serialization support for
it, i.e., being able to use &lt;abc href="..."/&gt; as the syntax for
the cross resource containment.&nbsp; So while I think the immediately above
gives the right model, I'm not sure that a serialization is produced or
consumed "correctly" when using an XMLResourceImpl with an extended
metadata option...<br>
<br>
I'm not sure how best to support something like this with a
serialization accurate schema.&nbsp; To make it work with the existing
framework, you'd have to ensure that you've set the following in the
XMLHandler:<br>
<blockquote>hrefAttribute = XMLResource.HREF;<br>
</blockquote>
<blockquote cite="mid:ft3nt1$klv$1@build.eclipse.org" type="cite">The
type is no longer xs:anyURI.
<br>
<br>
Thanks,
<br>
Will
<br>
</blockquote>
<br>
</body>
</html>

--------------070606030902000608060204--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Example for serialization to plain text file
Next Topic:unsettable and required
Goto Forum:
  


Current Time: Thu Apr 25 08:27:05 GMT 2024

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

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

Back to the top