Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Trouble with ecore:reference in XSD import(Attributes are mapped to EObject instead of the referenced type)
Trouble with ecore:reference in XSD import [message #685225] Fri, 17 June 2011 04:16 Go to next message
Mark Tippetts is currently offline Mark TippettsFriend
Messages: 25
Registered: July 2009
Junior Member
In the schema listed below, there are several lines of the form,
<xs:attribute ecore:reference="Topic" name="reifier" type="xs:anyURI" />

When importing the schema, this produces an unexpected result: The attribute is mapped to an EReference of type EObject, instead of the identified type. I've tried the following permutations, all with the same result:
ecore:reference="Topic"
ecore:reference="topic"
ecore:reference="xtm:Topic"
ecore:reference="xtm:topic"
ecore:reference="xtm2:Topic"
ecore:reference="xtm2:topic"

Am I doing it wrong, or is this a bug, or has the behavior changed from what's documented in the PDF at http://www.eclipse.org/modeling/emf/docs/overviews/XMLSchemaToEcoreMapping.pdf

Thanks,

Mark Tippetts

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- ............................................................. -->
<!-- XML Topic Map Schema ....................................... -->
<!-- XML Topic Map (XTM) Schema, Version 2.0 This is XTM 2.0, an XML interchange 
	syntax for ISO 13250 Topic Maps, defined by ISO 13250-3. See http://www.isotopicmaps.org/sam/sam-xtm/ -->
<xs:schema 
	xmlns="http://www.topicmaps.org/xtm/" 
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" 
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	ecore:package="net.golemware.topicmaps.xtm2" elementFormDefault="qualified"
	targetNamespace="http://www.topicmaps.org/xtm/">
	<xs:annotation>
		<xs:appinfo>
			<dc:title>W3C XML Schema for XTM 2.0</dc:title>
			<dc:owner>ISO/IEC JTC1 SC34</dc:owner>
			<dc:contributor>Max Voskob</dc:contributor>
			<dc:contributor>Lars Marius Garshol</dc:contributor>
			<dc:contributor>Ann Wrightson</dc:contributor>
		</xs:appinfo>
	</xs:annotation>

	<!-- any-markup ................................................ -->
	<xs:complexType mixed="true" name="any-markup">
		<xs:complexContent mixed="true">
			<xs:restriction base="xs:anyType">
				<xs:sequence>
					<xs:any maxOccurs="unbounded" minOccurs="0" namespace="##other"
						processContents="lax" />
				</xs:sequence>
				<xs:attribute name="datatype" type="xs:anyURI" />
			</xs:restriction>
		</xs:complexContent>
	</xs:complexType>

	<!-- topicMap .................................................. -->
	<xs:element name="topicMap">
		<xs:complexType ecore:name="TopicMap">
			<xs:sequence>
				<xs:element maxOccurs="unbounded" minOccurs="0"
					ref="itemIdentity" />

				<xs:element maxOccurs="unbounded" minOccurs="0" ref="mergeMap" />
				<xs:choice maxOccurs="unbounded" minOccurs="0">
					<xs:element ref="topic" />
					<xs:element ref="association" />
				</xs:choice>
			</xs:sequence>
			<xs:attribute ecore:reference="Topic" name="reifier"
				type="xs:anyURI" />
			<xs:attribute fixed="2.0" name="version" />
		</xs:complexType>
	</xs:element>

	<!-- topic ..................................................... -->
	<xs:element name="topic">
		<xs:complexType ecore:name="Topic">
			<xs:sequence>
				<xs:choice maxOccurs="unbounded" minOccurs="0">
					<xs:element ref="itemIdentity" />
					<xs:element ref="subjectLocator" />
					<xs:element ref="subjectIdentifier" />
				</xs:choice>
				<xs:element maxOccurs="1" minOccurs="0" ref="instanceOf" />
				<xs:choice maxOccurs="unbounded" minOccurs="0">
					<xs:element ref="name" />
					<xs:element ref="occurrence" />
				</xs:choice>
			</xs:sequence>
			<xs:attribute name="id" type="xs:ID" use="required" />
		</xs:complexType>
	</xs:element>

	<!-- itemIdentity .............................................. -->
	<xs:element name="itemIdentity">
		<xs:complexType ecore:name="ItemIdentity">
			<xs:attribute name="href" type="xs:anyURI" use="required" />
		</xs:complexType>
	</xs:element>

	<!-- subjectLocator ............................................ -->
	<xs:element name="subjectLocator">
		<xs:complexType ecore:name="SubjectLocator">
			<xs:attribute name="href" type="xs:anyURI" use="required" />
		</xs:complexType>
	</xs:element>

	<!-- subjectIdentifier ......................................... -->
	<xs:element name="subjectIdentifier">
		<xs:complexType ecore:name="SubjectIdentifier">
			<xs:attribute name="href" type="xs:anyURI" use="required" />
		</xs:complexType>
	</xs:element>

	<!-- name ...................................................... -->
	<xs:element name="name">
		<xs:complexType ecore:name="Name">
			<xs:sequence>
				<xs:element maxOccurs="unbounded" minOccurs="0"
					ref="itemIdentity" />
				<xs:element minOccurs="0" ref="type" />
				<xs:element minOccurs="0" ref="scope" />
				<xs:element ref="value" />
				<xs:element maxOccurs="unbounded" minOccurs="0" ref="variant" />
			</xs:sequence>
			<xs:attribute ecore:reference="Topic" name="reifier"
				type="xs:anyURI" />
		</xs:complexType>
	</xs:element>

	<!-- value ..................................................... -->
	<xs:element name="value" type="xs:string" />

	<!-- variant ................................................... -->
	<xs:element name="variant">
		<xs:complexType ecore:name="Variant">
			<xs:sequence>
				<xs:element maxOccurs="unbounded" minOccurs="0"
					ref="itemIdentity" />
				<xs:element ref="scope" />
				<xs:choice>
					<xs:element ref="resourceData" />
					<xs:element ref="resourceRef" />
				</xs:choice>
			</xs:sequence>
			<xs:attribute ecore:reference="Topic" name="reifier"
				type="xs:anyURI" />
		</xs:complexType>
	</xs:element>

	<!-- scope ..................................................... -->
	<xs:element name="scope">
		<xs:complexType ecore:name="Scope">
			<xs:choice>
				<xs:element maxOccurs="unbounded" ref="topicRef" />
			</xs:choice>
		</xs:complexType>
	</xs:element>

	<!-- instanceOf ................................................ -->
	<xs:element name="instanceOf">
		<xs:complexType ecore:name="InstanceOf">
			<xs:choice>
				<xs:element maxOccurs="unbounded" ref="topicRef" />
			</xs:choice>
		</xs:complexType>
	</xs:element>

	<!-- type ...................................................... -->
	<xs:element name="type">
		<xs:complexType ecore:name="Type">
			<xs:choice>
				<xs:element ref="topicRef" />
			</xs:choice>
		</xs:complexType>
	</xs:element>

	<!-- occurrence ................................................ -->
	<xs:element name="occurrence">
		<xs:complexType ecore:name="Occurrence">
			<xs:sequence>
				<xs:element maxOccurs="unbounded" minOccurs="0"
					ref="itemIdentity" />
				<xs:element ref="type" />
				<xs:element minOccurs="0" ref="scope" />
				<xs:choice>
					<xs:element ref="resourceRef" />
					<xs:element ref="resourceData" />
				</xs:choice>
			</xs:sequence>
			<xs:attribute ecore:reference="Topic" name="reifier"
				type="xs:anyURI" />
		</xs:complexType>
	</xs:element>

	<!-- resourceData .............................................. -->
	<xs:element name="resourceData" type="any-markup" />

	<!-- association ............................................... -->
	<xs:element name="association">
		<xs:complexType ecore:name="Association">
			<xs:sequence>
				<xs:element maxOccurs="unbounded" minOccurs="0"
					ref="itemIdentity" />
				<xs:element ref="type" />
				<xs:element minOccurs="0" ref="scope" />
				<xs:element maxOccurs="unbounded" ref="role" />
			</xs:sequence>
			<xs:attribute ecore:reference="Topic" name="reifier"
				type="xs:anyURI" />
		</xs:complexType>
	</xs:element>

	<!-- role ...................................................... -->
	<xs:element name="role">
		<xs:complexType ecore:name="Role">
			<xs:sequence>
				<xs:element maxOccurs="unbounded" minOccurs="0"
					ref="itemIdentity" />
				<xs:element ref="type" />
				<xs:element ref="topicRef" />
			</xs:sequence>
			<xs:attribute ecore:reference="Topic" name="reifier"
				type="xs:anyURI" />
		</xs:complexType>
	</xs:element>

	<!-- topicRef .................................................. -->
	<xs:element name="topicRef">
		<xs:complexType ecore:name="TopicRef">
			<xs:attribute ecore:reference="Topic" name="href" type="xs:anyURI"
				use="required" />
		</xs:complexType>
	</xs:element>

	<!-- resourceRef ............................................... -->
	<xs:element name="resourceRef">
		<xs:complexType ecore:name="ResourceRef">
			<xs:attribute name="href" type="xs:anyURI" use="required" />
		</xs:complexType>
	</xs:element>

	<!-- mergeMap .................................................. -->
	<xs:element name="mergeMap">
		<xs:complexType ecore:name="MergeMap">
			<xs:attribute name="href" type="xs:anyURI" use="required"
				ecore:reference="TopicMap" />
		</xs:complexType>
	</xs:element>
</xs:schema>

Re: Trouble with ecore:reference in XSD import [message #1692705 is a reply to message #685225] Fri, 17 April 2015 12:06 Go to previous messageGo to next message
Patrick Neubauer is currently offline Patrick NeubauerFriend
Messages: 8
Registered: December 2014
Junior Member
Hi Mark,

I am actually faced with the same issue as you describe. Since this article is quite old but the XMLSchemaToEcoreMapping pdf seems still to be the latest information regarding the Importer, did you come up with a solution?

According to the documentation in the pdf the following..
<xsd:attribute name="author" type="xsd:IDREF" ecore:reference="Writer"/>


.. should be transformed to:
EReference name="author" eType="//Writer" upperBound=1 containment=false resolveProxies=false


However, what I get is:
EReference name="author" eType="ecore:EClass URL#//EObject" resolveProxies=false


Note that URL is http : // www . eclipse . org / emf / 2002 / Ecore

Cheers, Patrick
Re: Trouble with ecore:reference in XSD import [message #1692739 is a reply to message #1692705] Fri, 17 April 2015 13:43 Go to previous message
Patrick Neubauer is currently offline Patrick NeubauerFriend
Messages: 8
Registered: December 2014
Junior Member
Hi again,

I solved the problem. If anyone has the same and is reading this, here is the solution:
Carefully look at how you write the class name in ecore:reference="CLASSNAME". In my example it could be solved by exactly writing it in the same upper-/lowercase as it has been defined in the name attribute of the complexType it refers to.
Also, make sure you start then with an uppercase letter as I am not sure what the conventions here are.

Cheers, Patrick
Previous Topic:[CDO] How to access CDO Preference window
Next Topic:Conflicting handlers with Kepler
Goto Forum:
  


Current Time: Mon Oct 21 05:36:47 GMT 2019

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

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

Back to the top