Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » ResourceSetImpl.getResource exception
ResourceSetImpl.getResource exception [message #24785] Mon, 14 July 2003 14:48 Go to next message
Eclipse UserFriend
Originally posted by: uvrook.mail.nnov.ru

I try to load the scheme from my xsd-file which located on hard disk.
I write:

ResourceSet resourceSet = new ResourceSetImpl();

XSDResourceImpl xsdSchemaResource =
(XSDResourceImpl)resourceSet.getResource
(URI.createFileURI("C://XSD//call.xsd"), true);
or
(URI.createURI("file:///C://XSD//call.xsd"), true);
or
(URI.createURI("file:///C:/XSD/call.xsd"), true);


In any case I get the exception:
"
java.lang.RuntimeException: Cannot create a resource for 'call1.xsd'; a
registered resource factory is needed
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:282)
at xml_generator.parse_xsd$1.getResource(parse_xsd.java:123)
at xml_generator.parse_xsd.traceLoading(parse_xsd.java:149).."

Could you help me, please, what is wrong.
How can I load the scheme into the memory correctly?
Re: ResourceSetImpl.getResource exception [message #24820 is a reply to message #24785] Mon, 14 July 2003 16:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

--------------5F4CEC2D53B1ACCD5B62F51D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Julia,

You haven't registered a parser (as is documented in the working example in
org.eclipse.xsd.test):

public class XSDMainTest // implements IPlatformRunnable
{
{
// This is needed because we can't have the following in the plugin.xml
//
// <extension point = "org.eclipse.emf.extension_parser">
// <parser type="xsd" class="org.eclipse.xsd.util.XSDResourceFactoryImpl"/>

// </extension>
//
// The com.ibm.etools.xsdmodel plugin, shipped with WSAD, has a conflicting
registration for this.
//
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd", new
XSDResourceFactoryImpl());
}

Julia wrote:

> I try to load the scheme from my xsd-file which located on hard disk.
> I write:
>
> ResourceSet resourceSet = new ResourceSetImpl();
>
> XSDResourceImpl xsdSchemaResource =
> (XSDResourceImpl)resourceSet.getResource
> (URI.createFileURI("C://XSD//call.xsd"), true);
> or
> (URI.createURI("file:///C://XSD//call.xsd"), true);
> or
> (URI.createURI("file:///C:/XSD/call.xsd"), true);
>
>
> In any case I get the exception:
> "
> java.lang.RuntimeException: Cannot create a resource for 'call1.xsd'; a
> registered resource factory is needed
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:282)
> at xml_generator.parse_xsd$1.getResource(parse_xsd.java:123)
> at xml_generator.parse_xsd.traceLoading(parse_xsd.java:149).."
>
> Could you help me, please, what is wrong.
> How can I load the scheme into the memory correctly?
>

--------------5F4CEC2D53B1ACCD5B62F51D
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Julia,
<p>You haven't registered a parser (as is documented in the working example
in org.eclipse.xsd.test):
<blockquote><tt>public class XSDMainTest // implements IPlatformRunnable</tt>
<br><tt>{</tt>
<br><tt>&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; // This is needed because we can't have the
following in the plugin.xml</tt>
<br><tt>&nbsp;&nbsp;&nbsp; //</tt>
<br><tt>&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp; &lt;extension point = "org.eclipse.emf.extension_parser"></tt>
<br><tt>&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp; &lt;parser type="xsd"
class="org.eclipse.xsd.util.XSDResourceFactoryImpl"/></tt >
<br><tt>&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp; &lt;/extension></tt>
<br><tt>&nbsp;&nbsp;&nbsp; //</tt>
<br><tt>&nbsp;&nbsp;&nbsp; // The com.ibm.etools.xsdmodel plugin, shipped
with WSAD, has a conflicting registration for this.</tt>
<br><tt>&nbsp;&nbsp;&nbsp; //</tt>
<br><tt>&nbsp;&nbsp;&nbsp; Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd",
new XSDResourceFactoryImpl());</tt>
<br><tt>&nbsp; }</tt></blockquote>
Julia wrote:
<blockquote TYPE=CITE>&nbsp;I try to load the scheme from my xsd-file which
located on hard disk.
<br>&nbsp;I write:
<p>&nbsp;&nbsp; ResourceSet resourceSet = new ResourceSetImpl();
<p>&nbsp;&nbsp; XSDResourceImpl xsdSchemaResource =
<br>&nbsp;&nbsp;&nbsp;&nbsp; (XSDResourceImpl)resourceSet.getResource
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(URI.createFileURI("C://XSD//call.xsd"), true);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (URI.createURI("<a href="file:///C://XSD//call.xsd">file:///C://XSD//call.xsd</a>"),
true);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (URI.createURI("<a href="file:///C:/XSD/call.xsd">file:///C:/XSD/call.xsd</a>"),
true);
<br>&nbsp;
<p>&nbsp;In any case I get the exception:
<br>"
<br>java.lang.RuntimeException: Cannot create a resource for 'call1.xsd';
a
<br>registered resource factory is needed
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:282)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd$1.getResource(parse_xsd.java:123)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd.traceLoading(parse_xsd.java:149).."
<p>&nbsp;Could you help me, please, what is wrong.
<br>&nbsp;How can I load the scheme into the memory correctly?
<br>&nbsp;</blockquote>
</html>

--------------5F4CEC2D53B1ACCD5B62F51D--
Re: ResourceSetImpl.getResource exception [message #24854 is a reply to message #24820] Tue, 15 July 2003 08:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: uvrook.mail.nnov.ru

Ed, many thanks for quick response.
I have fixed this problem, but I have other error now.

I want to load the scheme as in org.eclipse.xsd.test sample:

URI uri;
File file = new File("C:\\xsd\\call1.xsd");
if (file.isFile())
{
uri = URI.createFileURI(file.getCanonicalFile().toString());
}
else
{
uri = URI.createURI(xsdFile);
}

// Create a resource set, create a schema resource, and load the main
schema file into it.
//
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getLoadOptions().put(XSDResourceImpl.XSD_TRACK_L OCATION,
Boolean.TRUE);
XSDResourceImpl xsdMainResource = (XSDResourceImpl)
resourceSet.createResource(URI.createURI("*.xsd"));
xsdMainResource.setURI(uri);
xsdMainResource.load(resourceSet.getLoadOptions);

or simpler:

ResourceSet resourceSet = new ResourceSetImpl();
XSDResourceImpl xsdResource =
(XSDResourceImpl)resourceSet.getResource(uri, true);

In both cases the last row throws such exception :

java.lang.NullPointerException
at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
at
org.eclipse.xsd.util.XSDResourceImpl.createEntityResolver(XS DResourceImpl.java:207)
at
org.eclipse.xsd.util.XSDResourceImpl.getDocument(XSDResource Impl.java:179)
at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:333)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
at xml_generator.parse_xsd.<init>(parse_xsd.java:73)
at xml_generator.parse_xsd.main(parse_xsd.java:107)
java.lang.NullPointerException
at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
at
org.eclipse.xsd.impl.XSDSchemaImpl.getSchemaInstance(XSDSche maImpl.java:707)
at
org.eclipse.xsd.impl.XSDSchemaImpl.resolveSchema(XSDSchemaIm pl.java:2039)
at org.eclipse.xsd.impl.XSDSchemaImpl.patch(XSDSchemaImpl.java: 1485)
at
org.eclipse.xsd.impl.XSDSchemaImpl.changeAttribute(XSDSchema Impl.java:2240)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1205)
at
org.eclipse.xsd.impl.XSDSchemaImpl.setSchemaLocation(XSDSche maImpl.java:842)
at org.eclipse.xsd.util.XSDResourceImpl.attached(XSDResourceImp l.java:410)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl$ContentsELi st.inverseAdd(ResourceImpl.java:326)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:233)
at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:5 70)
at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:374)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
at xml_generator.parse_xsd.<init>(parse_xsd.java:73)
at xml_generator.parse_xsd.main(parse_xsd.java:107)


