Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Loading Platform Resource URI based XML Schema
Loading Platform Resource URI based XML Schema [message #69251] Fri, 18 August 2006 14:07 Go to next message
Stuart Stephen is currently offline Stuart StephenFriend
Messages: 22
Registered: July 2009
Junior Member
Hi,

I have a standalone application and I have an XML Schema file which is
built into the jar file in the package com.app.test. Unfortunately when I
run this code I get a problem with regards to path mapping not being setup
correctly. I do not know how I can set this up so that it may work. Can
anybody help me?

The error and the code I am using to load the XSDResourceImpl is detailed
below.

java.io.IOException: The path '/com/app/test/my.xsd' is unmapped
at
org.eclipse.emf.ecore.resource.impl.URIConverterImpl.createP latformResourceInputStream(Ljava/lang/String;)Ljava/io/Input Stream;(URIConverterImpl.java:551)
at
org.eclipse.emf.ecore.resource.impl.URIConverterImpl.createI nputStream(Lorg/eclipse/emf/common/util/URI;)Ljava/io/InputS tream;(URIConverterImpl.java:449)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Ljava/ util/Map;)V(ResourceImpl.java:892)
at
com.app.test.XmlSchemaLoading.load()V(OpenTwinsXmlSchemaLoad ing.java:49)
at
com.app.test.XmlSchemaLoading.<init>()V(OpenTwinsXmlSchemaLoading.java:29)
at
com.app.test.XmlSchemaLoading.main([Ljava/lang/String;)V(Ope nTwinsXmlSchemaLoading.java:110)

------------------

//Create a resource set to manage the different resources
ResourceSet resourceSet = new ResourceSetImpl();

//Register XSD resource factory

resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "xsd",
new XSDResourceFactoryImpl());

//Create a resource for this file.
XSDResourceImpl xsdResource =
(XSDResourceImpl)resourceSet.createResource(URI.createPlatfo rmResourceURI( "com/app/test/my.xsd"));

try
{
xsdResource.load(null);
}
catch (IOException e)
{
e.printStackTrace(); // fails here.
}

XSDSchema xsdSchema = xsdResource.getSchema();
Re: Loading Platform Resource URI based XML Schema [message #69271 is a reply to message #69251] Fri, 18 August 2006 14:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Stuart,

You should get the URL within the jar that will access the resource.
I.e., java.lang.Class.getResource to determine the URL and use that
converted to a URI for loading the resource.


Stuart Stephen wrote:
> Hi,
>
> I have a standalone application and I have an XML Schema file which is
> built into the jar file in the package com.app.test. Unfortunately
> when I run this code I get a problem with regards to path mapping not
> being setup correctly. I do not know how I can set this up so that it
> may work. Can anybody help me?
>
> The error and the code I am using to load the XSDResourceImpl is
> detailed below.
>
> java.io.IOException: The path '/com/app/test/my.xsd' is unmapped
> at
> org.eclipse.emf.ecore.resource.impl.URIConverterImpl.createP latformResourceInputStream(Ljava/lang/String;)Ljava/io/Input Stream;(URIConverterImpl.java:551)
>
> at
> org.eclipse.emf.ecore.resource.impl.URIConverterImpl.createI nputStream(Lorg/eclipse/emf/common/util/URI;)Ljava/io/InputS tream;(URIConverterImpl.java:449)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Ljava/ util/Map;)V(ResourceImpl.java:892)
>
> at
> com.app.test.XmlSchemaLoading.load()V(OpenTwinsXmlSchemaLoad ing.java:49)
> at
> com.app.test.XmlSchemaLoading.<init>()V(OpenTwinsXmlSchemaLoading.java:29)
>
> at
> com.app.test.XmlSchemaLoading.main([Ljava/lang/String;)V(Ope nTwinsXmlSchemaLoading.java:110)
>
>
> ------------------
>
> //Create a resource set to manage the different resources
> ResourceSet resourceSet = new ResourceSetImpl();
>
> //Register XSD resource factory
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "xsd",
> new XSDResourceFactoryImpl());
>
> //Create a resource for this file.
> XSDResourceImpl xsdResource =
> (XSDResourceImpl)resourceSet.createResource(URI.createPlatfo rmResourceURI( "com/app/test/my.xsd"));
>
>
> try {
> xsdResource.load(null);
> }
> catch (IOException e) {
> e.printStackTrace(); // fails here.
> }
> XSDSchema xsdSchema = xsdResource.getSchema();
>
>
Re: Loading Platform Resource URI based XML Schema [message #69410 is a reply to message #69271] Mon, 21 August 2006 07:55 Go to previous message
Stuart Stephen is currently offline Stuart StephenFriend
Messages: 22
Registered: July 2009
Junior Member
Thanks, I got this to work fine.
Re: Loading Platform Resource URI based XML Schema [message #598565 is a reply to message #69251] Fri, 18 August 2006 14:32 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Stuart,

You should get the URL within the jar that will access the resource.
I.e., java.lang.Class.getResource to determine the URL and use that
converted to a URI for loading the resource.


Stuart Stephen wrote:
> Hi,
>
> I have a standalone application and I have an XML Schema file which is
> built into the jar file in the package com.app.test. Unfortunately
> when I run this code I get a problem with regards to path mapping not
> being setup correctly. I do not know how I can set this up so that it
> may work. Can anybody help me?
>
> The error and the code I am using to load the XSDResourceImpl is
> detailed below.
>
> java.io.IOException: The path '/com/app/test/my.xsd' is unmapped
> at
> org.eclipse.emf.ecore.resource.impl.URIConverterImpl.createP latformResourceInputStream(Ljava/lang/String;)Ljava/io/Input Stream;(URIConverterImpl.java:551)
>
> at
> org.eclipse.emf.ecore.resource.impl.URIConverterImpl.createI nputStream(Lorg/eclipse/emf/common/util/URI;)Ljava/io/InputS tream;(URIConverterImpl.java:449)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Ljava/ util/Map;)V(ResourceImpl.java:892)
>
> at
> com.app.test.XmlSchemaLoading.load()V(OpenTwinsXmlSchemaLoad ing.java:49)
> at
> com.app.test.XmlSchemaLoading.<init>()V(OpenTwinsXmlSchemaLoading.java:29)
>
> at
> com.app.test.XmlSchemaLoading.main([Ljava/lang/String;)V(Ope nTwinsXmlSchemaLoading.java:110)
>
>
> ------------------
>
> //Create a resource set to manage the different resources
> ResourceSet resourceSet = new ResourceSetImpl();
>
> //Register XSD resource factory
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "xsd",
> new XSDResourceFactoryImpl());
>
> //Create a resource for this file.
> XSDResourceImpl xsdResource =
> (XSDResourceImpl)resourceSet.createResource(URI.createPlatfo rmResourceURI( "com/app/test/my.xsd"));
>
>
> try {
> xsdResource.load(null);
> }
> catch (IOException e) {
> e.printStackTrace(); // fails here.
> }
> XSDSchema xsdSchema = xsdResource.getSchema();
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Loading Platform Resource URI based XML Schema [message #598615 is a reply to message #69271] Mon, 21 August 2006 07:55 Go to previous message
Stuart Stephen is currently offline Stuart StephenFriend
Messages: 22
Registered: July 2009
Junior Member
Thanks, I got this to work fine.
Previous Topic:suggestion to use namespace prefix for nsPrefix in XSD2eCore mapping
Next Topic:How to annotate genmodel with a relative import location?
Goto Forum:
  


Current Time: Thu Apr 25 01:42:16 GMT 2024

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

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

Back to the top