Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Creating Link in XSD
Creating Link in XSD [message #74077] Mon, 07 April 2008 10:18 Go to next message
Eclipse User
Originally posted by: Nicolas.Dufault.techsolcom.ca

Hi,

I'm currently writing an XSD file in order to input it in the reflective
GMF tool...

So basically I want to write my XSD and from it automaticaly generate my
diagram and the editor for it.

I'm pretty sure to do it the right way but all links between classes don't
show up. Only the aggregation between my VueTop and the two others are
working but between the class "Middle" and "Small" nothing works.

I use the mindmap.xsd as example, which works fine.

Maybe you could help me.

Titan.xsd is the name of my file.
Here's my file.

********************************
********** TITAN.XSD ***********

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="/reflective.Xsd/model/XsdClassic/titan"
xmlns:titan="/reflective.Xsd/model/XsdClassic/titan"
ecore:nsPrefix="titan" ecore:package="titan"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">

<xsd:element name="vueTop" type="titan:VueTop"/>

<xsd:complexType ecore:instanceClass="com.reflective.ecore2Xsd.VueTop"
name="VueTop">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="middlez"
type="titan:Middle"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="smallz"
type="titan:Small"/>
<xsd:element name="title" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType ecore:instanceClass="com.reflective.ecore2Xsd.Middle"
name="Middle">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="email" type="xsd:string"/>
<xsd:element ecore:opposite="middles"
ecore:reference="titan:Small" name="smalls" type="xsd:anyURI"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType ecore:instanceClass="com.reflective.ecore2Xsd.Small"
name="Small">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="address" type="xsd:string"/>
<xsd:element ecore:opposite="smalls"
ecore:reference="titan:Middle" name="middles" type="xsd:anyURI"/>
</xsd:sequence>
</xsd:complexType>

</xsd:schema>

******************************

Here is a part of the mindmap.xsd example:
I remove some classes to make it shorter.


********************************
********* MINDMAP.XSD **********

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="http://www.example.org/mindmap"
xmlns:mindmap="http://www.example.org/mindmap"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">

<xsd:element name="map" type="mindmap:Map"/>

<xsd:complexType name="Map">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="rootTopics"
type="mindmap:Topic"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="relations"
type="mindmap:Relationship"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="resources"
type="mindmap:Resource"/>
</xsd:sequence>
<xsd:attribute name="title" type="xsd:string"/>
</xsd:complexType>

<xsd:complexType name="Topic">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="comments"
type="mindmap:Thread"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute ecore:reference="mindmap:Topic" name="subtopics">
<xsd:simpleType>
<xsd:list itemType="xsd:anyURI"/>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute ecore:opposite="topics"
ecore:reference="mindmap:Resource" name="resources">
<xsd:simpleType>
<xsd:list itemType="xsd:anyURI"/>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="percentComplete" type="xsd:float"/>
<xsd:attribute name="priority" type="mindmap:Priority"/>
<xsd:attribute name="startDate" type="xsd:date"/>
<xsd:attribute name="endDate" type="xsd:date"/>
<xsd:attribute default="0" name="duration" type="xsd:float"/>
</xsd:complexType>

<xsd:complexType name="Resource">
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute ecore:opposite="resources"
ecore:reference="mindmap:Topic" name="topics">
<xsd:simpleType>
<xsd:list itemType="xsd:anyURI"/>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="email" type="xsd:string"/>
<xsd:attribute ecore:opposite="author"
ecore:reference="mindmap:Thread" name="comments">
<xsd:simpleType>
<xsd:list itemType="xsd:anyURI"/>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>

</xsd:schema>

*****************************************************

Thanks for your help !

Nicolas
Re: Creating Link in XSD [message #74097 is a reply to message #74077] Mon, 07 April 2008 10:55 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

Nick,

The Ecore model looks okay when I import it. Note that there is no
aggregation relation between Small and Middle because you've made the
reference be a non-containment reference. I'm also not sure you really
want those ecore:instanceClassName annotations either; what purpose do
they serve in this scenario? (I.e., do you really have existing
interfaces for these?)


NickDuff wrote:
> Hi,
>
> I'm currently writing an XSD file in order to input it in the
> reflective GMF tool...
> So basically I want to write my XSD and from it automaticaly generate
> my diagram and the editor for it.
>
> I'm pretty sure to do it the right way but all links between classes
> don't show up. Only the aggregation between my VueTop and the two
> others are working but between the class "Middle" and "Small" nothing
> works.
>
> I use the mindmap.xsd as example, which works fine.
>
> Maybe you could help me.
>
> Titan.xsd is the name of my file.
> Here's my file.
>
> ********************************
> ********** TITAN.XSD ***********
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema targetNamespace="/reflective.Xsd/model/XsdClassic/titan"
> xmlns:titan="/reflective.Xsd/model/XsdClassic/titan"
> ecore:nsPrefix="titan" ecore:package="titan"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
>
> <xsd:element name="vueTop" type="titan:VueTop"/>
> <xsd:complexType
> ecore:instanceClass="com.reflective.ecore2Xsd.VueTop" name="VueTop">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" minOccurs="0"
> name="middlez" type="titan:Middle"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0"
> name="smallz" type="titan:Small"/>
> <xsd:element name="title" type="xsd:string"/>
> </xsd:sequence>
> </xsd:complexType> <xsd:complexType
> ecore:instanceClass="com.reflective.ecore2Xsd.Middle" name="Middle">
> <xsd:sequence>
> <xsd:element name="name" type="xsd:string"/>
> <xsd:element name="email" type="xsd:string"/>
> <xsd:element ecore:opposite="middles"
> ecore:reference="titan:Small" name="smalls" type="xsd:anyURI"/>
> </xsd:sequence>
> </xsd:complexType>
>
> <xsd:complexType
> ecore:instanceClass="com.reflective.ecore2Xsd.Small" name="Small">
> <xsd:sequence>
> <xsd:element name="name" type="xsd:string"/>
> <xsd:element name="address" type="xsd:string"/>
> <xsd:element ecore:opposite="smalls"
> ecore:reference="titan:Middle" name="middles" type="xsd:anyURI"/>
> </xsd:sequence>
> </xsd:complexType>
>
> </xsd:schema>
> ******************************
>
> Here is a part of the mindmap.xsd example:
> I remove some classes to make it shorter.
>
>
> ********************************
> ********* MINDMAP.XSD **********
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema targetNamespace="http://www.example.org/mindmap"
> xmlns:mindmap="http://www.example.org/mindmap"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
>
> <xsd:element name="map" type="mindmap:Map"/>
>
> <xsd:complexType name="Map">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" minOccurs="0"
> name="rootTopics" type="mindmap:Topic"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="relations"
> type="mindmap:Relationship"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="resources"
> type="mindmap:Resource"/>
> </xsd:sequence>
> <xsd:attribute name="title" type="xsd:string"/>
> </xsd:complexType>
>
> <xsd:complexType name="Topic">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="comments"
> type="mindmap:Thread"/>
> </xsd:sequence>
> <xsd:attribute name="name" type="xsd:string"/>
> <xsd:attribute ecore:reference="mindmap:Topic" name="subtopics">
> <xsd:simpleType>
> <xsd:list itemType="xsd:anyURI"/>
> </xsd:simpleType>
> </xsd:attribute>
> <xsd:attribute ecore:opposite="topics"
> ecore:reference="mindmap:Resource" name="resources">
> <xsd:simpleType>
> <xsd:list itemType="xsd:anyURI"/>
> </xsd:simpleType>
> </xsd:attribute>
> <xsd:attribute name="percentComplete" type="xsd:float"/>
> <xsd:attribute name="priority" type="mindmap:Priority"/>
> <xsd:attribute name="startDate" type="xsd:date"/>
> <xsd:attribute name="endDate" type="xsd:date"/>
> <xsd:attribute default="0" name="duration" type="xsd:float"/>
> </xsd:complexType>
>
> <xsd:complexType name="Resource">
> <xsd:attribute name="name" type="xsd:string"/>
> <xsd:attribute ecore:opposite="resources"
> ecore:reference="mindmap:Topic" name="topics">
> <xsd:simpleType>
> <xsd:list itemType="xsd:anyURI"/>
> </xsd:simpleType>
> </xsd:attribute>
> <xsd:attribute name="email" type="xsd:string"/>
> <xsd:attribute ecore:opposite="author"
> ecore:reference="mindmap:Thread" name="comments">
> <xsd:simpleType>
> <xsd:list itemType="xsd:anyURI"/>
> </xsd:simpleType>
> </xsd:attribute>
> </xsd:complexType>
>
> </xsd:schema>
>
> *****************************************************
>
> Thanks for your help !
>
> Nicolas
>
Re: Creating Link in XSD [message #74114 is a reply to message #74097] Mon, 07 April 2008 12:10 Go to previous messageGo to next message
Eclipse User
Originally posted by: Nicolas.Dufault.techsolcom.ca

Actually, when I create a diagram from a GenModel and Ecore with this XSD
it’s works fine.

But, I don’t want to use the genmodel process to generate my new “titan”
plugin in order to add artefact to my meta-model.

The mindmap.xsd that I used, which is posted in this thread, works fine.
My first iteration was to build this code: (almost identical to the most
already posted but I found it more clean)

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="/reflective.ecore2Xsd/model/XsdClassic/titan "
xmlns:titan="/reflective.ecore2Xsd/model/XsdClassic/titan"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">

<xsd:element name="vueTop" type="titan:VueTop"/>

<xsd:complexType name="VueTop">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="middlez"
type="titan:Middle"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="smallz"
type="titan:Small"/>
</xsd:sequence>
<xsd:attribute name="title" type="xsd:string"/>
</xsd:complexType>

<xsd:complexType name="Middle">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0"
name="link-4-Middle" type="titan:Small"/>
</xsd:sequence>
<xsd:attribute ecore:opposite="middles" ecore:reference="titan:Small"
name="smalls">
<xsd:simpleType>
<xsd:list itemType="xsd:anyURI"/>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="email" type="xsd:string"/>
</xsd:complexType>

<xsd:complexType name="Small">
<xsd:attribute ecore:opposite="smalls" ecore:reference="titan:Middle"
name="middles">
<xsd:simpleType>
<xsd:list itemType="xsd:anyURI"/>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="address" type="xsd:string"/>
</xsd:complexType>

</xsd:schema>


I think I don’t have any error linking the two classes.
I added the :

<xsd:complexType name="VueTop">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="middlez"
type="titan:Middle"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="smallz"
type="titan:Small"/>
</xsd:sequence>
<xsd:attribute name="title" type="xsd:string"/>
</xsd:complexType>

To my VueTop class which make it the parent of my aggregation. I didn’t
have to specify any containment=true. I’m doing the same think in my class
“Middle” and it didn’t work. I didn’t find in the docs where I have to put
anything to make it work. ?!

I”m using this doc:
http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf

I understood that when I added the “ecore:reference » to my attribute, it
was setting automatically my reference and then showing my reference link
in my diagram. But it didn’t.
Thanks for your time.

NickDuff
Re: Creating Link in XSD [message #74132 is a reply to message #74114] Mon, 07 April 2008 14:06 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

Nick,

Comments below.


NickDuff wrote:
> Actually, when I create a diagram from a GenModel and Ecore with this
> XSD it�s works fine.
That's what I figured.
> But, I don�t want to use the genmodel process to generate my new
> �titan� plugin in order to add artefact to my meta-model.
I don't quite get this part then... What do you want to use.
> The mindmap.xsd that I used, which is posted in this thread, works fine.
I'm not sure what the "it" is that worked fine. If "it" has something to
do with GMF though, it's best to ask on the GMF newsgroup about it. Here
I can only explain the mapping between XML Schema and Ecore, not who GMF
behaves once you get that far.
> My first iteration was to build this code: (almost identical to the
> most already posted but I found it more clean)
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema
> targetNamespace="/reflective.ecore2Xsd/model/XsdClassic/titan "
> xmlns:titan="/reflective.ecore2Xsd/model/XsdClassic/titan"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
> <xsd:element name="vueTop" type="titan:VueTop"/>
> <xsd:complexType name="VueTop">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="middlez"
> type="titan:Middle"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="smallz"
> type="titan:Small"/>
> </xsd:sequence>
> <xsd:attribute name="title" type="xsd:string"/>
> </xsd:complexType>
>
> <xsd:complexType name="Middle">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="link-4-Middle"
> type="titan:Small"/>
> </xsd:sequence>
> <xsd:attribute ecore:opposite="middles" ecore:reference="titan:Small"
> name="smalls">
> <xsd:simpleType>
> <xsd:list itemType="xsd:anyURI"/>
> </xsd:simpleType>
> </xsd:attribute>
> <xsd:attribute name="name" type="xsd:string"/>
> <xsd:attribute name="email" type="xsd:string"/>
> </xsd:complexType>
>
> <xsd:complexType name="Small">
> <xsd:attribute ecore:opposite="smalls" ecore:reference="titan:Middle"
> name="middles">
> <xsd:simpleType>
> <xsd:list itemType="xsd:anyURI"/>
> </xsd:simpleType>
> </xsd:attribute>
> <xsd:attribute name="name" type="xsd:string"/>
> <xsd:attribute name="address" type="xsd:string"/>
> </xsd:complexType>
>
> </xsd:schema>
>
> I think I don�t have any error linking the two classes. I added the :
>
> <xsd:complexType name="VueTop">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="middlez"
> type="titan:Middle"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="smallz"
> type="titan:Small"/>
> </xsd:sequence>
> <xsd:attribute name="title" type="xsd:string"/>
> </xsd:complexType>
>
> To my VueTop class which make it the parent of my aggregation. I
> didn�t have to specify any containment=true.
Elements of complex type will automatically become containment
references. Using anyURI/IDREF along with ecore:reference are for
specifying non-containment references.
> I�m doing the same think in my class �Middle� and it didn�t work.
No, in Middle you are creating a non-containment bidirectional
references between Middle and Small.
> I didn�t find in the docs where I have to put anything to make it work. ?!
It's not clear what "it" is though. What isn't working?
>
>
> I�m using this doc:
> http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf
>
>
> I understood that when I added the �ecore:reference » to my attribute,
> it was setting automatically my reference and then showing my
> reference link in my diagram. But it didn�t.
It does create a non-containment reference. I can't comment how how
that's rendered in your diagram. That's a GMF question that's best asked
on the GMF newsgroup...
> Thanks for your time.
>
> NickDuff
>
>
Re: Creating Link in XSD [message #74150 is a reply to message #74132] Tue, 08 April 2008 10:30 Go to previous messageGo to next message
Eclipse User
Originally posted by: Nicolas.Dufault.techsolcom.ca

Hi,

Ok, I make "it" works.
The "it" is the process by which I am able to generate a diagram from a
XSD at the runtime with all my reference and containment links showed up
and working.

The problem was my schema.

<xsd:schema targetNamespace="/reflective.ecore2Xsd/model/XsdClassic/titan "
xmlns:titan="/reflective.ecore2Xsd/model/XsdClassic/titan"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
<xsd:element name="vueTop" type="titan:VueTop"/>

At the beginning, I wrote it as below and I wasn't able to open my dynamic
diagrams. I changed it to the xsd:schema that you see at the top and "it"
worked but not my links. I didn't really understand the goal to have the
"www.example.org/..." so I tried to change it back and it worked.

<xsd:schema
targetNamespace="http://www.example.org/titan"
xmlns:titan="http://www.example.org/titan"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">

So thanks for your help and if you have extra explanation about why the
"www.example.org/..." is mandatory it would be nice.

Thanks,
NickDuff
Re: Creating Link in XSD [message #74168 is a reply to message #74150] Tue, 08 April 2008 10:45 Go to previous message
Eclipse User
Originally posted by: merks.ca.ibm.com

Nick,

The target namespace is just an arbitrary URI. I'm not sure what impact
it has... At least on the EMF end of things, this had no impact.
Perhaps you stumbled into some GMF but which assumed the namespace would
be an absolute URI...


NickDuff wrote:
> Hi,
>
> Ok, I make "it" works.
> The "it" is the process by which I am able to generate a diagram from
> a XSD at the runtime with all my reference and containment links
> showed up and working.
>
> The problem was my schema.
>
> <xsd:schema
> targetNamespace="/reflective.ecore2Xsd/model/XsdClassic/titan "
> xmlns:titan="/reflective.ecore2Xsd/model/XsdClassic/titan"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
> <xsd:element name="vueTop" type="titan:VueTop"/>
>
> At the beginning, I wrote it as below and I wasn't able to open my
> dynamic diagrams. I changed it to the xsd:schema that you see at the
> top and "it" worked but not my links. I didn't really understand the
> goal to have the "www.example.org/..." so I tried to change it back
> and it worked.
>
> <xsd:schema
> targetNamespace="http://www.example.org/titan"
> xmlns:titan="http://www.example.org/titan"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
>
> So thanks for your help and if you have extra explanation about why
> the "www.example.org/..." is mandatory it would be nice.
>
> Thanks,
> NickDuff
>
>
>
Re: Creating Link in XSD [message #602943 is a reply to message #74077] Mon, 07 April 2008 10:55 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25946
Registered: July 2009
Senior Member
Nick,

The Ecore model looks okay when I import it. Note that there is no
aggregation relation between Small and Middle because you've made the
reference be a non-containment reference. I'm also not sure you really
want those ecore:instanceClassName annotations either; what purpose do
they serve in this scenario? (I.e., do you really have existing
interfaces for these?)


NickDuff wrote:
> Hi,
>
> I'm currently writing an XSD file in order to input it in the
> reflective GMF tool...
> So basically I want to write my XSD and from it automaticaly generate
> my diagram and the editor for it.
>
> I'm pretty sure to do it the right way but all links between classes
> don't show up. Only the aggregation between my VueTop and the two
> others are working but between the class "Middle" and "Small" nothing
> works.
>
> I use the mindmap.xsd as example, which works fine.
>
> Maybe you could help me.
>
> Titan.xsd is the name of my file.
> Here's my file.
>
> ********************************
> ********** TITAN.XSD ***********
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema targetNamespace="/reflective.Xsd/model/XsdClassic/titan"
> xmlns:titan="/reflective.Xsd/model/XsdClassic/titan"
> ecore:nsPrefix="titan" ecore:package="titan"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
>
> <xsd:element name="vueTop" type="titan:VueTop"/>
> <xsd:complexType
> ecore:instanceClass="com.reflective.ecore2Xsd.VueTop" name="VueTop">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" minOccurs="0"
> name="middlez" type="titan:Middle"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0"
> name="smallz" type="titan:Small"/>
> <xsd:element name="title" type="xsd:string"/>
> </xsd:sequence>
> </xsd:complexType> <xsd:complexType
> ecore:instanceClass="com.reflective.ecore2Xsd.Middle" name="Middle">
> <xsd:sequence>
> <xsd:element name="name" type="xsd:string"/>
> <xsd:element name="email" type="xsd:string"/>
> <xsd:element ecore:opposite="middles"
> ecore:reference="titan:Small" name="smalls" type="xsd:anyURI"/>
> </xsd:sequence>
> </xsd:complexType>
>
> <xsd:complexType
> ecore:instanceClass="com.reflective.ecore2Xsd.Small" name="Small">
> <xsd:sequence>
> <xsd:element name="name" type="xsd:string"/>
> <xsd:element name="address" type="xsd:string"/>
> <xsd:element ecore:opposite="smalls"
> ecore:reference="titan:Middle" name="middles" type="xsd:anyURI"/>
> </xsd:sequence>
> </xsd:complexType>
>
> </xsd:schema>
> ******************************
>
> Here is a part of the mindmap.xsd example:
> I remove some classes to make it shorter.
>
>
> ********************************
> ********* MINDMAP.XSD **********
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema targetNamespace="http://www.example.org/mindmap"
> xmlns:mindmap="http://www.example.org/mindmap"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
>
> <xsd:element name="map" type="mindmap:Map"/>
>
> <xsd:complexType name="Map">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" minOccurs="0"
> name="rootTopics" type="mindmap:Topic"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="relations"
> type="mindmap:Relationship"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="resources"
> type="mindmap:Resource"/>
> </xsd:sequence>
> <xsd:attribute name="title" type="xsd:string"/>
> </xsd:complexType>
>
> <xsd:complexType name="Topic">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="comments"
> type="mindmap:Thread"/>
> </xsd:sequence>
> <xsd:attribute name="name" type="xsd:string"/>
> <xsd:attribute ecore:reference="mindmap:Topic" name="subtopics">
> <xsd:simpleType>
> <xsd:list itemType="xsd:anyURI"/>
> </xsd:simpleType>
> </xsd:attribute>
> <xsd:attribute ecore:opposite="topics"
> ecore:reference="mindmap:Resource" name="resources">
> <xsd:simpleType>
> <xsd:list itemType="xsd:anyURI"/>
> </xsd:simpleType>
> </xsd:attribute>
> <xsd:attribute name="percentComplete" type="xsd:float"/>
> <xsd:attribute name="priority" type="mindmap:Priority"/>
> <xsd:attribute name="startDate" type="xsd:date"/>
> <xsd:attribute name="endDate" type="xsd:date"/>
> <xsd:attribute default="0" name="duration" type="xsd:float"/>
> </xsd:complexType>
>
> <xsd:complexType name="Resource">
> <xsd:attribute name="name" type="xsd:string"/>
> <xsd:attribute ecore:opposite="resources"
> ecore:reference="mindmap:Topic" name="topics">
> <xsd:simpleType>
> <xsd:list itemType="xsd:anyURI"/>
> </xsd:simpleType>
> </xsd:attribute>
> <xsd:attribute name="email" type="xsd:string"/>
> <xsd:attribute ecore:opposite="author"
> ecore:reference="mindmap:Thread" name="comments">
> <xsd:simpleType>
> <xsd:list itemType="xsd:anyURI"/>
> </xsd:simpleType>
> </xsd:attribute>
> </xsd:complexType>
>
> </xsd:schema>
>
> *****************************************************
>
> Thanks for your help !
>
> Nicolas
>
Re: Creating Link in XSD [message #602948 is a reply to message #74097] Mon, 07 April 2008 12:10 Go to previous message
Eclipse User
Originally posted by: Nicolas.Dufault.techsolcom.ca

Actually, when I create a diagram from a GenModel and Ecore with this XSD
it’s works fine.

But, I don’t want to use the genmodel process to generate my new “titan”
plugin in order to add artefact to my meta-model.

The mindmap.xsd that I used, which is posted in this thread, works fine.
My first iteration was to build this code: (almost identical to the most
already posted but I found it more clean)

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="/reflective.ecore2Xsd/model/XsdClassic/titan "
xmlns:titan="/reflective.ecore2Xsd/model/XsdClassic/titan"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">

<xsd:element name="vueTop" type="titan:VueTop"/>

<xsd:complexType name="VueTop">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="middlez"
type="titan:Middle"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="smallz"
type="titan:Small"/>
</xsd:sequence>
<xsd:attribute name="title" type="xsd:string"/>
</xsd:complexType>

<xsd:complexType name="Middle">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0"
name="link-4-Middle" type="titan:Small"/>
</xsd:sequence>
<xsd:attribute ecore:opposite="middles" ecore:reference="titan:Small"
name="smalls">
<xsd:simpleType>
<xsd:list itemType="xsd:anyURI"/>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="email" type="xsd:string"/>
</xsd:complexType>

<xsd:complexType name="Small">
<xsd:attribute ecore:opposite="smalls" ecore:reference="titan:Middle"
name="middles">
<xsd:simpleType>
<xsd:list itemType="xsd:anyURI"/>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="address" type="xsd:string"/>
</xsd:complexType>

</xsd:schema>


I think I don’t have any error linking the two classes.
I added the :

<xsd:complexType name="VueTop">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="middlez"
type="titan:Middle"/>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="smallz"
type="titan:Small"/>
</xsd:sequence>
<xsd:attribute name="title" type="xsd:string"/>
</xsd:complexType>

To my VueTop class which make it the parent of my aggregation. I didn’t
have to specify any containment=true. I’m doing the same think in my class
“Middle” and it didn’t work. I didn’t find in the docs where I have to put
anything to make it work. ?!

I”m using this doc:
http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf

I understood that when I added the “ecore:reference » to my attribute, it
was setting automatically my reference and then showing my reference link
in my diagram. But it didn’t.
Thanks for your time.

NickDuff
Re: Creating Link in XSD [message #602953 is a reply to message #74114] Mon, 07 April 2008 14:06 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25946
Registered: July 2009
Senior Member
Nick,

Comments below.


NickDuff wrote:
> Actually, when I create a diagram from a GenModel and Ecore with this
> XSD it�s works fine.
That's what I figured.
> But, I don�t want to use the genmodel process to generate my new
> �titan� plugin in order to add artefact to my meta-model.
I don't quite get this part then... What do you want to use.
> The mindmap.xsd that I used, which is posted in this thread, works fine.
I'm not sure what the "it" is that worked fine. If "it" has something to
do with GMF though, it's best to ask on the GMF newsgroup about it. Here
I can only explain the mapping between XML Schema and Ecore, not who GMF
behaves once you get that far.
> My first iteration was to build this code: (almost identical to the
> most already posted but I found it more clean)
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema
> targetNamespace="/reflective.ecore2Xsd/model/XsdClassic/titan "
> xmlns:titan="/reflective.ecore2Xsd/model/XsdClassic/titan"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
> <xsd:element name="vueTop" type="titan:VueTop"/>
> <xsd:complexType name="VueTop">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="middlez"
> type="titan:Middle"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="smallz"
> type="titan:Small"/>
> </xsd:sequence>
> <xsd:attribute name="title" type="xsd:string"/>
> </xsd:complexType>
>
> <xsd:complexType name="Middle">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="link-4-Middle"
> type="titan:Small"/>
> </xsd:sequence>
> <xsd:attribute ecore:opposite="middles" ecore:reference="titan:Small"
> name="smalls">
> <xsd:simpleType>
> <xsd:list itemType="xsd:anyURI"/>
> </xsd:simpleType>
> </xsd:attribute>
> <xsd:attribute name="name" type="xsd:string"/>
> <xsd:attribute name="email" type="xsd:string"/>
> </xsd:complexType>
>
> <xsd:complexType name="Small">
> <xsd:attribute ecore:opposite="smalls" ecore:reference="titan:Middle"
> name="middles">
> <xsd:simpleType>
> <xsd:list itemType="xsd:anyURI"/>
> </xsd:simpleType>
> </xsd:attribute>
> <xsd:attribute name="name" type="xsd:string"/>
> <xsd:attribute name="address" type="xsd:string"/>
> </xsd:complexType>
>
> </xsd:schema>
>
> I think I don�t have any error linking the two classes. I added the :
>
> <xsd:complexType name="VueTop">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="middlez"
> type="titan:Middle"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0" name="smallz"
> type="titan:Small"/>
> </xsd:sequence>
> <xsd:attribute name="title" type="xsd:string"/>
> </xsd:complexType>
>
> To my VueTop class which make it the parent of my aggregation. I
> didn�t have to specify any containment=true.
Elements of complex type will automatically become containment
references. Using anyURI/IDREF along with ecore:reference are for
specifying non-containment references.
> I�m doing the same think in my class �Middle� and it didn�t work.
No, in Middle you are creating a non-containment bidirectional
references between Middle and Small.
> I didn�t find in the docs where I have to put anything to make it work. ?!
It's not clear what "it" is though. What isn't working?
>
>
> I�m using this doc:
> http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchema ToEcoreMapping.pdf
>
>
> I understood that when I added the �ecore:reference » to my attribute,
> it was setting automatically my reference and then showing my
> reference link in my diagram. But it didn�t.
It does create a non-containment reference. I can't comment how how
that's rendered in your diagram. That's a GMF question that's best asked
on the GMF newsgroup...
> Thanks for your time.
>
> NickDuff
>
>
Re: Creating Link in XSD [message #602958 is a reply to message #74132] Tue, 08 April 2008 10:30 Go to previous message
Eclipse User
Originally posted by: Nicolas.Dufault.techsolcom.ca

Hi,

Ok, I make "it" works.
The "it" is the process by which I am able to generate a diagram from a
XSD at the runtime with all my reference and containment links showed up
and working.

The problem was my schema.

<xsd:schema targetNamespace="/reflective.ecore2Xsd/model/XsdClassic/titan "
xmlns:titan="/reflective.ecore2Xsd/model/XsdClassic/titan"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
<xsd:element name="vueTop" type="titan:VueTop"/>

At the beginning, I wrote it as below and I wasn't able to open my dynamic
diagrams. I changed it to the xsd:schema that you see at the top and "it"
worked but not my links. I didn't really understand the goal to have the
"www.example.org/..." so I tried to change it back and it worked.

<xsd:schema
targetNamespace="http://www.example.org/titan"
xmlns:titan="http://www.example.org/titan"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">

So thanks for your help and if you have extra explanation about why the
"www.example.org/..." is mandatory it would be nice.

Thanks,
NickDuff
Re: Creating Link in XSD [message #602963 is a reply to message #74150] Tue, 08 April 2008 10:45 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25946
Registered: July 2009
Senior Member
Nick,

The target namespace is just an arbitrary URI. I'm not sure what impact
it has... At least on the EMF end of things, this had no impact.
Perhaps you stumbled into some GMF but which assumed the namespace would
be an absolute URI...


NickDuff wrote:
> Hi,
>
> Ok, I make "it" works.
> The "it" is the process by which I am able to generate a diagram from
> a XSD at the runtime with all my reference and containment links
> showed up and working.
>
> The problem was my schema.
>
> <xsd:schema
> targetNamespace="/reflective.ecore2Xsd/model/XsdClassic/titan "
> xmlns:titan="/reflective.ecore2Xsd/model/XsdClassic/titan"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
> <xsd:element name="vueTop" type="titan:VueTop"/>
>
> At the beginning, I wrote it as below and I wasn't able to open my
> dynamic diagrams. I changed it to the xsd:schema that you see at the
> top and "it" worked but not my links. I didn't really understand the
> goal to have the "www.example.org/..." so I tried to change it back
> and it worked.
>
> <xsd:schema
> targetNamespace="http://www.example.org/titan"
> xmlns:titan="http://www.example.org/titan"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
>
> So thanks for your help and if you have extra explanation about why
> the "www.example.org/..." is mandatory it would be nice.
>
> Thanks,
> NickDuff
>
>
>
Previous Topic:Creating Link in XSD
Next Topic:Boolean Attributes
Goto Forum:
  


Current Time: Wed Jul 30 23:39:02 EDT 2014

Powered by FUDForum. Page generated in 0.06467 seconds