Skip to main content



      Home
Home » Modeling » EMF » Problem using Resource given a emf model
Problem using Resource given a emf model [message #397996] Mon, 23 January 2006 06:25 Go to next message
Eclipse UserFriend
Originally posted by: shruthi.cn.in.bosch.com

Hello all,
I have generated a emf model giving a XML schema as input. Then i
generated classes for the model. Now i want to create a XML instance given
an xml file.

To do this, i used Resource api as follows:

Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map m = reg.getExtensionToFactoryMap();
m.put("*", new XMIResourceFactoryImpl());
ResourceSet resSet=new ResourceSetImpl();
URI uriobj =
URI.createURI("file:/D:/projects/DAME_java/wspace/library/Lines.xml ");
Resource res = resSet.getResource(uriobj,true);
Object forum = res.getContents().get(0);

This code generates a "Package with uri 'null' not found." exception when
i execute the getResource method. I have checked up the net where the same
kind of code is used. I dont know whats happening. Could anybody help me
please.


Exception in thread "main" Wrapped exception
org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
'null' not found.
(file:/D:/projects/DAME_java/wspace/library/DashedLines.xml, 2, 68)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:724)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:779)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:462)
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:65)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:449)
at
org.eclipse.emf.ecore.xmi.impl.SAXWrapper.startElement(SAXWr apper.java:73)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(AbstractSAXParser.java:533)
at
com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator. startElement(XMLDTDValidator.java:798)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.j ava:878)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl$ContentDispatcher.scanRootElementHook(XMLDocumentScannerI mpl.java:1157)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFra gmentScannerImpl.java:1794)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java: 368)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:834)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:764)
at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(X MLParser.java:148)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(AbstractSAXParser.java:1242)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:140)
at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:169)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:977)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:832)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:249)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:264)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:349)
at pack1.EmfClass1.main(EmfClass1.java:31)
Wrapped by
org.eclipse.emf.common.util.WrappedException: Package with uri 'null' not
found. (file:/D:/projects/DAME_java/wspace/library/DashedLines.xml, 2, 68)
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:349)
at pack1.EmfClass1.main(EmfClass1.java:31)
Re: Problem using Resource given a emf model [message #398003 is a reply to message #397996] Mon, 23 January 2006 09:04 Go to previous messageGo to next message
Eclipse UserFriend
Shruthi,

Have a look at the generated XyzExample.java in the *.tests plugin.
That will illustrate how to do this correctly.


Shruthi wrote:

> Hello all,
> I have generated a emf model giving a XML schema as input. Then i
> generated classes for the model. Now i want to create a XML instance
> given an xml file.
> To do this, i used Resource api as follows:
> Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
> Map m = reg.getExtensionToFactoryMap();
> m.put("*", new XMIResourceFactoryImpl());
> ResourceSet resSet=new ResourceSetImpl();
> URI uriobj =
> URI.createURI("file:/D:/projects/DAME_java/wspace/library/Lines.xml ");
> Resource res = resSet.getResource(uriobj,true);
> Object forum = res.getContents().get(0);
>
> This code generates a "Package with uri 'null' not found." exception
> when i execute the getResource method. I have checked up the net where
> the same kind of code is used. I dont know whats happening. Could
> anybody help me please.
>
>
> Exception in thread "main" Wrapped exception
> org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
> 'null' not found.
> (file:/D:/projects/DAME_java/wspace/library/DashedLines.xml, 2, 68)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:724)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:779)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:462)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:65)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:449)
>
> at
> org.eclipse.emf.ecore.xmi.impl.SAXWrapper.startElement(SAXWr apper.java:73)
>
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(AbstractSAXParser.java:533)
>
> at
> com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator. startElement(XMLDTDValidator.java:798)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.j ava:878)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl$ContentDispatcher.scanRootElementHook(XMLDocumentScannerI mpl.java:1157)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFra gmentScannerImpl.java:1794)
>
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java: 368)
>
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:834)
>
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(XML11Configuration.java:764)
>
> at
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(X MLParser.java:148)
>
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(AbstractSAXParser.java:1242)
>
> at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:140)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:169)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:977)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:832)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:249)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:264)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:349)
>
> at pack1.EmfClass1.main(EmfClass1.java:31)
> Wrapped by
> org.eclipse.emf.common.util.WrappedException: Package with uri 'null'
> not found.
> (file:/D:/projects/DAME_java/wspace/library/DashedLines.xml, 2, 68)
> 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:349)
>
> at pack1.EmfClass1.main(EmfClass1.java:31)
>
>
>
>
Re: Problem using Resource given a emf model [message #398019 is a reply to message #398003] Tue, 24 January 2006 02:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: shruthi.cn.in.bosch.com

Hello Mr Ed Merks,

I didnt find that xyzExample.java anywhere. Could you please paste lines
of that xyzExample.java in to the mail. Please dont attach the file
because last time when i had posted, the security system did not allow me
to open the file.
This code would be of very great help to me. I have still not found the
correct code.

Thank you very much for your reply.
Best Regards
Shruthi
Re: Problem using Resource given a emf model [message #398022 is a reply to message #398019] Tue, 24 January 2006 04:36 Go to previous message
Eclipse UserFriend
Originally posted by: shruthi.cn.in.bosch.com

Hello Mr Ed Merks,
I was able to find it. Thank you very much for the help.
I am able to run the code successfully.

Thanks again,
Shruthi
Previous Topic:Filtering a View
Next Topic:Can someone give an example for JET on C code generation or JET 's tutorial for C? thanks!
Goto Forum:
  


Current Time: Sat Oct 25 18:41:01 EDT 2025

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

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

Back to the top