Could you tell me why I don't load the scheme?
I get such exception if I try to load any xsd-scheme.

I have found recently your library. It's realy very impressive!
I'm from Russia, I hope on your help.



Ed Merks wrote:

> Julia,

> You haven't registered a parser (as is documented in the working example in
> org.eclipse.xsd.test):

> public class XSDMainTest // implements IPlatformRunnable
> {
> {
> // This is needed because we can't have the following in the
plugin.xml
> //
> // <extension point = "org.eclipse.emf.extension_parser">
> // <parser type="xsd"
class="org.eclipse.xsd.util.XSDResourceFactoryImpl"/>

> // </extension>
> //
> // The com.ibm.etools.xsdmodel plugin, shipped with WSAD, has a
conflicting
> registration for this.
> //
>
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd", new
> XSDResourceFactoryImpl());
> }

> Julia wrote:

> > I try to load the scheme from my xsd-file which located on hard disk.
> > I write:
> >
> > ResourceSet resourceSet = new ResourceSetImpl();
> >
> > XSDResourceImpl xsdSchemaResource =
> > (XSDResourceImpl)resourceSet.getResource
> > (URI.createFileURI("C://XSD//call.xsd"), true);
> > or
> > (URI.createURI("file:///C://XSD//call.xsd"), true);
> > or
> > (URI.createURI("file:///C:/XSD/call.xsd"), true);
> >
> >
> > In any case I get the exception:
> > "
> > java.lang.RuntimeException: Cannot create a resource for 'call1.xsd'; a
> > registered resource factory is needed
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:282)
> > at xml_generator.parse_xsd$1.getResource(parse_xsd.java:123)
> > at xml_generator.parse_xsd.traceLoading(parse_xsd.java:149).."
> >
> > Could you help me, please, what is wrong.
> > How can I load the scheme into the memory correctly?
> >
Re: ResourceSetImpl.getResource exception [message #24887 is a reply to message #24854] Tue, 15 July 2003 10:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

--------------B7CB6E68897AC93141F63B26
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Julia,

Have you set up your CLASSPATH as instructed in the FAQ:

http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/xsd- home/faq.html#install_classpath

Julia wrote:

>
>
> Ed, many thanks for quick response.
> I have fixed this problem, but I have other error now.
>
> I want to load the scheme as in org.eclipse.xsd.test sample:
>
> URI uri;
> File file = new File("C:\\xsd\\call1.xsd");
> if (file.isFile())
> {
> uri = URI.createFileURI(file.getCanonicalFile().toString());
> }
> else
> {
> uri = URI.createURI(xsdFile);
> }
>
> // Create a resource set, create a schema resource, and load the main
> schema file into it.
> //
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getLoadOptions().put(XSDResourceImpl.XSD_TRACK_L OCATION,
> Boolean.TRUE);
> XSDResourceImpl xsdMainResource = (XSDResourceImpl)
> resourceSet.createResource(URI.createURI("*.xsd"));
> xsdMainResource.setURI(uri);
> xsdMainResource.load(resourceSet.getLoadOptions);
>
> or simpler:
>
> ResourceSet resourceSet = new ResourceSetImpl();
> XSDResourceImpl xsdResource =
> (XSDResourceImpl)resourceSet.getResource(uri, true);
>
> In both cases the last row throws such exception :
>
> java.lang.NullPointerException
> at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
> at
> org.eclipse.xsd.util.XSDResourceImpl.createEntityResolver(XS DResourceImpl.java:207)
> at
> org.eclipse.xsd.util.XSDResourceImpl.getDocument(XSDResource Impl.java:179)
> at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:333)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
> at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
> at xml_generator.parse_xsd.<init>(parse_xsd.java:73)
> at xml_generator.parse_xsd.main(parse_xsd.java:107)
> java.lang.NullPointerException
> at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
> at
> org.eclipse.xsd.impl.XSDSchemaImpl.getSchemaInstance(XSDSche maImpl.java:707)
> at
> org.eclipse.xsd.impl.XSDSchemaImpl.resolveSchema(XSDSchemaIm pl.java:2039)
> at org.eclipse.xsd.impl.XSDSchemaImpl.patch(XSDSchemaImpl.java: 1485)
> at
> org.eclipse.xsd.impl.XSDSchemaImpl.changeAttribute(XSDSchema Impl.java:2240)
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1205)
> at
> org.eclipse.xsd.impl.XSDSchemaImpl.setSchemaLocation(XSDSche maImpl.java:842)
> at org.eclipse.xsd.util.XSDResourceImpl.attached(XSDResourceImp l.java:410)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl$ContentsELi st.inverseAdd(ResourceImpl.java:326)
> at
> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:233)
> at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:5 70)
> at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:374)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
> at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
> at xml_generator.parse_xsd.<init>(parse_xsd.java:73)
> at xml_generator.parse_xsd.main(parse_xsd.java:107)
>
> Could you tell me why I don't load the scheme?
> I get such exception if I try to load any xsd-scheme.
>
> I have found recently your library. It's realy very impressive!
> I'm from Russia, I hope on your help.
>
> Ed Merks wrote:
>
> > Julia,
>
> > You haven't registered a parser (as is documented in the working example in
> > org.eclipse.xsd.test):
>
> > public class XSDMainTest // implements IPlatformRunnable
> > {
> > {
> > // This is needed because we can't have the following in the
> plugin.xml
> > //
> > // <extension point = "org.eclipse.emf.extension_parser">
> > // <parser type="xsd"
> class="org.eclipse.xsd.util.XSDResourceFactoryImpl"/>
>
> > // </extension>
> > //
> > // The com.ibm.etools.xsdmodel plugin, shipped with WSAD, has a
> conflicting
> > registration for this.
> > //
> >
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd", new
> > XSDResourceFactoryImpl());
> > }
>
> > Julia wrote:
>
> > > I try to load the scheme from my xsd-file which located on hard disk.
> > > I write:
> > >
> > > ResourceSet resourceSet = new ResourceSetImpl();
> > >
> > > XSDResourceImpl xsdSchemaResource =
> > > (XSDResourceImpl)resourceSet.getResource
> > > (URI.createFileURI("C://XSD//call.xsd"), true);
> > > or
> > > (URI.createURI("file:///C://XSD//call.xsd"), true);
> > > or
> > > (URI.createURI("file:///C:/XSD/call.xsd"), true);
> > >
> > >
> > > In any case I get the exception:
> > > "
> > > java.lang.RuntimeException: Cannot create a resource for 'call1.xsd'; a
> > > registered resource factory is needed
> > > at
> > >
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:282)
> > > at xml_generator.parse_xsd$1.getResource(parse_xsd.java:123)
> > > at xml_generator.parse_xsd.traceLoading(parse_xsd.java:149).."
> > >
> > > Could you help me, please, what is wrong.
> > > How can I load the scheme into the memory correctly?
> > >

