Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Modeling (top-level project) » getResource issue
getResource issue [message #528481] Tue, 20 April 2010 16:43 Go to next message
Vaz is currently offline VazFriend
Messages: 16
Registered: July 2009
Junior Member
Hello all,

I'm trying to load a xml into an EObject. I use the following code:
(...)
resourceSet.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);		resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new GenericXMLResourceFactoryImpl());
Resource resource = resourceSet.getResource(URI.createFileURI(xmlFile), true);		
EObject documentRoot = (EObject)resource.getContents().get(0);
(...)


I get an exception on the last line.

Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '0' is not legal. (file:///C:/copy/wS/BS/data/example.ifcxml, 161, 46)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:315)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:397)
	at bs.Loader.XsdTest.main(XsdTest.java:113)
Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '0' is not legal. (file:///C:/copy/wS/BS/data/example.ifcxml, 161, 46)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2662)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XMLHandler.java:2716)
	at org.eclipse.emf.ecore.xmi.impl.SAXXMLHandler.handleObjectAttribs(SAXXMLHandler.java:83)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFactory(XMLHandler.java:2192)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFeatureType(XMLHandler.java:2158)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHandler.java:2034)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1813)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1023)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1001)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:712)
	at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
	at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:181)
	at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:180)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1494)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1282)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:255)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:270)
	... 2 more
Caused by: java.lang.IllegalArgumentException: The value '0' is invalid. 
	at org.eclipse.emf.ecore.impl.EFactoryImpl.createFromString(EFactoryImpl.java:439)
	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(XMLHelperImpl.java:1621)
	at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1162)
	at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2657)
	... 27 more


Well, on the line 161 of the xml file i have the following: "<IfcLengthMeasure pos="0">0.</IfcLengthMeasure>".

In the context:
<IfcCartesianPoint id="i22">
			<Coordinates ex:cType="list">
				<IfcLengthMeasure pos="0">0.</IfcLengthMeasure>
				<IfcLengthMeasure pos="1">0.</IfcLengthMeasure>
				<IfcLengthMeasure pos="2">0.</IfcLengthMeasure>
			</Coordinates>
		</IfcCartesianPoint>


The element in the xml schema is as follows:
<xs:element name="IfcLengthMeasure" nillable="true">
		<xs:complexType>
			<xs:simpleContent>
				<xs:extension base="ifc:IfcLengthMeasure">
					<xs:attributeGroup ref="ex:instanceAttributes">
					</xs:attributeGroup>
				</xs:extension>
			</xs:simpleContent>
		</xs:complexType>
	</xs:element>

	<xs:simpleType name="IfcLengthMeasure">
		<xs:restriction base="xs:double">
		</xs:restriction>
	</xs:simpleType>
	
	
	<xs:attributeGroup name="instanceAttributes">
		<xs:attribute name="id" type="xs:ID" use="optional"/>
		<xs:attribute name="path" type="xs:NMTOKENS" use="optional"/>
		<xs:attribute name="pos" use="optional">
			<xs:simpleType>
				<xs:restriction>
					<xs:simpleType>
						<xs:list itemType="xs:integer"/>
					</xs:simpleType>
					<xs:minLength value="1"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
	</xs:attributeGroup


I already validated the xml with SAX and here: http://tools.decisionsoft.com/schemaValidate/
None of them returned errors, so i'm excluding any xml issues.

Could it be a problem with the parser EMF uses? If i remove the "pos" attribute i don't get the exception, but then i lose important data Embarrassed
Does any of you have an idea or suggestion?

Thank you,
João Vaz

PS. I think i posted on the wrong section as i was planning to post in the EMF section

[Updated on: Tue, 20 April 2010 16:46]

Report message to a moderator

