Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Loading XML on the Editor from EMF
Loading XML on the Editor from EMF [message #407466] Thu, 01 March 2007 13:31 Go to next message
Annamalai Chockalingam is currently offline Annamalai ChockalingamFriend
Messages: 49
Registered: July 2009
Member
hello

I have generated a static model along with its edit and editor plugin from
a XML Schema. Now i would like to use the Editor that is generated to load
the XML file.

It just bombs giving an exception.
1st Package URI Null --> this is because the XML doesnt hav a URI

If URI is mentioned
2nd ClassNotFoundException pointing the 1st tag in the XML.

But if i create a file using the New Wizard of EMF and then that file
works fine. But i am not interested in creating a new file, i want to load
an existing XML File.

If i write a main class and load this XML file as we normally write an XML
Resource Load in EMF it works. but just on the editor it doesnt work.

Can you please help me ... ?

regards
Malai
Re: Loading XML on the Editor from EMF [message #407473 is a reply to message #407466] Thu, 01 March 2007 14:36 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Malai,

This should just work unless we broke something. The generated
XyzResourceFactoryImpl should be properly set up to specify the
null-namespace package. How does the resource created by the wizard
look different from the one you are trying to load that fails?


Annamalai C wrote:
> hello
>
> I have generated a static model along with its edit and editor plugin
> from a XML Schema. Now i would like to use the Editor that is
> generated to load the XML file.
>
> It just bombs giving an exception. 1st Package URI Null --> this is
> because the XML doesnt hav a URI
>
> If URI is mentioned
> 2nd ClassNotFoundException pointing the 1st tag in the XML.
>
> But if i create a file using the New Wizard of EMF and then that file
> works fine. But i am not interested in creating a new file, i want to
> load an existing XML File.
>
> If i write a main class and load this XML file as we normally write an
> XML Resource Load in EMF it works. but just on the editor it doesnt work.
>
> Can you please help me ... ?
>
> regards
> Malai
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Loading XML on the Editor from EMF [message #407474 is a reply to message #407473] Thu, 01 March 2007 15:10 Go to previous messageGo to next message
Annamalai Chockalingam is currently offline Annamalai ChockalingamFriend
Messages: 49
Registered: July 2009
Member
Hello Ed

This is my XML called as addressbook.xml
<?xml version='1.0' encoding='UTF-8'?>
<Address_Book
xmlns=" file:/D:/Malai's%20World/Workspaces/Sphinx%20Workspace/org.e clipse.emf.extras.ecore.xmi.dtd/model/dtd/addressbook.xsd ">
<OWNER> Joe Bloggs </OWNER>
<Address_Book_Entry
name="Alastair_Scotland">

<![CDATA[Alastair & Rhona Scotland,
23 The road to nowhere,
Timbucktoo]]>

</Address_Book_Entry>
</Address_Book>

This is how Wizard created File My.addressbook looks

<?xml version="1.0" encoding="UTF-8"?>
<Address_Book>
<Address_Book_Entry name="Alastair_Scotland"><![CDATA[Alastair & Rhona
Scotland,23 The road to nowhere,Timbucktoo]]></Address_Book_Entry>
</Address_Book>


The file that i provide is a .xml and the other one is .addressbook
All i did was in the editor plugin.xml i said this file should also open
not only .addressbook but also .xml in the extension.

This is the exception that i get

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1$Diagno sticWrappedException:
org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'Address_Book' not
found. (platform:/resource/msrprj/addressbook.xml, 2, 141)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDe mandLoadException(ResourceSetImpl.java:307)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:268)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:390)
at
Addressbook.presentation.AddressbookEditor.createModel(Addre ssbookEditor.java:906)
at
Addressbook.presentation.AddressbookEditor.createPages(Addre ssbookEditor.java:962)
at
org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:276)
at
org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:596)
at
org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:372)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:566)
at
org.eclipse.ui.internal.EditorReference.getEditor(EditorRefe rence.java:214)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2595)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2528)
at
org.eclipse.ui.internal.WorkbenchPage.access$10(WorkbenchPag e.java:2520)
at org.eclipse.ui.internal.WorkbenchPage$9.run(WorkbenchPage.ja va:2505)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2500)
at org.eclipse.ui.actions.OpenWithMenu.openEditor(OpenWithMenu. java:288)
at org.eclipse.ui.actions.OpenWithMenu.access$0(OpenWithMenu.ja va:280)
at
org.eclipse.ui.actions.OpenWithMenu$2.handleEvent(OpenWithMe nu.java:184)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3348)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2968)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1914)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:419)
at org.eclip

Ed some reliving escape from this error pls ...Thank you in advance

