XSD Question: maps in XSD [message #402424] |
Thu, 13 July 2006 16:18 |
Eclipse User |
|
|
|
Originally posted by: philipp.kutter.org
Hi, All.
I have an XSD Schema with instances of Type A.
Now I would like to add a map, from A to A, where the key is a
refrerence, and the value is a containment.
I know how to do this in Java and in ECore, but not in XSD.
When I tried to load from the generated XSD fragment:
<xsd:complexType name="XMLToXMLMapEntry">
<xsd:choice maxOccurs="unbounded" minOccurs="0">
<xsd:element name="key" type="mtgDecoration:MXmlElement"/>
<xsd:element name="value" type="mtgDecoration:MXmlElement"/>
<xsd:element ref="xmi:Extension"/>
</xsd:choice>
<xsd:attribute ref="xmi:id"/>
<xsd:attributeGroup ref="xmi:ObjectAttribs"/>
<xsd:attribute name="key" type="xsd:string"/>
<xsd:attribute name="value" type="xsd:string"/>
</xsd:complexType>
It did not work, and it looks overly complex.
Is there any built in support in EMF/XSD for this?
Best Regards, Philipp
|
|
|
Re: XSD Question: maps in XSD [message #402428 is a reply to message #402424] |
Thu, 13 July 2006 16:39 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------060307060603090902040505
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Philipp,
Here's what Ecore.xsd looks like:
<xsd:complexType name="EAnnotation">
<xsd:complexContent>
<xsd:extension base="ecore:EModelElement">
<xsd:sequence>
*<xsd:element maxOccurs="unbounded" minOccurs="0"
name="details" type="ecore:EStringToStringMapEntry"/>*
<xsd:element maxOccurs="unbounded" minOccurs="0" name="contents"/>
</xsd:sequence>
<xsd:attribute name="source" type="ecore:EString"/>
<xsd:attribute ecore:opposite="eAnnotations"
ecore:reference="ecore:EModelElement" ecore:transient="true"
name="eModelElement" type="xsd:IDREF"/>
<xsd:attribute ecore:reference="xsd:anyType" name="references">
<xsd:simpleType>
<xsd:list itemType="xsd:anyURI"/>
</xsd:simpleType>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
* <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
name="EStringToStringMapEntry">
<xsd:attribute name="key" type="ecore:EString"/>
<xsd:attribute name="value" type="ecore:EString"/>
</xsd:complexType> *
If you know how to do it in Ecore, you can try exporting the .ecore to
an XML Schema and see what it produces. I've tried to make the Ecore ->
XML Schema -> Ecore be as roundtrippable as possible...
Philipp W. Kutter wrote:
> Hi, All.
> I have an XSD Schema with instances of Type A.
>
> Now I would like to add a map, from A to A, where the key is a
> refrerence, and the value is a containment.
>
> I know how to do this in Java and in ECore, but not in XSD.
>
> When I tried to load from the generated XSD fragment:
>
> <xsd:complexType name="XMLToXMLMapEntry">
> <xsd:choice maxOccurs="unbounded" minOccurs="0">
> <xsd:element name="key" type="mtgDecoration:MXmlElement"/>
> <xsd:element name="value" type="mtgDecoration:MXmlElement"/>
> <xsd:element ref="xmi:Extension"/>
> </xsd:choice>
> <xsd:attribute ref="xmi:id"/>
> <xsd:attributeGroup ref="xmi:ObjectAttribs"/>
> <xsd:attribute name="key" type="xsd:string"/>
> <xsd:attribute name="value" type="xsd:string"/>
> </xsd:complexType>
>
> It did not work, and it looks overly complex.
>
> Is there any built in support in EMF/XSD for this?
>
> Best Regards, Philipp
>
--------------060307060603090902040505
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">
Philipp,<br>
<br>
Here's what Ecore.xsd looks like:<br>
<small><br>
<xsd:complexType name="EAnnotation"><br>
<xsd:complexContent><br>
<xsd:extension base="ecore:EModelElement"><br>
<xsd:sequence><br>
<b><xsd:element maxOccurs="unbounded" minOccurs="0"
name="details" type="ecore:EStringToStringMapEntry"/></b><br>
<xsd:element maxOccurs="unbounded" minOccurs="0"
name="contents"/><br>
</xsd:sequence><br>
<xsd:attribute name="source" type="ecore:EString"/><br>
<xsd:attribute ecore:opposite="eAnnotations"
ecore:reference="ecore:EModelElement" ecore:transient="true"
name="eModelElement" type="xsd:IDREF"/><br>
<xsd:attribute ecore:reference="xsd:anyType"
name="references"><br>
<xsd:simpleType><br>
<xsd:list itemType="xsd:anyURI"/><br>
</xsd:simpleType><br>
</xsd:attribute><br>
</xsd:extension><br>
</xsd:complexContent><br>
</xsd:complexType></small><br>
<br>
<b><small> <xsd:complexType
ecore:instanceClass="java.util.Map$Entry"
name="EStringToStringMapEntry"><br>
<xsd:attribute name="key" type="ecore:EString"/><br>
<xsd:attribute name="value" type="ecore:EString"/><br>
</xsd:complexType> </small></b><br >
<div><br>
</div>
If you know how to do it in Ecore, you can try exporting the .ecore to
an XML Schema and see what it produces. I've tried to make the Ecore
-> XML Schema -> Ecore be as roundtrippable as possible...<br>
<br>
<br>
Philipp W. Kutter wrote:
<blockquote cite="mide95roa$4ra$1@utils.eclipse.org" type="cite">
<pre wrap="">Hi, All.
I have an XSD Schema with instances of Type A.
Now I would like to add a map, from A to A, where the key is a
refrerence, and the value is a containment.
I know how to do this in Java and in ECore, but not in XSD.
When I tried to load from the generated XSD fragment:
<xsd:complexType name="XMLToXMLMapEntry">
<xsd:choice maxOccurs="unbounded" minOccurs="0">
<xsd:element name="key" type="mtgDecoration:MXmlElement"/>
<xsd:element name="value" type="mtgDecoration:MXmlElement"/>
<xsd:element ref="xmi:Extension"/>
</xsd:choice>
<xsd:attribute ref="xmi:id"/>
<xsd:attributeGroup ref="xmi:ObjectAttribs"/>
<xsd:attribute name="key" type="xsd:string"/>
<xsd:attribute name="value" type="xsd:string"/>
</xsd:complexType>
It did not work, and it looks overly complex.
Is there any built in support in EMF/XSD for this?
Best Regards, Philipp
</pre>
</blockquote>
<br>
</body>
</html>
--------------060307060603090902040505--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: perfect, it works in all variants! [message #402452 is a reply to message #402451] |
Fri, 14 July 2006 13:56 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Philipp,
There's this
http://www.eclipse.org/emf/docs/overviews/XMLSchemaToEcoreMa pping.pdf
but it's out of date and it doesn't specifically cover maps, although
there aren't really any map specific annotations, you just use general
purpose annotations to achieve a map result...
Philipp W. Kutter wrote:
> Thanks a lot.
> I got it to work, both string to string, object ref to object ref,
> and object ref to contained object. See the minimal XSD below.
>
> Best, Philipp
>
> PS: a pitty that there is no place one can look for
> "map XSD EMF" and get the info.
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema
> targetNamespace="http://www.montages.com/mtg/MTGDECORATION"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:mtgDecoration="http://www.montages.com/mtg/MTGDECORATION"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>
> <xsd:complexType name="MAny">
> <xsd:sequence>
> <xsd:element name="child" type="mtgDecoration:MAny"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0"
> name="details" type="mtgDecoration:MStringToStringMapEntry"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0"
> name="any2any" type="mtgDecoration:MAnyToAnyMapEntry"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0"
> name="any2anyContained" type="mtgDecoration:MAnyToAnyContainedMapEntry"/>
> </xsd:sequence>
> <xsd:attribute name="ref"
> ecore:reference="mtgDecoration:MAny" type="xsd:anyURI"/>
> <xsd:attribute name="id" type="xsd:string"/>
> </xsd:complexType>
>
>
>
> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
> name="MStringToStringMapEntry">
> <xsd:attribute name="key" type="xsd:string"/>
> <xsd:attribute name="value" type="xsd:string"/>
> </xsd:complexType>
>
> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
> name="MAnyToAnyMapEntry">
> <xsd:attribute name="key" ecore:reference="mtgDecoration:MAny"
> type="xsd:anyURI"/>
> <xsd:attribute name="value" ecore:reference="mtgDecoration:MAny"
> type="xsd:anyURI"/>
> </xsd:complexType>
>
> <xsd:complexType ecore:instanceClass="java.util.Map$Entry"
> name="MAnyToAnyContainedMapEntry">
> <xsd:sequence>
> <xsd:element name="value" type="mtgDecoration:MAny"/>
> </xsd:sequence>
> <xsd:attribute name="key" ecore:reference="mtgDecoration:MAny"
> type="xsd:anyURI"/>
> </xsd:complexType>
>
> </xsd:schema>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04209 seconds