Re: getResource issue [message #528492 is a reply to message #528481] Tue, 20 April 2010 17:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
João,

Comments below.

Vaz wrote:
> Hello all,
>
> I'm trying to load a xml into an EObject. I use the following code:
>
> (...)
> resourceSet.getLoadOptions().put(XMLResource.OPTION_EXTENDED _META_DATA,
> Boolean.TRUE);
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
> new GenericXMLResourceFactoryImpl());
It already uses that option, so no point in doing the options thing
before it.
> Resource resource =
> resourceSet.getResource(URI.createFileURI(xmlFile), true);
> EObject documentRoot = (EObject)resource.getContents().get(0);
> (...)
>
>
> I get an exception on the last line.
>
>
> Exception in thread "main"
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
> org.eclipse.emf.ecore.xmi.IllegalValueException: Value '0' is not
> legal. (file:///C:/copy/wS/BS/data/example.ifcxml, 161, 46)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDe mandLoadException(ResourceSetImpl.java:315)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:274)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
>
> at bs.Loader.XsdTest.main(XsdTest.java:113)
I don't know what models you have registered. Did you generate a model
for your schema? If so, try invoking Generate Test Code and using the
generated XyzExample.java in the *.tests project.
> Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '0'
> is not legal. (file:///C:/copy/wS/BS/data/example.ifcxml, 161, 46)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2662)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XML Handler.java:2716)
>
> at
> org.eclipse.emf.ecore.xmi.impl.SAXXMLHandler.handleObjectAtt ribs(SAXXMLHandler.java:83)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2192)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFe atureType(XMLHandler.java:2158)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:2034)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1813)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1023)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
>
> at
> org.apache.xerces.parsers.AbstractSAXParser.startElement(Unk nown Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanSt artElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragme ntContentDispatcher.dispatch(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo cument(Unknown
> Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
> at
> org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unk nown Source)
> at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1494)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1282)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
>
> ... 2 more
> Caused by: java.lang.IllegalArgumentException: The value '0' is
> invalid. at
> org.eclipse.emf.ecore.impl.EFactoryImpl.createFromString(EFa ctoryImpl.java:439)
>
If your schema was actually being used, I'd expect this to end up using
an EDataType from XMLTypeFactoryImpl. Do you know which model's
EDataType is being used to process the literals here?
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromStrin g(XMLHelperImpl.java:1621)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1162)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2657)
>
> ... 27 more
>
>
> Well, on the line 161 of the xml file i have the following:
> "<IfcLengthMeasure pos="0">0.</IfcLengthMeasure>".
>
> In the context:
>
> <IfcCartesianPoint id="i22">
> <Coordinates ex:cType="list">
> <IfcLengthMeasure pos="0">0.</IfcLengthMeasure>
> <IfcLengthMeasure pos="1">0.</IfcLengthMeasure>
> <IfcLengthMeasure pos="2">0.</IfcLengthMeasure>
> </Coordinates>
> </IfcCartesianPoint>
>
>
> The element in the xml schema is as follows:
>
> <xs:element name="IfcLengthMeasure" nillable="true">
> <xs:complexType>
> <xs:simpleContent>
> <xs:extension base="ifc:IfcLengthMeasure">
> <xs:attributeGroup ref="ex:instanceAttributes">
> </xs:attributeGroup>
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
> </xs:element>
>
> <xs:simpleType name="IfcLengthMeasure">
> <xs:restriction base="xs:double">
> </xs:restriction>
> </xs:simpleType>
>
>
> <xs:attributeGroup name="instanceAttributes">
> <xs:attribute name="id" type="xs:ID" use="optional"/>
> <xs:attribute name="path" type="xs:NMTOKENS" use="optional"/>
> <xs:attribute name="pos" use="optional">
> <xs:simpleType>
> <xs:restriction>
> <xs:simpleType>
> <xs:list itemType="xs:integer"/>
> </xs:simpleType>
> <xs:minLength value="1"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:attribute>
> </xs:attributeGroup
>
>
> I already validated the xml with SAX and here:
> http://tools.decisionsoft.com/schemaValidate/
> None of them returned errors, so i'm excluding any xml issues.
>
> Could it be a problem with the parser EMF uses?
No, some issue with the data type being used not allowing the value "0"
but I can't imagine why. "xsd:integer" obviously allows that and a list
of those should allow it too.
> If i remove the "pos" attribute i don't get the exception, but then i
> lose important data :blush: Does any of you have an idea or suggestion?
> Thank you,
> João Vaz


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: getResource issue [message #528559 is a reply to message #528492] Wed, 21 April 2010 00:24 Go to previous messageGo to next message
Vaz is currently offline VazFriend
Messages: 16
Registered: July 2009
Junior Member
Ed,

Thanks for the quick reply.

Quote:
I don't know what models you have registered. Did you generate a model
for your schema?

Quote:
If your schema was actually being used, I'd expect this to end up using
an EDataType from XMLTypeFactoryImpl. Do you know which model's
EDataType is being used to process the literals here?

I wanted to load a xsd into an ePackage and then register it in the factory. The code I'm currently using to accomplish that is the following:
                XSDEcoreBuilder xsdEcoreBuilder = new XSDEcoreBuilder();
		ResourceSet resourceSet = new ResourceSetImpl();
		Collection eCorePackages = xsdEcoreBuilder.generate(URI.createFileURI(xsdFile));
		int n =0;
		Resource resource;
		for (Iterator iter = eCorePackages.iterator(); iter.hasNext();) 
		{
			 	n++;
				EPackage element = (EPackage) iter.next();
				resourceSet.getPackageRegistry().put(element.getNsURI(), element);	
				
				// Register XML Factory implementation to handle .ecore files
				resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
						.put("ecore", new XMLResourceFactoryImpl());

				// Create empty resource with the given URI
				Resource resource2 = resourceSet.createResource(URI
						.createURI("./" + element.getName() + + n + ".ecore"));

				// Add bookStoreEPackage to contents list of the resource
				resource2.getContents().add(element);

				try {
					// Save the resource
					resource2.save(null);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}


The whole idea (if it's relevant) is to create an app which parses a xsd and xml, and loads them into the EMF world so that they can be "ATL-transformed".

Thank you,
João Vaz
Re: getResource issue [message #528697 is a reply to message #528559] Wed, 21 April 2010 13:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
Vaz,

Comments below.

Vaz wrote:
> Ed,
>
> Thanks for the quick reply.
>
> Quote:
>> I don't know what models you have registered. Did you generate a
>> model for your schema?
>
> Quote:
>> If your schema was actually being used, I'd expect this to end up
>> using an EDataType from XMLTypeFactoryImpl. Do you know which
>> model's EDataType is being used to process the literals here?
>
> I wanted to load a xsd into an ePackage and then register it in the
> factory. The code I'm currently using to accomplish that is the
> following:
>
> XSDEcoreBuilder xsdEcoreBuilder = new XSDEcoreBuilder();
> ResourceSet resourceSet = new ResourceSetImpl();
> Collection eCorePackages =
> xsdEcoreBuilder.generate(URI.createFileURI(xsdFile));
Time to start exploiting Java 5.0...
> int n =0;
> Resource resource;
> for (Iterator iter = eCorePackages.iterator();
> iter.hasNext();) {
> n++;
> EPackage element = (EPackage) iter.next();
>
> resourceSet.getPackageRegistry().put(element.getNsURI(), element);
>
> // Register XML Factory implementation to handle
> .ecore files
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
> .put("ecore", new XMLResourceFactoryImpl());
Normally EcoreResourceFactoryImpl is used for Ecore resources.
>
> // Create empty resource with the given URI
> Resource resource2 = resourceSet.createResource(URI
> .createURI("./" + element.getName() + + n +
> ".ecore"));
>
> // Add bookStoreEPackage to contents list of the resource
> resource2.getContents().add(element);
If there is more than one Ecore model, it's important to put all of them
in resources before saving any of them so that they reference each other
correctly via their physical location.
>
> try {
> // Save the resource
> resource2.save(null);
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
>
>
> The whole idea (if it's relevant) is to create an app which parses a
> xsd and xml, and loads them into the EMF world so that they can be
> "ATL-transformed".
Just from the snips you've shown, it's not apparent to me yet what data
type is being used to process the "0" value.
> Thank you,
> João Vaz
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: getResource issue [message #528992 is a reply to message #528481] Thu, 22 April 2010 14:46 Go to previous messageGo to next message
Vaz is currently offline VazFriend
Messages: 16
Registered: July 2009
Junior Member
Hi Ed,
Quote:
Just from the snips you've shown, it's not apparent to me yet what data
type is being used to process the "0" value.

My xml schema imports another schema. So in fact I have to load both into separate models, resulting in two separate *.ecore files. Although here, I didn't understand your suggestion, when you say
Quote:

If there is more than one Ecore model, it's important to put all of them
in resources before saving any of them so that they reference each other
correctly via their physical location.
you mean that I must put both EcorePackages in the same ResourceSet? If so, i think I'm already doing that.


Thus, the relevant lines to solve the error from both generated Ecore models are:

The IfcCartesianPoint:
<eClassifiers xsi:type="ecore:EClass" name="IfcCartesianPoint" eSuperTypes="./org.tech.iai.ifc.xml.ifc._2x3.final2.ecore#//IfcPoint">
    <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
      <details key="name" value="IfcCartesianPoint"/>
      <details key="kind" value="elementOnly"/>
    </eAnnotations>
    <eStructuralFeatures xsi:type="ecore:EReference" name="coordinates" lowerBound="1"
        eType="ecore:EClass ./org.tech.iai.ifc.xml.ifc._2x3.final2.ecore#//CoordinatesType1"
        containment="true" resolveProxies="false">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="element"/>
        <details key="name" value="Coordinates"/>
        <details key="namespace" value="##targetNamespace"/>
      </eAnnotations>
    </eStructuralFeatures>
  </eClassifiers>
which has an eStructuralFeature "Coordinates" of the type CoordinatesType1:
<eClassifiers xsi:type="ecore:EClass" name="CoordinatesType1">
    <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
      <details key="name" value="Coordinates_._1_._type"/>
      <details key="kind" value="elementOnly"/>
    </eAnnotations>
    <eStructuralFeatures xsi:type="ecore:EReference" name="ifcLengthMeasure" lowerBound="1"
        upperBound="3" eType="ecore:EClass ./org.tech.iai.ifc.xml.ifc._2x3.final2.ecore#//IfcLengthMeasureType"
        containment="true" resolveProxies="false">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="element"/>
        <details key="name" value="IfcLengthMeasure"/>
        <details key="namespace" value="##targetNamespace"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="arraySize" eType="ecore:EDataType ./org.iso.standard._10303.part._28.version._2.xmlschema.common2.ecore#//ArraySizeType">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="attribute"/>
        <details key="name" value="arraySize"/>
        <details key="namespace" value="urn:iso.org:standard:10303:part(28):version(2):xmlschema:common"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="cType" eType="ecore:EDataType ./org.iso.standard._10303.part._28.version._2.xmlschema.common2.ecore#//CTypeType"
        defaultValueLiteral="list" unsettable="true">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="attribute"/>
        <details key="name" value="cType"/>
        <details key="namespace" value="urn:iso.org:standard:10303:part(28):version(2):xmlschema:common"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="itemType" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//QName"
        defaultValueLiteral="ifc:IfcLengthMeasure" unsettable="true">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="attribute"/>
        <details key="name" value="itemType"/>
        <details key="namespace" value="urn:iso.org:standard:10303:part(28):version(2):xmlschema:common"/>
      </eAnnotations>
    </eStructuralFeatures>
  </eClassifiers>  

Here starts the problem (i think...), because the CoordinatesType1 has an eStructuralFeatures named ifcLengthMeasure which references the type IfcLengthMeasureType :
<eClassifiers xsi:type="ecore:EClass" name="IfcLengthMeasureType">
    <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
      <details key="name" value="IfcLengthMeasure_._type"/>
      <details key="kind" value="simple"/>
    </eAnnotations>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="value" eType="ecore:EDataType ./org.tech.iai.ifc.xml.ifc._2x3.final2.ecore#//IfcLengthMeasure"
        unsettable="true">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="name" value=":0"/>
        <details key="kind" value="simple"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//ID"
        iD="true">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="attribute"/>
        <details key="name" value="id"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="path" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//NMTOKENS">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="attribute"/>
        <details key="name" value="path"/>
      </eAnnotations>
    </eStructuralFeatures>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="pos" eType="ecore:EDataType ./org.iso.standard._10303.part._28.version._2.xmlschema.common2.ecore#//PosType">
      <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
        <details key="kind" value="attribute"/>
        <details key="name" value="pos"/>
      </eAnnotations>
    </eStructuralFeatures>
  </eClassifiers>

The error parsing the xml data is very specific and points out to the Attribute "pos" of the Eclass above, and it doesn't matter what value I insert. That Attribute is of the type "PosType" and is declared in the other Ecore file as follows:
<eClassifiers xsi:type="ecore:EDataType" name="PosType" instanceClassName="java.util.List">
    <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
      <details key="name" value="pos_._type"/>
      <details key="minLength" value="1"/>
    </eAnnotations>
  </eClassifiers>






And finally, the xml I'm trying to load (which is created automatically with a specific sofware):
(...)
<IfcCartesianPoint id="i22">
			<Coordinates ex:cType="list">
				<IfcLengthMeasure pos="0">0.</IfcLengthMeasure>
				<IfcLengthMeasure pos="1">0.</IfcLengthMeasure>
				<IfcLengthMeasure pos="2">0.</IfcLengthMeasure>
			</Coordinates>
		</IfcCartesianPoint>
(...)


Do you think there's a problem with the generated models? Or maybe even with the way they reference each other?

I know the post got a bit confusing (and huge), sorry for that, but it gets really difficult to explain the problem.

Thanks once more,
João Vaz
Re: getResource issue [message #529291 is a reply to message #528992] Fri, 23 April 2010 17:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
Vaz,

Comments below.

Vaz wrote:
> Hi Ed,
> Quote:
>> Just from the snips you've shown, it's not apparent to me yet what
>> data type is being used to process the "0" value.
>
> My xml schema imports another schema. So in fact I have to load both
> into separate models, resulting in two separate *.ecore files.
> Although here, I didn't understand your suggestion, when you say Quote:
>> If there is more than one Ecore model, it's important to put all of
>> them in resources before saving any of them so that they reference
>> each other correctly via their physical location.
> you mean that I must put both EcorePackages in the same ResourceSet?
> If so, i think I'm already doing that.
The models will reference each other via the URI of the resource that
contains them, so it's import to establish those names first. Perhaps
you're lucky that the order in which you process happens to set the URI
of the referenced model before a reference to it from the second model
is saved.
>
>
> Thus, the relevant lines to solve the error from both generated Ecore
> models are:
>
> The IfcCartesianPoint:
>
> <eClassifiers xsi:type="ecore:EClass" name="IfcCartesianPoint"
> eSuperTypes="./org.tech.iai.ifc.xml.ifc._2x3.final2.ecore#//IfcPoint ">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="IfcCartesianPoint"/>
> <details key="kind" value="elementOnly"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EReference" name="coordinates"
> lowerBound="1"
> eType="ecore:EClass
> ./org.tech.iai.ifc.xml.ifc._2x3.final2.ecore#//CoordinatesTy pe1 "
> containment="true" resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="Coordinates"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> which has an eStructuralFeature "Coordinates" of the type
> CoordinatesType1:
>
> <eClassifiers xsi:type="ecore:EClass" name="CoordinatesType1">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="Coordinates_._1_._type"/>
> <details key="kind" value="elementOnly"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="ifcLengthMeasure" lowerBound="1"
> upperBound="3" eType="ecore:EClass
> ./org.tech.iai.ifc.xml.ifc._2x3.final2.ecore#//IfcLengthMeas ureType "
> containment="true" resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="IfcLengthMeasure"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="arraySize"
> eType="ecore:EDataType
> ./org.iso.standard._10303.part._28.version._2.xmlschema.comm on2.ecore#//ArraySizeType ">
>
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="arraySize"/>
> <details key="namespace"
> value=" urn:iso.org:standard:10303:part(28):version(2):xmlschema:com mon "/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="cType"
> eType="ecore:EDataType
> ./org.iso.standard._10303.part._28.version._2.xmlschema.comm on2.ecore#//CTypeType "
>
> defaultValueLiteral="list" unsettable="true">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="cType"/>
> <details key="namespace"
> value=" urn:iso.org:standard:10303:part(28):version(2):xmlschema:com mon "/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="itemType"
> eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//QName"
> defaultValueLiteral="ifc:IfcLengthMeasure" unsettable="true">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="itemType"/>
> <details key="namespace"
> value=" urn:iso.org:standard:10303:part(28):version(2):xmlschema:com mon "/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> Here starts the problem (i think...), because the CoordinatesType1 has
> an eStructuralFeatures named ifcLengthMeasure which references the
> type IfcLengthMeasureType :
>
> <eClassifiers xsi:type="ecore:EClass" name="IfcLengthMeasureType">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="IfcLengthMeasure_._type"/>
> <details key="kind" value="simple"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
> eType="ecore:EDataType
> ./org.tech.iai.ifc.xml.ifc._2x3.final2.ecore#//IfcLengthMeas ure "
> unsettable="true">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value=":0"/>
> <details key="kind" value="simple"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"
> eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//ID"
> iD="true">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="id"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="path"
> eType="ecore:EDataType
> http://www.eclipse.org/emf/2003/XMLType#//NMTOKENS">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="path"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="pos"
> eType="ecore:EDataType
> ./org.iso.standard._10303.part._28.version._2.xmlschema.comm on2.ecore#//PosType ">
>
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="pos"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
>
> The error parsing the xml data is very specific and points out to the
> Attribute "pos" of the Eclass above, and it doesn't matter what value
> I insert. That Attribute is of the type "PosType" and is declared in
> the other Ecore file as follows:
> <eClassifiers xsi:type="ecore:EDataType" name="PosType"
> instanceClassName="java.util.List">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
I don't seen an annotation for key="baseType" nor any EDataType that
specifies the itemType.
> <details key="name" value="pos_._type"/>
> <details key="minLength" value="1"/>
> </eAnnotations>
> </eClassifiers>
>
>
If you provide a complete schema I can see if it's producing the right
Ecore model from it but what you show looks incomplete.
>
>
>
> And finally, the xml I'm trying to load (which is created
> automatically with a specific sofware):
>
> (...)
> <IfcCartesianPoint id="i22">
> <Coordinates ex:cType="list">
> <IfcLengthMeasure pos="0">0.</IfcLengthMeasure>
> <IfcLengthMeasure pos="1">0.</IfcLengthMeasure>
> <IfcLengthMeasure pos="2">0.</IfcLengthMeasure>
> </Coordinates>
> </IfcCartesianPoint>
> (...)
>
> Do you think there's a problem with the generated models? Or maybe
> even with the way they reference each other?
>
> I know the post got a bit confusing (and huge), sorry for that, but it
> gets really difficult to explain the problem.
>
> Thanks once more,
> João Vaz


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: getResource issue [message #529542 is a reply to message #528481] Mon, 26 April 2010 10:29 Go to previous messageGo to next message
Vaz is currently offline VazFriend
Messages: 16
Registered: July 2009
Junior Member
Hi Ed,
Quote:

The models will reference each other via the URI of the resource that
contains them, so it's import to establish those names first. Perhaps
you're lucky that the order in which you process happens to set the URI
of the referenced model before a reference to it from the second model
is saved.

Understood now.


Quote:

If you provide a complete schema I can see if it's producing the right
Ecore model from it but what you show looks incomplete.

I can't post the schema because it has 22.000 lines Embarrassed
Though both schemas (IFC.xsd and the referenced ex.xsd) are available on the web:
IFC.xsd: http://www.iai-tech.org/ifcXML/IFC2x3/FINAL/IFC2X3.xsd
EX.xsd: http://www.iai-tech.org/ifcXML/IFC2x3/FINAL/ex.xsd

I'd greatly appreciate if you could take a quick look at it.

Thanks again for your help.

João Vaz

[Updated on: Mon, 26 April 2010 10:32]

Report message to a moderator

Re: getResource issue [message #529547 is a reply to message #529542] Mon, 26 April 2010 10:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080500070805090605070304
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Vaz,

For me I end up with this

<eClassifiers xsi:type="ecore:EDataType" name="PosType"
instanceClassName="java.util.List">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="pos_._type"/>
*<details key="baseType" value="pos_._type_._base"/>*
<details key="minLength" value="1"/>
</eAnnotations>
</eClassifiers>

Note there's a baseType annotation. So it looks fine to me and I don't
know why it's not working this same expected way for you.


Vaz wrote:
> Hi Ed,
> Quote:
>> The models will reference each other via the URI of the resource that
>> contains them, so it's import to establish those names first. Perhaps
>> you're lucky that the order in which you process happens to set the
>> URI of the referenced model before a reference to it from the second
>> model is saved.
>
> Understood now.
>
>
> Quote:
>> If you provide a complete schema I can see if it's producing the
>> right Ecore model from it but what you show looks incomplete.
>
> I can't post the schema because it has 22.000 lines :blush: Though
> both schemas (IFC.xsd and the referenced ex.xsd) are available here
> http://www.iai-tech.org/products/ifc_specification/ifcxml-re leases/ifcxml2x3-release/summary
> and I'd greatly appreciate if you could take a look at it.
>
> Thanks again for your help.
>
> João Vaz

--------------080500070805090605070304
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Vaz,<br>
<br>
For me I end up with this<br>
<br>
  &lt;eClassifiers xsi:type="ecore:EDataType" name="PosType"
instanceClassName="java.util.List"&gt;<br>
    &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;<br>
      &lt;details key="name" value="pos_._type"/&gt;<br>
      <b>&lt;details key="baseType" value="pos_._type_._base"/&gt;</b><br>
      &lt;details key="minLength" value="1"/&gt;<br>
    &lt;/eAnnotations&gt;<br>
  &lt;/eClassifiers&gt;<br>
<br>
Note there's a baseType annotation.  So it looks fine to me and I don't
know why it's not working this same expected way for you.<br>
<br>
<br>
Vaz wrote:
<blockquote cite="mid:hr3ptf$1o5$1@build.eclipse.org" type="cite">Hi
Ed,
<br>
Quote:
<br>
<blockquote type="cite">The models will reference each other via the
URI of the resource that contains them, so it's import to establish
those names first. Perhaps you're lucky that the order in which you
process happens to set the URI of the referenced model before a
reference to it from the second model is saved.
<br>
</blockquote>
<br>
Understood now.
<br>
<br>
<br>
Quote:
<br>
<blockquote type="cite">If you provide a complete schema I can see if
it's producing the right Ecore model from it but what you show looks
incomplete.
<br>
</blockquote>
<br>
I can't post the schema because it has 22.000 lines  :blush: Though
both schemas (IFC.xsd and the referenced ex.xsd) are available here
<a class="moz-txt-link-freetext" href=" http://www.iai-tech.org/products/ifc_specification/ifcxml-re leases/ifcxml2x3-release/summary"> http://www.iai-tech.org/products/ifc_specification/ifcxml-re leases/ifcxml2x3-release/summary</a>
and I'd greatly appreciate if you could take a look at it.
<br>
<br>
Thanks again for your help.
<br>
<br>
João Vaz
<br>
</blockquote>
</body>
</html>

--------------080500070805090605070304--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: getResource issue [message #529643 is a reply to message #529547] Mon, 26 April 2010 15:39 Go to previous messageGo to next message
Vaz is currently offline VazFriend
Messages: 16
Registered: July 2009
Junior Member
Ed,

Just spent a few more minutes analyzing deeply the generated ecores and after reading the "XML schema to Ecore Mapping pdf" some questions arise:

Shouldn't the "PosType" have a reference to the "PosTypeBase"? I know the "PosTypeBase" represents a restriction in xml.
<eClassifiers xsi:type="ecore:EDataType" name="PosType" instanceClassName="java.util.List">
    <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
      <details key="name" value="pos_._type"/>
      <details key="minLength" value="1"/>
    </eAnnotations>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EDataType" name="PosTypeBase" instanceClassName="java.util.List">
    <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
      <details key="name" value="pos_._type_._base"/>
      <details key="itemType" value="http://www.eclipse.org/emf/2003/XMLType#integer"/>
    </eAnnotations>
  </eClassifiers>

The problem lies in here somewhere, since if i add an "id" or a "path" in xml data, which are the other eStructuralFeatures in the class "IfcLengthMeasureType", the problem doesn't show up.

Thanks again for your time.
João Vaz
Re: getResource issue [message #529652 is a reply to message #529643] Mon, 26 April 2010 15:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
Vaz,

Comments below.


Vaz wrote:
> Ed,
>
> Just spent a few more minutes analyzing deeply the generated ecores
> and after reading the "XML schema to Ecore Mapping pdf" some questions
> arise:
>
> Shouldn't the "PosType" have a reference to the "PosTypeBase"? I know
> the "PosTypeBase" represents a restriction in xml.
Well, yes, that was the point of my earlier notes.
> <eClassifiers xsi:type="ecore:EDataType" name="PosType"
> instanceClassName="java.util.List">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="pos_._type"/>
> <details key="minLength" value="1"/>
> </eAnnotations>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EDataType" name="PosTypeBase"
> instanceClassName="java.util.List">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="pos_._type_._base"/>
> <details key="itemType"
> value="http://www.eclipse.org/emf/2003/XMLType#integer"/>
> </eAnnotations>
> </eClassifiers>
> The problem lies in here somewhere, since if i add an "id" or a "path"
> in xml data, which are the other eStructuralFeatures in the class
> "IfcLengthMeasureType", the problem doesn't
Version version of EMF are you using? Perhaps this is a bug that's been
fixed in the latest...
> show up.
> Thanks again for your time.
> João Vaz


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: getResource issue [message #529882 is a reply to message #529652] Tue, 27 April 2010 14:44 Go to previous messageGo to next message
Vaz is currently offline VazFriend
Messages: 16
Registered: July 2009
Junior Member
Ed,

Currently I'm working with two versions.
- Eclipse 3.6.0 + Emf 2.6.0
- Eclipse 3.5.0 + Emf 2.5.0

I get same error with both of them.
Quote:
> Shouldn't the "PosType" have a reference to the "PosTypeBase"? I know
> the "PosTypeBase" represents a restriction in xml.
Well, yes, that was the point of my earlier notes.

Is that a bug or a feature?

Ed Merks wrote on Mon, 26 April 2010 11:59
Vaz,

Comments below.


Vaz wrote:
> Ed,
>
> Just spent a few more minutes analyzing deeply the generated ecores
> and after reading the "XML schema to Ecore Mapping pdf" some questions
> arise:
>
> Shouldn't the "PosType" have a reference to the "PosTypeBase"? I know
> the "PosTypeBase" represents a restriction in xml.
Well, yes, that was the point of my earlier notes.
> <eClassifiers xsi:type="ecore:EDataType" name="PosType"
> instanceClassName="java.util.List">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="pos_._type"/>
> <details key="minLength" value="1"/>
> </eAnnotations>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EDataType" name="PosTypeBase"
> instanceClassName="java.util.List">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="pos_._type_._base"/>
> <details key="itemType"
> value="http://www.eclipse.org/emf/2003/XMLType#integer"/>
> </eAnnotations>
> </eClassifiers>
> The problem lies in here somewhere, since if i add an "id" or a "path"
> in xml data, which are the other eStructuralFeatures in the class
> "IfcLengthMeasureType", the problem doesn't
Version version of EMF are you using? Perhaps this is a bug that's been
fixed in the latest...
> show up.
> Thanks again for your time.
> João Vaz

Thanks
João Vaz
Re: getResource issue [message #529910 is a reply to message #529882] Tue, 27 April 2010 16:14 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
Vaz,

The problem is that I can't reproduce your problem. You've not modified
the schemas I used directly from the web in any way? Unless I can
reproduce it, I can't do anything about it, so if you want to be look at
this further, you'll need to send me a completely self contained test
case (e.g., exported projects I can import into my workspace) and which
I can execute to see this problem.


Vaz wrote:
> Ed,
>
> Currently I'm working with two versions. - Eclipse 3.6.0 + Emf 2.6.0
> - Eclipse 3.5.0 + Emf 2.5.0
>
> I get same error with both of them.
> Quote:
>> > Shouldn't the "PosType" have a reference to the "PosTypeBase"? I
>> know > the "PosTypeBase" represents a restriction in xml.
>> Well, yes, that was the point of my earlier notes.
>
> Is that a bug or a feature?
>
> Ed Merks wrote on Mon, 26 April 2010 11:59
>> Vaz,
>>
>> Comments below.
>>
>>
>> Vaz wrote:
>> > Ed,
>> >
>> > Just spent a few more minutes analyzing deeply the generated ecores
>> > and after reading the "XML schema to Ecore Mapping pdf" some
>> questions > arise:
>> >
>> > Shouldn't the "PosType" have a reference to the "PosTypeBase"? I
>> know > the "PosTypeBase" represents a restriction in xml.
>> Well, yes, that was the point of my earlier notes.
>> > <eClassifiers xsi:type="ecore:EDataType" name="PosType" >
>> instanceClassName="java.util.List">
>> > <eAnnotations >
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> > <details key="name" value="pos_._type"/>
>> > <details key="minLength" value="1"/>
>> > </eAnnotations>
>> > </eClassifiers>
>> > <eClassifiers xsi:type="ecore:EDataType" name="PosTypeBase" >
>> instanceClassName="java.util.List">
>> > <eAnnotations >
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> > <details key="name" value="pos_._type_._base"/>
>> > <details key="itemType" >
>> value="http://www.eclipse.org/emf/2003/XMLType#integer"/>
>> > </eAnnotations>
>> > </eClassifiers>
>> > The problem lies in here somewhere, since if i add an "id" or a
>> "path" > in xml data, which are the other eStructuralFeatures in the
>> class > "IfcLengthMeasureType", the problem doesn't
>> Version version of EMF are you using? Perhaps this is a bug that's
>> been fixed in the latest...
>> > show up.
>> > Thanks again for your time.
>> > João Vaz
>
> Thanks
> João Vaz


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: getResource issue [message #619502 is a reply to message #528492] Wed, 21 April 2010 00:24 Go to previous message
Vaz is currently offline VazFriend
Messages: 16
Registered: July 2009
Junior Member
Ed,

Thanks for the quick reply.

Quote:
> I don't know what models you have registered. Did you generate a model
> for your schema?

Quote:
> If your schema was actually being used, I'd expect this to end up using
> an EDataType from XMLTypeFactoryImpl. Do you know which model's
> EDataType is being used to process the literals here?

I wanted to load a xsd into an ePackage and then register it in the factory. The code I'm currently using to accomplish that is the following:

XSDEcoreBuilder xsdEcoreBuilder = new XSDEcoreBuilder();
ResourceSet resourceSet = new ResourceSetImpl();
Collection eCorePackages = xsdEcoreBuilder.generate(URI.createFileURI(xsdFile));
int n =0;
Resource resource;
for (Iterator iter = eCorePackages.iterator(); iter.hasNext();)
{
n++;
EPackage element = (EPackage) iter.next();
resourceSet.getPackageRegistry().put(element.getNsURI(), element);

// Register XML Factory implementation to handle .ecore files
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
.put("ecore", new XMLResourceFactoryImpl());

// Create empty resource with the given URI
Resource resource2 = resourceSet.createResource(URI
.createURI("./" + element.getName() + + n + ".ecore"));

// Add bookStoreEPackage to contents list of the resource
resource2.getContents().add(element);

try {
// Save the resource
resource2.save(null);
} catch (IOException e) {
e.printStackTrace();
}
}


The whole idea (if it's relevant) is to create an app which parses a xsd and xml, and loads them into the EMF world so that they can be "ATL-transformed".

Thank you,
João Vaz
Re: getResource issue [message #619538 is a reply to message #619502] Wed, 21 April 2010 13:41 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
Vaz,

Comments below.

Vaz wrote:
> Ed,
>
> Thanks for the quick reply.
>
> Quote:
>> I don't know what models you have registered. Did you generate a
>> model for your schema?
>
> Quote:
>> If your schema was actually being used, I'd expect this to end up
>> using an EDataType from XMLTypeFactoryImpl. Do you know which
>> model's EDataType is being used to process the literals here?
>
> I wanted to load a xsd into an ePackage and then register it in the
> factory. The code I'm currently using to accomplish that is the
> following:
>
> XSDEcoreBuilder xsdEcoreBuilder = new XSDEcoreBuilder();
> ResourceSet resourceSet = new ResourceSetImpl();
> Collection eCorePackages =
> xsdEcoreBuilder.generate(URI.createFileURI(xsdFile));
Time to start exploiting Java 5.0...
> int n =0;
> Resource resource;
> for (Iterator iter = eCorePackages.iterator();
> iter.hasNext();) {
> n++;
> EPackage element = (EPackage) iter.next();
>
> resourceSet.getPackageRegistry().put(element.getNsURI(), element);
>
> // Register XML Factory implementation to handle
> .ecore files
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap()
> .put("ecore", new XMLResourceFactoryImpl());
Normally EcoreResourceFactoryImpl is used for Ecore resources.
>
> // Create empty resource with the given URI
> Resource resource2 = resourceSet.createResource(URI
> .createURI("./" + element.getName() + + n +
> ".ecore"));
>
> // Add bookStoreEPackage to contents list of the resource
> resource2.getContents().add(element);
If there is more than one Ecore model, it's important to put all of them
in resources before saving any of them so that they reference each other
correctly via their physical location.
>
> try {
> // Save the resource
> resource2.save(null);
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
>
>
> The whole idea (if it's relevant) is to create an app which parses a
> xsd and xml, and loads them into the EMF world so that they can be
> "ATL-transformed".
Just from the snips you've shown, it's not apparent to me yet what data
type is being used to process the "0" value.
> Thank you,
> João Vaz
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: getResource issue [message #619554 is a reply to message #529547] Mon, 26 April 2010 15:39 Go to previous message
Vaz is currently offline VazFriend
Messages: 16
Registered: July 2009
Junior Member
Ed,

Just spent a few more minutes analyzing deeply the generated ecores and after reading the "XML schema to Ecore Mapping pdf" some questions arise:

Shouldn't the "PosType" have a reference to the "PosTypeBase"? I know the "PosTypeBase" represents a restriction in xml.
<eClassifiers xsi:type="ecore:EDataType" name="PosType" instanceClassName="java.util.List">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="pos_._type"/>
<details key="minLength" value="1"/>
</eAnnotations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EDataType" name="PosTypeBase" instanceClassName="java.util.List">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="pos_._type_._base"/>
<details key="itemType" value="http://www.eclipse.org/emf/2003/XMLType#integer"/>
</eAnnotations>
</eClassifiers>
The problem lies in here somewhere, since if i add an "id" or a "path" in xml data, which are the other eStructuralFeatures in the class "IfcLengthMeasureType", the problem doesn't show up.

Thanks again for your time.
João Vaz
Re: getResource issue [message #619555 is a reply to message #529643] Mon, 26 April 2010 15:59 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
Vaz,

Comments below.


Vaz wrote:
> Ed,
>
> Just spent a few more minutes analyzing deeply the generated ecores
> and after reading the "XML schema to Ecore Mapping pdf" some questions
> arise:
>
> Shouldn't the "PosType" have a reference to the "PosTypeBase"? I know
> the "PosTypeBase" represents a restriction in xml.
Well, yes, that was the point of my earlier notes.
> <eClassifiers xsi:type="ecore:EDataType" name="PosType"
> instanceClassName="java.util.List">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="pos_._type"/>
> <details key="minLength" value="1"/>
> </eAnnotations>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EDataType" name="PosTypeBase"
> instanceClassName="java.util.List">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="pos_._type_._base"/>
> <details key="itemType"
> value="http://www.eclipse.org/emf/2003/XMLType#integer"/>
> </eAnnotations>
> </eClassifiers>
> The problem lies in here somewhere, since if i add an "id" or a "path"
> in xml data, which are the other eStructuralFeatures in the class
> "IfcLengthMeasureType", the problem doesn't
Version version of EMF are you using? Perhaps this is a bug that's been
fixed in the latest...
> show up.
> Thanks again for your time.
> João Vaz


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: getResource issue [message #619556 is a reply to message #529652] Tue, 27 April 2010 14:44 Go to previous message
Vaz is currently offline VazFriend
Messages: 16
Registered: July 2009
Junior Member
Ed,

Currently I'm working with two versions.
- Eclipse 3.6.0 + Emf 2.6.0
- Eclipse 3.5.0 + Emf 2.5.0

I get same error with both of them.
Quote:
> > Shouldn't the "PosType" have a reference to the "PosTypeBase"? I know
> > the "PosTypeBase" represents a restriction in xml.
> Well, yes, that was the point of my earlier notes.

Is that a bug or a feature?

Ed Merks wrote on Mon, 26 April 2010 11:59
> Vaz,
>
> Comments below.
>
>
> Vaz wrote:
> > Ed,
> >
> > Just spent a few more minutes analyzing deeply the generated ecores
> > and after reading the "XML schema to Ecore Mapping pdf" some questions
> > arise:
> >
> > Shouldn't the "PosType" have a reference to the "PosTypeBase"? I know
> > the "PosTypeBase" represents a restriction in xml.
> Well, yes, that was the point of my earlier notes.
> > <eClassifiers xsi:type="ecore:EDataType" name="PosType"
> > instanceClassName="java.util.List">
> > <eAnnotations
> > source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> > <details key="name" value="pos_._type"/>
> > <details key="minLength" value="1"/>
> > </eAnnotations>
> > </eClassifiers>
> > <eClassifiers xsi:type="ecore:EDataType" name="PosTypeBase"
> > instanceClassName="java.util.List">
> > <eAnnotations
> > source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> > <details key="name" value="pos_._type_._base"/>
> > <details key="itemType"
> > value="http://www.eclipse.org/emf/2003/XMLType#integer"/>
> > </eAnnotations>
> > </eClassifiers>
> > The problem lies in here somewhere, since if i add an "id" or a "path"
> > in xml data, which are the other eStructuralFeatures in the class
> > "IfcLengthMeasureType", the problem doesn't
> Version version of EMF are you using? Perhaps this is a bug that's been
> fixed in the latest...
> > show up.
> > Thanks again for your time.
> > João Vaz

Thanks
João Vaz
Re: getResource issue [message #619557 is a reply to message #529882] Tue, 27 April 2010 16:14 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
Vaz,

The problem is that I can't reproduce your problem. You've not modified
the schemas I used directly from the web in any way? Unless I can
reproduce it, I can't do anything about it, so if you want to be look at
this further, you'll need to send me a completely self contained test
case (e.g., exported projects I can import into my workspace) and which
I can execute to see this problem.


Vaz wrote:
> Ed,
>
> Currently I'm working with two versions. - Eclipse 3.6.0 + Emf 2.6.0
> - Eclipse 3.5.0 + Emf 2.5.0
>
> I get same error with both of them.
> Quote:
>> > Shouldn't the "PosType" have a reference to the "PosTypeBase"? I
>> know > the "PosTypeBase" represents a restriction in xml.
>> Well, yes, that was the point of my earlier notes.
>
> Is that a bug or a feature?
>
> Ed Merks wrote on Mon, 26 April 2010 11:59
>> Vaz,
>>
>> Comments below.
>>
>>
>> Vaz wrote:
>> > Ed,
>> >
>> > Just spent a few more minutes analyzing deeply the generated ecores
>> > and after reading the "XML schema to Ecore Mapping pdf" some
>> questions > arise:
>> >
>> > Shouldn't the "PosType" have a reference to the "PosTypeBase"? I
>> know > the "PosTypeBase" represents a restriction in xml.
>> Well, yes, that was the point of my earlier notes.
>> > <eClassifiers xsi:type="ecore:EDataType" name="PosType" >
>> instanceClassName="java.util.List">
>> > <eAnnotations >
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> > <details key="name" value="pos_._type"/>
>> > <details key="minLength" value="1"/>
>> > </eAnnotations>
>> > </eClassifiers>
>> > <eClassifiers xsi:type="ecore:EDataType" name="PosTypeBase" >
>> instanceClassName="java.util.List">
>> > <eAnnotations >
>> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
>> > <details key="name" value="pos_._type_._base"/>
>> > <details key="itemType" >
>> value="http://www.eclipse.org/emf/2003/XMLType#integer"/>
>> > </eAnnotations>
>> > </eClassifiers>
>> > The problem lies in here somewhere, since if i add an "id" or a
>> "path" > in xml data, which are the other eStructuralFeatures in the
>> class > "IfcLengthMeasureType", the problem doesn't
>> Version version of EMF are you using? Perhaps this is a bug that's
>> been fixed in the latest...
>> > show up.
>> > Thanks again for your time.
>> > João Vaz
>
> Thanks
> João Vaz


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:getResource issue
Next Topic:[Announce] Webinar: CDO Model Repository - Apr. 29
Goto Forum:
  


Current Time: Tue Mar 19 04:36:58 GMT 2024

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

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

Back to the top