| Problem using Resource given a emf model [message #397996] |
Mon, 23 January 2006 06:25  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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)
>
>
>
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03425 seconds