--------------B7CB6E68897AC93141F63B26
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Julia,
<p>Have you set up your CLASSPATH as instructed in the FAQ:
<blockquote>&nbsp;<a href=" http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/xsd- home/faq.html#install_classpath"> http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/xsd- home/faq.html#install_classpath</a></blockquote>

<p>Julia wrote:
<blockquote TYPE=CITE>&nbsp;
<p>&nbsp;Ed, many thanks for quick response.
<br>&nbsp;I have fixed this problem, but I have other error now.
<p>&nbsp;I want to load the scheme as in org.eclipse.xsd.test sample:
<p>&nbsp;&nbsp;&nbsp; URI uri;
<br>&nbsp;&nbsp;&nbsp; File file = new File("C:\\xsd\\call1.xsd");
<br>&nbsp;&nbsp;&nbsp; if (file.isFile())
<br>&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uri = URI.createFileURI(file.getCanonicalFile().toString());
<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp;&nbsp; else
<br>&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uri = URI.createURI(xsdFile);
<br>&nbsp;&nbsp;&nbsp; }
<p>&nbsp;&nbsp;&nbsp;&nbsp; // Create a resource set, create a schema resource,
and load the main
<br>&nbsp;schema file into it.
<br>&nbsp;&nbsp;&nbsp;&nbsp; //
<br>&nbsp;&nbsp;&nbsp;&nbsp; ResourceSet resourceSet = new ResourceSetImpl();
<br>&nbsp;&nbsp;&nbsp;&nbsp; resourceSet.getLoadOptions().put(XSDResourceImpl.XSD_TRACK_L OCATION,
<br>Boolean.TRUE);
<br>&nbsp;&nbsp;&nbsp;&nbsp; XSDResourceImpl xsdMainResource = (XSDResourceImpl)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
resourceSet.createResource(URI.createURI("*.xsd"));
<br>&nbsp;&nbsp;&nbsp;&nbsp; xsdMainResource.setURI(uri);
<br>&nbsp;&nbsp;&nbsp;&nbsp; xsdMainResource.load(resourceSet.getLoadOptions);
<p>&nbsp;or simpler:
<p>&nbsp;&nbsp;&nbsp;&nbsp; ResourceSet resourceSet = new ResourceSetImpl();
<br>&nbsp;&nbsp;&nbsp;&nbsp; XSDResourceImpl xsdResource =
<br>(XSDResourceImpl)resourceSet.getResource(uri, true);
<p>&nbsp; In both cases the last row throws such exception :
<p>&nbsp;java.lang.NullPointerException
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.xsd.util.XSDResourceImpl.createEntityResolver(XS DResourceImpl.java:207)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.xsd.util.XSDResourceImpl.getDocument(XSDResource Impl.java:179)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:333)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd.&lt;init>(parse_xsd.java:73)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd.main(parse_xsd.java:107)
<br>java.lang.NullPointerException
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.xsd.impl.XSDSchemaImpl.getSchemaInstance(XSDSche maImpl.java:707)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.xsd.impl.XSDSchemaImpl.resolveSchema(XSDSchemaIm pl.java:2039)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at org.eclipse.xsd.impl.XSDSchemaImpl.patch(XSDSchemaImpl.java: 1485)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.xsd.impl.XSDSchemaImpl.changeAttribute(XSDSchema Impl.java:2240)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1205)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.xsd.impl.XSDSchemaImpl.setSchemaLocation(XSDSche maImpl.java:842)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at org.eclipse.xsd.util.XSDResourceImpl.attached(XSDResourceImp l.java:410)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceImpl$ContentsELi st.inverseAdd(ResourceImpl.java:326)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:233)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:5 70)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:374)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd.&lt;init>(parse_xsd.java:73)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd.main(parse_xsd.java:107)
<p>&nbsp; Could you tell me why I don't load the scheme?
<br>&nbsp; I get such exception if I try to load any xsd-scheme.
<p>&nbsp; I have found recently your library. It's realy very impressive!
<br>&nbsp; I'm from Russia, I hope on your help.
<p>Ed Merks wrote:
<p>> Julia,
<p>> You haven't registered a parser (as is documented in the working example
in
<br>> org.eclipse.xsd.test):
<p>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public class XSDMainTest // implements
IPlatformRunnable
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // This is
needed because we can't have the following in the
<br>plugin.xml
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;
&lt;extension point = "org.eclipse.emf.extension_parser">
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;
&lt;parser type="xsd"
<br>class="org.eclipse.xsd.util.XSDResourceFactoryImpl"/>
<p>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;
&lt;/extension>
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // The com.ibm.etools.xsdmodel
plugin, shipped with WSAD, has a
<br>conflicting
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; registration for this.
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //
<br>>
<br> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd",
new
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XSDResourceFactoryImpl());
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }
<p>> Julia wrote:
<p>> >&nbsp; I try to load the scheme from my xsd-file which located on
hard disk.
<br>> >&nbsp; I write:
<br>> >
<br>> >&nbsp;&nbsp;&nbsp; ResourceSet resourceSet = new ResourceSetImpl();
<br>> >
<br>> >&nbsp;&nbsp;&nbsp; XSDResourceImpl xsdSchemaResource =
<br>> >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (XSDResourceImpl)resourceSet.getResource
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
(URI.createFileURI("C://XSD//call.xsd"), true);
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (URI.createURI("<a href="file:///C://XSD//call.xsd">file:///C://XSD//call.xsd</a>"),
true);
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (URI.createURI("<a href="file:///C:/XSD/call.xsd">file:///C:/XSD/call.xsd</a>"),
true);
<br>> >
<br>> >
<br>> >&nbsp; In any case I get the exception:
<br>> > "
<br>> > java.lang.RuntimeException: Cannot create a resource for 'call1.xsd';
a
<br>> > registered resource factory is needed
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; at
<br>> >
<br> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:282)
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; at xml_generator.parse_xsd$1.getResource(parse_xsd.java:123)
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; at xml_generator.parse_xsd.traceLoading(parse_xsd.java:149).."
<br>> >
<br>> >&nbsp; Could you help me, please, what is wrong.
<br>> >&nbsp; How can I load the scheme into the memory correctly?
<br>> ></blockquote>
</html>

--------------B7CB6E68897AC93141F63B26--
Re: ResourceSetImpl.getResource exception [message #25045 is a reply to message #24887] Tue, 15 July 2003 12:50 Go to previous message
Eclipse UserFriend
Originally posted by: uvrook.mail.nnov.ru

Ed, many thanks!

Best regards.
Julia

Ed Merks wrote:

> Julia,

> Have you set up your CLASSPATH as instructed in the FAQ:

>
http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/xsd- home/faq.html#install_classpath

> Julia wrote:

> >
> >
> > Ed, many thanks for quick response.
> > I have fixed this problem, but I have other error now.
> >
> > I want to load the scheme as in org.eclipse.xsd.test sample:
> >
> > URI uri;
> > File file = new File("C:\xsd\call1.xsd");
> > if (file.isFile())
> > {
> > uri = URI.createFileURI(file.getCanonicalFile().toString());
> > }
> > else
> > {
> > uri = URI.createURI(xsdFile);
> > }
> >
> > // Create a resource set, create a schema resource, and load the main
> > schema file into it.
> > //
> > ResourceSet resourceSet = new ResourceSetImpl();
> > resourceSet.getLoadOptions().put(XSDResourceImpl.XSD_TRACK_L OCATION,
> > Boolean.TRUE);
> > XSDResourceImpl xsdMainResource = (XSDResourceImpl)
> > resourceSet.createResource(URI.createURI("*.xsd"));
> > xsdMainResource.setURI(uri);
> > xsdMainResource.load(resourceSet.getLoadOptions);
> >
> > or simpler:
> >
> > ResourceSet resourceSet = new ResourceSetImpl();
> > XSDResourceImpl xsdResource =
> > (XSDResourceImpl)resourceSet.getResource(uri, true);
> >
> > In both cases the last row throws such exception :
> >
> > java.lang.NullPointerException
> > at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
> > at
> >
org.eclipse.xsd.util.XSDResourceImpl.createEntityResolver(XS DResourceImpl.java:207)
> > at
> > org.eclipse.xsd.util.XSDResourceImpl.getDocument(XSDResource Impl.java:179)
> > at
org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:333)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
> > at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
> > at xml_generator.parse_xsd.<init>(parse_xsd.java:73)
> > at xml_generator.parse_xsd.main(parse_xsd.java:107)
> > java.lang.NullPointerException
> > at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
> > at
> >
org.eclipse.xsd.impl.XSDSchemaImpl.getSchemaInstance(XSDSche maImpl.java:707)
> > at
> > org.eclipse.xsd.impl.XSDSchemaImpl.resolveSchema(XSDSchemaIm pl.java:2039)
> > at
org.eclipse.xsd.impl.XSDSchemaImpl.patch(XSDSchemaImpl.java: 1485)
> > at
> > org.eclipse.xsd.impl.XSDSchemaImpl.changeAttribute(XSDSchema Impl.java:2240)
> > at
> >
org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1205)
> > at
> >
org.eclipse.xsd.impl.XSDSchemaImpl.setSchemaLocation(XSDSche maImpl.java:842)
> > at
org.eclipse.xsd.util.XSDResourceImpl.attached(XSDResourceImp l.java:410)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceImpl$ContentsELi st.inverseAdd(ResourceImpl.java:326)
> > at
> >
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:233)
> > at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:5 70)
> > at
org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:374)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
> > at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
> > at xml_generator.parse_xsd.<init>(parse_xsd.java:73)
> > at xml_generator.parse_xsd.main(parse_xsd.java:107)
> >
> > Could you tell me why I don't load the scheme?
> > I get such exception if I try to load any xsd-scheme.
> >
> > I have found recently your library. It's realy very impressive!
> > I'm from Russia, I hope on your help.
> >
> > Ed Merks wrote:
> >
> > > Julia,
> >
> > > You haven't registered a parser (as is documented in the working example
in
> > > org.eclipse.xsd.test):
> >
> > > public class XSDMainTest // implements IPlatformRunnable
> > > {
> > > {
> > > // This is needed because we can't have the following in the
> > plugin.xml
> > > //
> > > // <extension point = "org.eclipse.emf.extension_parser">
> > > // <parser type="xsd"
> > class="org.eclipse.xsd.util.XSDResourceFactoryImpl"/>
> >
> > > // </extension>
> > > //
> > > // The com.ibm.etools.xsdmodel plugin, shipped with WSAD, has a
> > conflicting
> > > registration for this.
> > > //
> > >
> > Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd",
new
> > > XSDResourceFactoryImpl());
> > > }
> >
> > > Julia wrote:
> >
> > > > I try to load the scheme from my xsd-file which located on hard disk.
> > > > I write:
> > > >
> > > > ResourceSet resourceSet = new ResourceSetImpl();
> > > >
> > > > XSDResourceImpl xsdSchemaResource =
> > > > (XSDResourceImpl)resourceSet.getResource
> > > > (URI.createFileURI("C://XSD//call.xsd"), true);
> > > > or
> > > > (URI.createURI("file:///C://XSD//call.xsd"), true);
> > > > or
> > > > (URI.createURI("file:///C:/XSD/call.xsd"), true);
> > > >
> > > >
> > > > In any case I get the exception:
> > > > "
> > > > java.lang.RuntimeException: Cannot create a resource for 'call1.xsd'; a
> > > > registered resource factory is needed
> > > > at
> > > >
> >
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:282)
> > > > at xml_generator.parse_xsd$1.getResource(parse_xsd.java:123)
> > > > at xml_generator.parse_xsd.traceLoading(parse_xsd.java:149).."
> > > >
> > > > Could you help me, please, what is wrong.
> > > > How can I load the scheme into the memory correctly?
> > > >
Re: ResourceSetImpl.getResource exception [message #574113 is a reply to message #24785] Mon, 14 July 2003 16:30 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
--------------5F4CEC2D53B1ACCD5B62F51D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Julia,

You haven't registered a parser (as is documented in the working example in
org.eclipse.xsd.test):

