xml catalog

Having trouble installing Oxygen? Got a bug to report? Post it all here.
ewinston

xml catalog

Post by ewinston »

I am trying to figure out the use os the xml catalog but it appears to be having no effect.

my xml has a schemaLocation attribute that looks like :

Code: Select all


xsi:schemaLocation="
http://a/1.1/ ../../a.xsd
http://b/0.95/ ../../../../../b/M.xsd
http://b/0.95/ ../../../../../b/P.xsd
http://b/0.95/ ../../../../../b/J.xsd"
and my catalog file looks like :

Code: Select all


<rewriteURI
uriStartString="http://a/1.1/"
rewritePrefix="/abs/path/a.xsd"/>
and it still refuses to validate the xml. When i ask it to open external schemas, it looks like it is just looking at the schemaLocation attribute only.

Is there a way to tell if the catalog is getting used? The catalog is in the same directory as my xml files. I i have tried file:// in front of the rewritePrefix and it did not help either.

I'm stumped!

thanks
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Post by Dan »

I would not use the rewrite URI, and also not use relative paths for the shema location. Instead you can try to define some locations using absolute URIs like this:

Code: Select all


xsi:schemaLocation="
http://a/1.1/ http://myserver/X/a.xsd
http://b/0.95/ http://myserver/Y/M.xsd
http://b/0.95/ http://myserver/Y/P.xsd
http://b/0.95/ http://myserver/Y/J.xsd"
(they can exist on a server or not, the catalog will solve them)

And then create a catalog by mapping each system id to a local file. the local file can be specified relative to the catalog file.

Code: Select all


<system systemId="http://myserver/X/a.xsd"
uri="../../a.xsd"/>
<system systemId="http://myserver/Y/M.xsd"
uri="../../../m.xsd"/>
<system systemId="http://myserver/Y/P.xsd"
uri="../../../p.xsd"/>
<system systemId="http://myserver/Y/J.xsd"
uri="../../../j.xsd"/>
Do not forget to restart the editor after modifying a catalog.

Best regards,
Dan
ewinston
Posts: 7
Joined: Thu Feb 05, 2004 7:10 pm

Post by ewinston »

Ok, making the chanes you suggested works. But i am not the one who controls the XML. Is there a way to get the catalog to work with the relative paths in the schemaLocation?

I can try to lobby for changing the xml, but i doubt that would go over well.

thanks
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Post by Dan »

I am not sure about solving relative paths with a catalog. The primary purpose of the catalog is to solve remote files to local ones. Of course, the immediate workaround is to have the XSD file locally, in a directory structure that matchs the relative paths, and avoid using the catalog.

Ex:
In directory:
C:/alpha/beta/
There is a document gamma.xml that refers to schema"../a.xsd".

Then if I put into alpha the a.xsd file the validation will work fine, with no need of an xml catalog.

Regards,
Dan
ewinston
Posts: 7
Joined: Thu Feb 05, 2004 7:10 pm

Post by ewinston »

Yes, the directory structure method is the way things are now, but my directory structure existed before i started working on the xml files, and so i'd need to rearrange things to match, possibly breaking other things i was doing.

Thanks for your help. At least i know something can be done.

edward
ewinston
Posts: 7
Joined: Thu Feb 05, 2004 7:10 pm

Post by ewinston »

Ok, i want to revisit this a bit to try to understand if what i am seeing is an error. I have created the catalog file as explained above, and changed the xml so that URI's are used instead of relative paths in the scemalLocation attribute.

My validation still fails. It appears that not all of the schemas are being searched. I get a message that says a certain element is not defined. I look, and it is defined. If i move the schema up in the list of items in the schemaLocation, then it is found,

So, it appears to be the case that only items in the first xsd of a namespace are found. Is this true? Is there a way around this?

I will try to create an example to better illustrate what i am doing.

thanks
edward
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi Edward,

This is true and this was also discussed a couple of times on the Xerces list. Xerces will consider the first schema it encounters for a namespace as defining everything in that namespace. The solution is simple, you should define a wrapper schema for that namespace that just includes all the sub-schemas.

Hope that helps,
George
Post Reply