Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » XML2XMI Serialization with nillable attributes
XML2XMI Serialization with nillable attributes [message #1727936] Tue, 29 March 2016 14:45 Go to next message
Ahmed AHMED is currently offline Ahmed AHMEDFriend
Messages: 10
Registered: December 2015
Junior Member
Hi,
I have a problem converting XML files to XMI containing nillable attributes.
Futhermore, i need to verify my procedure to load XML models using the model editor.
Below is the sequence of steps that i did and the problems that i had.

1. Converting XSD2Ecore
a. Transformed XSD schema to Ecore MM using XSD2ecore.
b. modified the NsPrefix ("set") and the Ns URI values of the generated ecore model.
c. generated the model, edit and editor code.
2. loading XML using the tree editor
After generating the code, i loaded the files after performing two steps:
a. Modiftying the xmlns to the generated ecore model
b. Modifying the file extension to name specified in the nsprefix (myModel.xml -> myModel.set)
The model is loading and everything is working OK.
However, i need to verify whether i am loading the XML model in the right way, or i can do it without modifying the extension and namespace ?

Converting XML2XMI
My real problem exist in this section.
I need to convert the XMLmodel to XMI. Therefore i loaded my XML file using XMLResourceFactoryImplemention with the extended meta data option and save it using XMIResourceImpl with null options.
This conversion works for some xml files, however with some files, i get a NullPointerException. After analyzing the XML files, i found that the problem is due to the existence of nillable attributes in some tags of these file.

I cannot manage to solve this problem and i am looking for your help.

e.g of the XML file.
<Description p5:nil="true" xmlns:p5="http://www.w3.org/2001/XMLSchema-instance" />

The error stack is as follows:

Exception in thread "main" java.lang.NullPointerException
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1114)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1042)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementFeatureMap(XMLSaveImpl.java:2466)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1518)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1224)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2716)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1181)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1042)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementFeatureMap(XMLSaveImpl.java:2466)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1518)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1224)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2716)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1181)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1042)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementFeatureMap(XMLSaveImpl.java:2466)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1518)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1224)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2716)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1181)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1042)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementFeatureMap(XMLSaveImpl.java:2466)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1518)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1224)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2716)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1181)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1042)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementFeatureMap(XMLSaveImpl.java:2466)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1518)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1224)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2716)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1181)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1042)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedSingle(XMLSaveImpl.java:2403)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1547)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1224)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2716)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1181)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1042)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementFeatureMap(XMLSaveImpl.java:2466)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1518)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1224)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2716)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1181)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1042)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementFeatureMap(XMLSaveImpl.java:2466)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1518)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1224)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2716)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XMLSaveImpl.java:683)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveImpl.java:591)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl.java:251)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLResourceImpl.java:389)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1430)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:999)
at testXML2XMI.main(testXML2XMI.java:97)



Re: XML2XMI Serialization with nillable attributes [message #1727938 is a reply to message #1727936] Tue, 29 March 2016 14:53 Go to previous message
Ahmed AHMED is currently offline Ahmed AHMEDFriend
Messages: 10
Registered: December 2015
Junior Member
Sorry, i post the topic in ATL forum by mistake.
Previous Topic:Short DataType is not supported in ATL
Next Topic:Combine / Concatenate matched rules of two modules
Goto Forum:
  


Current Time: Tue Oct 16 03:58:05 GMT 2018

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

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

Back to the top