public class XSDMainTest // implements IPlatformRunnable
{
{
// This is needed because we can't have the following in the plugin.xml
//
// <extension point = "org.eclipse.emf.extension_parser">
// <parser type="xsd" class="org.eclipse.xsd.util.XSDResourceFactoryImpl"/>

// </extension>
//
// The com.ibm.etools.xsdmodel plugin, shipped with WSAD, has a conflicting
registration for this.
//
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd", new
XSDResourceFactoryImpl());
}

Julia wrote:

> I try to load the scheme from my xsd-file which located on hard disk.
> I write:
>
> ResourceSet resourceSet = new ResourceSetImpl();
>
> XSDResourceImpl xsdSchemaResource =
> (XSDResourceImpl)resourceSet.getResource
> (URI.createFileURI("C://XSD//call.xsd"), true);
> or
> (URI.createURI("file:///C://XSD//call.xsd"), true);
> or
> (URI.createURI("file:///C:/XSD/call.xsd"), true);
>
>
> In any case I get the exception:
> "
> java.lang.RuntimeException: Cannot create a resource for 'call1.xsd'; a
> registered resource factory is needed
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:282)
> at xml_generator.parse_xsd$1.getResource(parse_xsd.java:123)
> at xml_generator.parse_xsd.traceLoading(parse_xsd.java:149).."
>
> Could you help me, please, what is wrong.
> How can I load the scheme into the memory correctly?
>