regards
Malai
Re: Loading XML on the Editor from EMF [message #407478 is a reply to message #407474] Thu, 01 March 2007 17:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Malai,

Your model plugin's plugin.xml will register the generated
XyzResourceFactoryImpl to handle resources with "addressbook"
extension. But that won't kick in for "xml" extension. Only the wizard
created file below looks correct. The other one you show is not a good
instance of a null-namespace schema.

If you want the editor to work for any extension then I suggest you
specialize createModel to add this registration:

// Register the appropriate resource factory to handle all file
extentions.
//

editingDomain.getResourceSet.getResourceFactoryRegistry().ge tExtensionToFactoryMap().put
(Resource.Factory.Registry.DEFAULT_EXTENSION,
new XyzResourceFactoryImpl());


Annamalai C wrote:
> Hello Ed
>
> This is my XML called as addressbook.xml
> <?xml version='1.0' encoding='UTF-8'?>
> <Address_Book
> xmlns=" file:/D:/Malai's%20World/Workspaces/Sphinx%20Workspace/org.e clipse.emf.extras.ecore.xmi.dtd/model/dtd/addressbook.xsd ">
>
> <OWNER> Joe Bloggs </OWNER>
> <Address_Book_Entry
> name="Alastair_Scotland">
>
> <![CDATA[Alastair & Rhona Scotland,
> 23 The road to nowhere,
> Timbucktoo]]>
>
> </Address_Book_Entry>
> </Address_Book>
>
> This is how Wizard created File My.addressbook looks
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Address_Book>
> <Address_Book_Entry name="Alastair_Scotland"><![CDATA[Alastair &
> Rhona Scotland,23 The road to nowhere,Timbucktoo]]></Address_Book_Entry>
> </Address_Book>
>
>
> The file that i provide is a .xml and the other one is .addressbook
> All i did was in the editor plugin.xml i said this file should also
> open not only .addressbook but also .xml in the extension.
>
> This is the exception that i get
>
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1$Diagno sticWrappedException:
> org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'Address_Book'
> not found. (platform:/resource/msrprj/addressbook.xml, 2, 141)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDe mandLoadException(ResourceSetImpl.java:307)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:268)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:390)
>
> at
> Addressbook.presentation.AddressbookEditor.createModel(Addre ssbookEditor.java:906)
>
> at
> Addressbook.presentation.AddressbookEditor.createPages(Addre ssbookEditor.java:962)
>
> at
> org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:276)
>
> at
> org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:596)
>
> at
> org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:372)
>
> at
> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:566)
>
> at
> org.eclipse.ui.internal.EditorReference.getEditor(EditorRefe rence.java:214)
>
> at
> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2595)
>
> at
> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2528)
>
> at
> org.eclipse.ui.internal.WorkbenchPage.access$10(WorkbenchPag e.java:2520)
> at
> org.eclipse.ui.internal.WorkbenchPage$9.run(WorkbenchPage.ja va:2505)
> at
> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2500)
> at
> org.eclipse.ui.actions.OpenWithMenu.openEditor(OpenWithMenu. java:288)
> at
> org.eclipse.ui.actions.OpenWithMenu.access$0(OpenWithMenu.ja va:280)
> at
> org.eclipse.ui.actions.OpenWithMenu$2.handleEvent(OpenWithMe nu.java:184)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
> at
> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3348)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2968)
> at
> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1914)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:419)
>
> at org.eclip
>
> Ed some reliving escape from this error pls ...Thank you in advance
>
> regards
> Malai
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Loading XML on the Editor from EMF [message #407566 is a reply to message #407478] Mon, 05 March 2007 09:34 Go to previous messageGo to next message
Annamalai Chockalingam is currently offline Annamalai ChockalingamFriend
Messages: 49
Registered: July 2009
Member
Hello ED

I have this typical problem ...
My model is obtained using XSD as input. Now the XSD has changed a little
bit but all the old values are still valid ... but in the new XSD my
namespace has changed.

So the XML files corresponding to the new XSD have the new namespace but
the old ones still have the old namespace. So if i load the old one it has
a different name space .. so crashes ...

Is there any way to suppress the namespace consideration while loading?

regards
Malai
Re: Loading XML on the Editor from EMF [message #407575 is a reply to message #407566] Mon, 05 March 2007 17:16 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Malai,

An Ecore to Ecore mapping between the two could be used to solve a
problem like this. There have been quite a few previous questions about
that mapping support, so you could search for those. This particular
problem could be quite easily solved with a derived implementation
BasicExtendedMetaData that overrides getPackage, getLocalElement, and
getLocalAttribute to substitute the new namespace for the old namespace.


Annamalai C wrote:
> Hello ED
>
> I have this typical problem ...
> My model is obtained using XSD as input. Now the XSD has changed a
> little bit but all the old values are still valid ... but in the new
> XSD my namespace has changed.
> So the XML files corresponding to the new XSD have the new namespace
> but the old ones still have the old namespace. So if i load the old
> one it has a different name space .. so crashes ...
>
> Is there any way to suppress the namespace consideration while loading?
>
> regards
> Malai
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:schema validation
Next Topic:use "new" externalization
Goto Forum:
  


Current Time: Fri Apr 26 02:34:49 GMT 2024

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

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

Back to the top