Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » problems loading xml schema with targetNamespace
problems loading xml schema with targetNamespace [message #596995] Wed, 19 October 2005 08:37
Enrique is currently offline Enrique
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)
Previous Topic:The content model with 10,006 states is too large
Next Topic:problems loading xml schema with targetNamespace
Goto Forum:
  


Current Time: Sun Oct 26 07:58:54 GMT 2014

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

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