--------------5F4CEC2D53B1ACCD5B62F51D
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Julia,
<p>You haven't registered a parser (as is documented in the working example
in org.eclipse.xsd.test):
<blockquote><tt>public class XSDMainTest // implements IPlatformRunnable</tt>
<br><tt>{</tt>
<br><tt>&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; // This is needed because we can't have the
following in the plugin.xml</tt>
<br><tt>&nbsp;&nbsp;&nbsp; //</tt>
<br><tt>&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp; &lt;extension point = "org.eclipse.emf.extension_parser"></tt>
<br><tt>&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp; &lt;parser type="xsd"
class="org.eclipse.xsd.util.XSDResourceFactoryImpl"/></tt >
<br><tt>&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp; &lt;/extension></tt>
<br><tt>&nbsp;&nbsp;&nbsp; //</tt>
<br><tt>&nbsp;&nbsp;&nbsp; // The com.ibm.etools.xsdmodel plugin, shipped
with WSAD, has a conflicting registration for this.</tt>
<br><tt>&nbsp;&nbsp;&nbsp; //</tt>
<br><tt>&nbsp;&nbsp;&nbsp; Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd",
new XSDResourceFactoryImpl());</tt>
<br><tt>&nbsp; }</tt></blockquote>
Julia wrote:
<blockquote TYPE=CITE>&nbsp;I try to load the scheme from my xsd-file which
located on hard disk.
<br>&nbsp;I write:
<p>&nbsp;&nbsp; ResourceSet resourceSet = new ResourceSetImpl();
<p>&nbsp;&nbsp; XSDResourceImpl xsdSchemaResource =
<br>&nbsp;&nbsp;&nbsp;&nbsp; (XSDResourceImpl)resourceSet.getResource
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(URI.createFileURI("C://XSD//call.xsd"), true);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (URI.createURI("<a href="file:///C://XSD//call.xsd">file:///C://XSD//call.xsd</a>"),
true);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; (URI.createURI("<a href="file:///C:/XSD/call.xsd">file:///C:/XSD/call.xsd</a>"),
true);
<br>&nbsp;
<p>&nbsp;In any case I get the exception:
<br>"
<br>java.lang.RuntimeException: Cannot create a resource for 'call1.xsd';
a
<br>registered resource factory is needed
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:282)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd$1.getResource(parse_xsd.java:123)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd.traceLoading(parse_xsd.java:149).."
<p>&nbsp;Could you help me, please, what is wrong.
<br>&nbsp;How can I load the scheme into the memory correctly?
<br>&nbsp;</blockquote>
</html>

--------------5F4CEC2D53B1ACCD5B62F51D--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: ResourceSetImpl.getResource exception [message #574184 is a reply to message #24820] Tue, 15 July 2003 08:01 Go to previous message
Julia is currently offline JuliaFriend
Messages: 85
Registered: July 2009
Member
Ed, many thanks for quick response.
I have fixed this problem, but I have other error now.

I want to load the scheme as in org.eclipse.xsd.test sample:

URI uri;
File file = new File("C:\\xsd\\call1.xsd");
if (file.isFile())
{
uri = URI.createFileURI(file.getCanonicalFile().toString());
}
else
{
uri = URI.createURI(xsdFile);
}

// Create a resource set, create a schema resource, and load the main
schema file into it.
//
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getLoadOptions().put(XSDResourceImpl.XSD_TRACK_L OCATION,
Boolean.TRUE);
XSDResourceImpl xsdMainResource = (XSDResourceImpl)
resourceSet.createResource(URI.createURI("*.xsd"));
xsdMainResource.setURI(uri);
xsdMainResource.load(resourceSet.getLoadOptions);

or simpler:

ResourceSet resourceSet = new ResourceSetImpl();
XSDResourceImpl xsdResource =
(XSDResourceImpl)resourceSet.getResource(uri, true);

In both cases the last row throws such exception :

java.lang.NullPointerException
at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
at
org.eclipse.xsd.util.XSDResourceImpl.createEntityResolver(XS DResourceImpl.java:207)
at
org.eclipse.xsd.util.XSDResourceImpl.getDocument(XSDResource Impl.java:179)
at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:333)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
at xml_generator.parse_xsd.<init>(parse_xsd.java:73)
at xml_generator.parse_xsd.main(parse_xsd.java:107)
java.lang.NullPointerException
at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
at
org.eclipse.xsd.impl.XSDSchemaImpl.getSchemaInstance(XSDSche maImpl.java:707)
at
org.eclipse.xsd.impl.XSDSchemaImpl.resolveSchema(XSDSchemaIm pl.java:2039)
at org.eclipse.xsd.impl.XSDSchemaImpl.patch(XSDSchemaImpl.java: 1485)
at
org.eclipse.xsd.impl.XSDSchemaImpl.changeAttribute(XSDSchema Impl.java:2240)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1205)
at
org.eclipse.xsd.impl.XSDSchemaImpl.setSchemaLocation(XSDSche maImpl.java:842)
at org.eclipse.xsd.util.XSDResourceImpl.attached(XSDResourceImp l.java:410)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl$ContentsELi st.inverseAdd(ResourceImpl.java:326)
at
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:233)
at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:5 70)
at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:374)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
at xml_generator.parse_xsd.<init>(parse_xsd.java:73)
at xml_generator.parse_xsd.main(parse_xsd.java:107)


