Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » problems loading xml schema with targetNamespace
problems loading xml schema with targetNamespace [message #64618] Wed, 19 October 2005 08:37 Go to next message
Enrique is currently offline EnriqueFriend
Messages: 44
Registered: July 2009
Member
Hi,
I would like would like to load an XML model with a XML schema which is
defined
below. I am using Eclipse 3.1 and EMF 2.1 (I am not using RSA anymore)

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.com.mydb/db"
targetNamespace="http://www.com.mydb/db">

<xsd:complexType name="tableType">
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>

<xsd:complexType name="dataBaseType">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="table" type="tableType"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>

<xsd:element name="dataBase" type="dataBaseType"/>

</xsd:schema>

My XML file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<dataBase name="db12"/>

So, without defining a targetNamespace in the XML schema it works fine.
But with the mentioned targetNamespace "http://www.com.mydb/db" I get a
PackageNotFoundException which is displayed at the bottom...

I guess this comes from the logical URI of the targetNamespace, which
Parser hasn`t the physical URI for, right?
IŽve read something about a URIConverter, which you can use for mapping
logical URIs tu physical URIs.
So IŽve tried the following Java Code:

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).
put("*", new DbResourceFactoryImpl());
ResourceSet resourceSet = new ResourceSetImpl();
URI uri =
URI.createURI("file:/C:/eclipse/workspace/DbPlugin/samples/load/db.xml ");

URI uri1, uri2;
URIConverter converter = resourceSet.getURIConverter();
Map map = converter.getURIMap();
map.put(uri1 = URI.createURI("http://www.com.mydb/db"),
uri2 =
URI.createURI("platform:/resource/DbPlugin/src/xmlSchema/dbSchema.xsd "));

DbResourceImpl resource = (DbResourceImpl) resourceSet.getResource(uri,
true);

I still get the same exception. What still I need to do?
Thanks in advance.




*** THE EXCEPTION:

Exception in thread "main" Wrapped exception
org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
'null' not found.
(file:/C:/eclipse/workspace/DbPlugin/samples/load/db.xml, 2, 23)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:724)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:765)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:462)
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 org.apache.xerces.parsers.AbstractSAXParser.startElement(Unk nown
Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unkn own Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanSt artElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatc her.scanRootElementHook(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragme ntContentDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo cument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
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:988)
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 app.Main.main(Main.java:31)
Wrapped by
Wrapped exception
org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
'null' not found.
(file:/C:/eclipse/workspace/DbPlugin/samples/load/db.xml, 2, 23)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:724)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:765)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:462)
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 org.apache.xerces.parsers.AbstractSAXParser.startElement(Unk nown
Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unkn own Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanSt artElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatc her.scanRootElementHook(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$Fragme ntContentDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo cument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
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:988)
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 app.Main.main(Main.java:31)
Wrapped by
org.eclipse.emf.common.util.WrappedException: Package with uri 'null' not
found. (file:/C:/eclipse/workspace/DbPlugin/samples/load/db.xml, 2, 23)
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 app.Main.main(Main.java:31)
Re: problems loading xml schema with targetNamespace [message #64642 is a reply to message #64618] Wed, 19 October 2005 11:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------060608020102090909070506
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Enrique,

Have you looked closely at the generated *Example.java in the generated
*.tests plugin? That example provides a working example of what things
you need to register when running standalone.

Note that to conform to your schema your instance should look like:

<?xml version="1.0" encoding="UTF-8"?>
<dataBase xmlns="http://www.com.mydb/db" name="db12"/>

or

<?xml version="1.0" encoding="UTF-8"?>
<prefix:dataBase xmlns:prefix="http://www.com.mydb/db" name="db12"/>


Enrique wrote:

> Hi,
> I would like would like to load an XML model with a XML schema which
> is defined below. I am using Eclipse 3.1 and EMF 2.1 (I am not using
> RSA anymore)
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns="http://www.com.mydb/db"
> targetNamespace="http://www.com.mydb/db">
>
> <xsd:complexType name="tableType">
> <xsd:attribute name="name" type="xsd:string" use="required"/>
> </xsd:complexType>
>
> <xsd:complexType name="dataBaseType">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" name="table"
> type="tableType"/>
> </xsd:sequence>
> <xsd:attribute name="name" type="xsd:string" use="required"/>
> </xsd:complexType>
>
> <xsd:element name="dataBase" type="dataBaseType"/>
>
> </xsd:schema>
>
> My XML file looks like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <dataBase name="db12"/>
>
> So, without defining a targetNamespace in the XML schema it works fine.
> But with the mentioned targetNamespace "http://www.com.mydb/db" I get
> a PackageNotFoundException which is displayed at the bottom...
>
> I guess this comes from the logical URI of the targetNamespace, which
> Parser hasn`t the physical URI for, right?
> I
Re: problems loading xml schema with targetNamespace [message #64663 is a reply to message #64642] Wed, 19 October 2005 12:50 Go to previous message
Enrique is currently offline EnriqueFriend
Messages: 44
Registered: July 2009
Member
You`re absolutely right. I didn`t see that yet.
Now it works!
Thank very much for your help.

Best regards, Enrique
Re: problems loading xml schema with targetNamespace [message #597012 is a reply to message #64618] Wed, 19 October 2005 11:42 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060608020102090909070506
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Enrique,

Have you looked closely at the generated *Example.java in the generated
*.tests plugin? That example provides a working example of what things
you need to register when running standalone.

Note that to conform to your schema your instance should look like:

<?xml version="1.0" encoding="UTF-8"?>
<dataBase xmlns="http://www.com.mydb/db" name="db12"/>

or

<?xml version="1.0" encoding="UTF-8"?>
<prefix:dataBase xmlns:prefix="http://www.com.mydb/db" name="db12"/>


Enrique wrote:

> Hi,
> I would like would like to load an XML model with a XML schema which
> is defined below. I am using Eclipse 3.1 and EMF 2.1 (I am not using
> RSA anymore)
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns="http://www.com.mydb/db"
> targetNamespace="http://www.com.mydb/db">
>
> <xsd:complexType name="tableType">
> <xsd:attribute name="name" type="xsd:string" use="required"/>
> </xsd:complexType>
>
> <xsd:complexType name="dataBaseType">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" name="table"
> type="tableType"/>
> </xsd:sequence>
> <xsd:attribute name="name" type="xsd:string" use="required"/>
> </xsd:complexType>
>
> <xsd:element name="dataBase" type="dataBaseType"/>
>
> </xsd:schema>
>
> My XML file looks like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <dataBase name="db12"/>
>
> So, without defining a targetNamespace in the XML schema it works fine.
> But with the mentioned targetNamespace "http://www.com.mydb/db" I get
> a PackageNotFoundException which is displayed at the bottom...
>
> I guess this comes from the logical URI of the targetNamespace, which
> Parser hasn`t the physical URI for, right?
> I


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: problems loading xml schema with targetNamespace [message #597019 is a reply to message #64642] Wed, 19 October 2005 12:50 Go to previous message
Enrique is currently offline EnriqueFriend
Messages: 44
Registered: July 2009
Member
You`re absolutely right. I didn`t see that yet.
Now it works!
Thank very much for your help.

Best regards, Enrique
Previous Topic:problems loading xml schema with targetNamespace
Next Topic:derivation from existing Java classes
Goto Forum:
  


Current Time: Thu Apr 25 08:16:43 GMT 2024

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

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

Back to the top