Could you tell me why I don't load the scheme?
I get such exception if I try to load any xsd-scheme.

I have found recently your library. It's realy very impressive!
I'm from Russia, I hope on your help.



Ed Merks wrote:

> Julia,

> You haven't registered a parser (as is documented in the working example in
> org.eclipse.xsd.test):

> public class XSDMainTest // implements IPlatformRunnable
> {
> {
> // This is needed because we can't have the following in the
plugin.xml
> //
> // <extension point = "org.eclipse.emf.extension_parser">
> // <parser type="xsd"
class="org.eclipse.xsd.util.XSDResourceFactoryImpl"/>

> // </extension>
> //
> // The com.ibm.etools.xsdmodel plugin, shipped with WSAD, has a
conflicting
> registration for this.
> //
>
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd", new
> XSDResourceFactoryImpl());
> }

> Julia wrote:

> > I try to load the scheme from my xsd-file which located on hard disk.
> > I write:
> >
> > ResourceSet resourceSet = new ResourceSetImpl();
> >
> > XSDResourceImpl xsdSchemaResource =
> > (XSDResourceImpl)resourceSet.getResource
> > (URI.createFileURI("C://XSD//call.xsd"), true);
> > or
> > (URI.createURI("file:///C://XSD//call.xsd"), true);
> > or
> > (URI.createURI("file:///C:/XSD/call.xsd"), true);
> >
> >
> > In any case I get the exception:
> > "
> > java.lang.RuntimeException: Cannot create a resource for 'call1.xsd'; a
> > registered resource factory is needed
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:282)
> > at xml_generator.parse_xsd$1.getResource(parse_xsd.java:123)
> > at xml_generator.parse_xsd.traceLoading(parse_xsd.java:149).."
> >
> > Could you help me, please, what is wrong.
> > How can I load the scheme into the memory correctly?
> >
Re: ResourceSetImpl.getResource exception [message #574249 is a reply to message #24854] Tue, 15 July 2003 10:18 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
--------------B7CB6E68897AC93141F63B26
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Julia,

Have you set up your CLASSPATH as instructed in the FAQ:

http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/xsd- home/faq.html#install_classpath

Julia wrote:

>
>
> Ed, many thanks for quick response.
> I have fixed this problem, but I have other error now.
>
> I want to load the scheme as in org.eclipse.xsd.test sample:
>
> URI uri;
> File file = new File("C:\\xsd\\call1.xsd");
> if (file.isFile())
> {
> uri = URI.createFileURI(file.getCanonicalFile().toString());
> }
> else
> {
> uri = URI.createURI(xsdFile);
> }
>
> // Create a resource set, create a schema resource, and load the main
> schema file into it.
> //
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getLoadOptions().put(XSDResourceImpl.XSD_TRACK_L OCATION,
> Boolean.TRUE);
> XSDResourceImpl xsdMainResource = (XSDResourceImpl)
> resourceSet.createResource(URI.createURI("*.xsd"));
> xsdMainResource.setURI(uri);
> xsdMainResource.load(resourceSet.getLoadOptions);
>
> or simpler:
>
> ResourceSet resourceSet = new ResourceSetImpl();
> XSDResourceImpl xsdResource =
> (XSDResourceImpl)resourceSet.getResource(uri, true);
>
> In both cases the last row throws such exception :
>
> java.lang.NullPointerException
> at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
> at
> org.eclipse.xsd.util.XSDResourceImpl.createEntityResolver(XS DResourceImpl.java:207)
> at
> org.eclipse.xsd.util.XSDResourceImpl.getDocument(XSDResource Impl.java:179)
> at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:333)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
> at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
> at xml_generator.parse_xsd.<init>(parse_xsd.java:73)
> at xml_generator.parse_xsd.main(parse_xsd.java:107)
> java.lang.NullPointerException
> at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
> at
> org.eclipse.xsd.impl.XSDSchemaImpl.getSchemaInstance(XSDSche maImpl.java:707)
> at
> org.eclipse.xsd.impl.XSDSchemaImpl.resolveSchema(XSDSchemaIm pl.java:2039)
> at org.eclipse.xsd.impl.XSDSchemaImpl.patch(XSDSchemaImpl.java: 1485)
> at
> org.eclipse.xsd.impl.XSDSchemaImpl.changeAttribute(XSDSchema Impl.java:2240)
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1205)
> at
> org.eclipse.xsd.impl.XSDSchemaImpl.setSchemaLocation(XSDSche maImpl.java:842)
> at org.eclipse.xsd.util.XSDResourceImpl.attached(XSDResourceImp l.java:410)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl$ContentsELi st.inverseAdd(ResourceImpl.java:326)
> at
> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:233)
> at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:5 70)
> at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:374)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
> at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
> at xml_generator.parse_xsd.<init>(parse_xsd.java:73)
> at xml_generator.parse_xsd.main(parse_xsd.java:107)
>
> Could you tell me why I don't load the scheme?
> I get such exception if I try to load any xsd-scheme.
>
> I have found recently your library. It's realy very impressive!
> I'm from Russia, I hope on your help.
>
> Ed Merks wrote:
>
> > Julia,
>
> > You haven't registered a parser (as is documented in the working example in
> > org.eclipse.xsd.test):
>
> > public class XSDMainTest // implements IPlatformRunnable
> > {
> > {
> > // This is needed because we can't have the following in the
> plugin.xml
> > //
> > // <extension point = "org.eclipse.emf.extension_parser">
> > // <parser type="xsd"
> class="org.eclipse.xsd.util.XSDResourceFactoryImpl"/>
>
> > // </extension>
> > //
> > // The com.ibm.etools.xsdmodel plugin, shipped with WSAD, has a
> conflicting
> > registration for this.
> > //
> >
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd", new
> > XSDResourceFactoryImpl());
> > }
>
> > Julia wrote:
>
> > > I try to load the scheme from my xsd-file which located on hard disk.
> > > I write:
> > >
> > > ResourceSet resourceSet = new ResourceSetImpl();
> > >
> > > XSDResourceImpl xsdSchemaResource =
> > > (XSDResourceImpl)resourceSet.getResource
> > > (URI.createFileURI("C://XSD//call.xsd"), true);
> > > or
> > > (URI.createURI("file:///C://XSD//call.xsd"), true);
> > > or
> > > (URI.createURI("file:///C:/XSD/call.xsd"), true);
> > >
> > >
> > > In any case I get the exception:
> > > "
> > > java.lang.RuntimeException: Cannot create a resource for 'call1.xsd'; a
> > > registered resource factory is needed
> > > at
> > >
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:282)
> > > at xml_generator.parse_xsd$1.getResource(parse_xsd.java:123)
> > > at xml_generator.parse_xsd.traceLoading(parse_xsd.java:149).."
> > >
> > > Could you help me, please, what is wrong.
> > > How can I load the scheme into the memory correctly?
> > >

--------------B7CB6E68897AC93141F63B26
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Julia,
<p>Have you set up your CLASSPATH as instructed in the FAQ:
<blockquote>&nbsp;<a href=" http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/xsd- home/faq.html#install_classpath"> http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/xsd- home/faq.html#install_classpath</a></blockquote>

<p>Julia wrote:
<blockquote TYPE=CITE>&nbsp;
<p>&nbsp;Ed, many thanks for quick response.
<br>&nbsp;I have fixed this problem, but I have other error now.
<p>&nbsp;I want to load the scheme as in org.eclipse.xsd.test sample:
<p>&nbsp;&nbsp;&nbsp; URI uri;
<br>&nbsp;&nbsp;&nbsp; File file = new File("C:\\xsd\\call1.xsd");
<br>&nbsp;&nbsp;&nbsp; if (file.isFile())
<br>&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uri = URI.createFileURI(file.getCanonicalFile().toString());
<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp;&nbsp; else
<br>&nbsp;&nbsp;&nbsp; {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uri = URI.createURI(xsdFile);
<br>&nbsp;&nbsp;&nbsp; }
<p>&nbsp;&nbsp;&nbsp;&nbsp; // Create a resource set, create a schema resource,
and load the main
<br>&nbsp;schema file into it.
<br>&nbsp;&nbsp;&nbsp;&nbsp; //
<br>&nbsp;&nbsp;&nbsp;&nbsp; ResourceSet resourceSet = new ResourceSetImpl();
<br>&nbsp;&nbsp;&nbsp;&nbsp; resourceSet.getLoadOptions().put(XSDResourceImpl.XSD_TRACK_L OCATION,
<br>Boolean.TRUE);
<br>&nbsp;&nbsp;&nbsp;&nbsp; XSDResourceImpl xsdMainResource = (XSDResourceImpl)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
resourceSet.createResource(URI.createURI("*.xsd"));
<br>&nbsp;&nbsp;&nbsp;&nbsp; xsdMainResource.setURI(uri);
<br>&nbsp;&nbsp;&nbsp;&nbsp; xsdMainResource.load(resourceSet.getLoadOptions);
<p>&nbsp;or simpler:
<p>&nbsp;&nbsp;&nbsp;&nbsp; ResourceSet resourceSet = new ResourceSetImpl();
<br>&nbsp;&nbsp;&nbsp;&nbsp; XSDResourceImpl xsdResource =
<br>(XSDResourceImpl)resourceSet.getResource(uri, true);
<p>&nbsp; In both cases the last row throws such exception :
<p>&nbsp;java.lang.NullPointerException
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.xsd.util.XSDResourceImpl.createEntityResolver(XS DResourceImpl.java:207)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.xsd.util.XSDResourceImpl.getDocument(XSDResource Impl.java:179)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:333)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd.&lt;init>(parse_xsd.java:73)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd.main(parse_xsd.java:107)
<br>java.lang.NullPointerException
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.xsd.impl.XSDSchemaImpl.getSchemaInstance(XSDSche maImpl.java:707)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.xsd.impl.XSDSchemaImpl.resolveSchema(XSDSchemaIm pl.java:2039)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at org.eclipse.xsd.impl.XSDSchemaImpl.patch(XSDSchemaImpl.java: 1485)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.xsd.impl.XSDSchemaImpl.changeAttribute(XSDSchema Impl.java:2240)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1205)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.xsd.impl.XSDSchemaImpl.setSchemaLocation(XSDSche maImpl.java:842)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at org.eclipse.xsd.util.XSDResourceImpl.attached(XSDResourceImp l.java:410)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceImpl$ContentsELi st.inverseAdd(ResourceImpl.java:326)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:233)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:5 70)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:374)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at
<br> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd.&lt;init>(parse_xsd.java:73)
<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; at xml_generator.parse_xsd.main(parse_xsd.java:107)
<p>&nbsp; Could you tell me why I don't load the scheme?
<br>&nbsp; I get such exception if I try to load any xsd-scheme.
<p>&nbsp; I have found recently your library. It's realy very impressive!
<br>&nbsp; I'm from Russia, I hope on your help.
<p>Ed Merks wrote:
<p>> Julia,
<p>> You haven't registered a parser (as is documented in the working example
in
<br>> org.eclipse.xsd.test):
<p>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public class XSDMainTest // implements
IPlatformRunnable
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // This is
needed because we can't have the following in the
<br>plugin.xml
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;
&lt;extension point = "org.eclipse.emf.extension_parser">
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;
&lt;parser type="xsd"
<br>class="org.eclipse.xsd.util.XSDResourceFactoryImpl"/>
<p>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;
&lt;/extension>
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // The com.ibm.etools.xsdmodel
plugin, shipped with WSAD, has a
<br>conflicting
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; registration for this.
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //
<br>>
<br> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd",
new
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XSDResourceFactoryImpl());
<br>> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }
<p>> Julia wrote:
<p>> >&nbsp; I try to load the scheme from my xsd-file which located on
hard disk.
<br>> >&nbsp; I write:
<br>> >
<br>> >&nbsp;&nbsp;&nbsp; ResourceSet resourceSet = new ResourceSetImpl();
<br>> >
<br>> >&nbsp;&nbsp;&nbsp; XSDResourceImpl xsdSchemaResource =
<br>> >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (XSDResourceImpl)resourceSet.getResource
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
(URI.createFileURI("C://XSD//call.xsd"), true);
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (URI.createURI("<a href="file:///C://XSD//call.xsd">file:///C://XSD//call.xsd</a>"),
true);
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; or
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; (URI.createURI("<a href="file:///C:/XSD/call.xsd">file:///C:/XSD/call.xsd</a>"),
true);
<br>> >
<br>> >
<br>> >&nbsp; In any case I get the exception:
<br>> > "
<br>> > java.lang.RuntimeException: Cannot create a resource for 'call1.xsd';
a
<br>> > registered resource factory is needed
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; at
<br>> >
<br> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:282)
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; at xml_generator.parse_xsd$1.getResource(parse_xsd.java:123)
<br>> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; at xml_generator.parse_xsd.traceLoading(parse_xsd.java:149).."
<br>> >
<br>> >&nbsp; Could you help me, please, what is wrong.
<br>> >&nbsp; How can I load the scheme into the memory correctly?
<br>> ></blockquote>
</html>

--------------B7CB6E68897AC93141F63B26--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: ResourceSetImpl.getResource exception [message #574493 is a reply to message #24887] Tue, 15 July 2003 12:50 Go to previous message
Julia is currently offline JuliaFriend
Messages: 85
Registered: July 2009
Member
Ed, many thanks!

Best regards.
Julia

Ed Merks wrote:

> Julia,

> Have you set up your CLASSPATH as instructed in the FAQ:

>
http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/xsd- home/faq.html#install_classpath

> Julia wrote:

> >
> >
> > Ed, many thanks for quick response.
> > I have fixed this problem, but I have other error now.
> >
> > I want to load the scheme as in org.eclipse.xsd.test sample:
> >
> > URI uri;
> > File file = new File("C:\xsd\call1.xsd");
> > if (file.isFile())
> > {
> > uri = URI.createFileURI(file.getCanonicalFile().toString());
> > }
> > else
> > {
> > uri = URI.createURI(xsdFile);
> > }
> >
> > // Create a resource set, create a schema resource, and load the main
> > schema file into it.
> > //
> > ResourceSet resourceSet = new ResourceSetImpl();
> > resourceSet.getLoadOptions().put(XSDResourceImpl.XSD_TRACK_L OCATION,
> > Boolean.TRUE);
> > XSDResourceImpl xsdMainResource = (XSDResourceImpl)
> > resourceSet.createResource(URI.createURI("*.xsd"));
> > xsdMainResource.setURI(uri);
> > xsdMainResource.load(resourceSet.getLoadOptions);
> >
> > or simpler:
> >
> > ResourceSet resourceSet = new ResourceSetImpl();
> > XSDResourceImpl xsdResource =
> > (XSDResourceImpl)resourceSet.getResource(uri, true);
> >
> > In both cases the last row throws such exception :
> >
> > java.lang.NullPointerException
> > at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
> > at
> >
org.eclipse.xsd.util.XSDResourceImpl.createEntityResolver(XS DResourceImpl.java:207)
> > at
> > org.eclipse.xsd.util.XSDResourceImpl.getDocument(XSDResource Impl.java:179)
> > at
org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:333)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
> > at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
> > at xml_generator.parse_xsd.<init>(parse_xsd.java:73)
> > at xml_generator.parse_xsd.main(parse_xsd.java:107)
> > java.lang.NullPointerException
> > at org.eclipse.emf.common.EMFPlugin.getBaseURL(EMFPlugin.java:1 01)
> > at
> >
org.eclipse.xsd.impl.XSDSchemaImpl.getSchemaInstance(XSDSche maImpl.java:707)
> > at
> > org.eclipse.xsd.impl.XSDSchemaImpl.resolveSchema(XSDSchemaIm pl.java:2039)
> > at
org.eclipse.xsd.impl.XSDSchemaImpl.patch(XSDSchemaImpl.java: 1485)
> > at
> > org.eclipse.xsd.impl.XSDSchemaImpl.changeAttribute(XSDSchema Impl.java:2240)
> > at
> >
org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1205)
> > at
> >
org.eclipse.xsd.impl.XSDSchemaImpl.setSchemaLocation(XSDSche maImpl.java:842)
> > at
org.eclipse.xsd.util.XSDResourceImpl.attached(XSDResourceImp l.java:410)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceImpl$ContentsELi st.inverseAdd(ResourceImpl.java:326)
> > at
> >
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:233)
> > at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:5 70)
> > at
org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl. java:374)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:881)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:755)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:220)
> > at
> >
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:286)
> > at xml_generator.parse_xsd.loadScheme(parse_xsd.java:287)
> > at xml_generator.parse_xsd.<init>(parse_xsd.java:73)
> > at xml_generator.parse_xsd.main(parse_xsd.java:107)
> >
> > Could you tell me why I don't load the scheme?
> > I get such exception if I try to load any xsd-scheme.
> >
> > I have found recently your library. It's realy very impressive!
> > I'm from Russia, I hope on your help.
> >
> > Ed Merks wrote:
> >
> > > Julia,
> >
> > > You haven't registered a parser (as is documented in the working example
in
> > > org.eclipse.xsd.test):
> >
> > > public class XSDMainTest // implements IPlatformRunnable
> > > {
> > > {
> > > // This is needed because we can't have the following in the
> > plugin.xml
> > > //
> > > // <extension point = "org.eclipse.emf.extension_parser">
> > > // <parser type="xsd"
> > class="org.eclipse.xsd.util.XSDResourceFactoryImpl"/>
> >
> > > // </extension>
> > > //
> > > // The com.ibm.etools.xsdmodel plugin, shipped with WSAD, has a
> > conflicting
> > > registration for this.
> > > //
> > >
> > Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xsd",
new
> > > XSDResourceFactoryImpl());
> > > }
> >
> > > Julia wrote:
> >
> > > > I try to load the scheme from my xsd-file which located on hard disk.
> > > > I write:
> > > >
> > > > ResourceSet resourceSet = new ResourceSetImpl();
> > > >
> > > > XSDResourceImpl xsdSchemaResource =
> > > > (XSDResourceImpl)resourceSet.getResource
> > > > (URI.createFileURI("C://XSD//call.xsd"), true);
> > > > or
> > > > (URI.createURI("file:///C://XSD//call.xsd"), true);
> > > > or
> > > > (URI.createURI("file:///C:/XSD/call.xsd"), true);
> > > >
> > > >
> > > > In any case I get the exception:
> > > > "
> > > > java.lang.RuntimeException: Cannot create a resource for 'call1.xsd'; a
> > > > registered resource factory is needed
> > > > at
> > > >
> >
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:282)
> > > > at xml_generator.parse_xsd$1.getResource(parse_xsd.java:123)
> > > > at xml_generator.parse_xsd.traceLoading(parse_xsd.java:149).."
> > > >
> > > > Could you help me, please, what is wrong.
> > > > How can I load the scheme into the memory correctly?
> > > >
Previous Topic:Analysing Schemas
Next Topic:creating xml according to xsd
Goto Forum:
  


Current Time: Wed Apr 24 23:21:03 GMT 2024

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

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

Back to the top