You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Yoann Moranville <yo...@gmail.com> on 2012/03/29 15:32:19 UTC

XMLCatalogResolver and catalog.xml within jar file

Hi all,

I have a problem using XML catalogs.
Basically, the project is like this:
- main jar file
-- including a "logic" jar file
--- including a few schemas + a catalog.xml file

In the main program, I call an method that should validate an XML file, 
but since it could happen offline, I wanted to use XML catalogs in order 
to have the schema locally. For some reasons, the schemas need to stay 
where they are (in the second jar file).
I use the XSD directly into a Schema object 
(schemaFactory.newSchema(....)), but this schema imports another XSD 
(schema.xsd) which points somewhere online.

It does not quite work, I can not actually read the catalog.xml file 
from the XMLCatalogResolver.

Catalog.xml:
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog 
V1.0//EN" 
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" 
prefer="public">
<uri name="http://www.example.org/schema" uri="schema.xsd"/>
</catalog>

The XMLCatalogResolver accepts an array of String for the setCatalogList 
method. What kind of String should I pass to that method?

Thanks for the help,
Yoann

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: XMLCatalogResolver and catalog.xml within jar file

Posted by Yoann Moranville <yo...@gmail.com>.
Hi Michael,

Thanks for the info, I checked a bit xml-commons resolver component, 
that helped. The resolver seems to use mostly absolute URLs anyway.
It seems the easiest solution is the one working... Passing to the 
setCatalogList a simple URL in external form worked just fine.
---
URL xmlCatalogUrl = .........getResource("/xmlCatalog.xml"); //this XML 
is the same I gave earlier - xsd schemas are next to the xmlCatalog.xml
String[] catalogs = {xmlCatalogUrl.toExternalForm()};
setCatalogList(catalogs);
---

Thanks,
Yoann


On 3/30/12 8:15 PM, Michael Glavassevich wrote:
> Hi Yoann,
>
> The XMLCatalogResolver just passes the catalog file names down to the 
> XML Commons Resolver's Catalog.parseCatalog() method [1]. So 
> XMLCatalogResolver accepts whatever Catalog.parseCatalog() accepts. I 
> know that doesn't really answer your question, though hope you might 
> get closer if you looked at little deeper there.
>
> Thanks.
>
> [1] 
> http://xml.apache.org/commons/components/apidocs/resolver/org/apache/xml/resolver/Catalog.html#parseCatalog%28java.lang.String%29 
>
>
> Michael Glavassevich
> XML Technologies and WAS Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> Yoann Moranville <yo...@gmail.com> wrote on 29/03/2012 
> 09:32:19 AM:
>
> > From: Yoann Moranville <yo...@gmail.com>
> > To: j-users@xerces.apache.org,
> > Date: 29/03/2012 09:38 AM
> > Subject: XMLCatalogResolver and catalog.xml within jar file
> >
> > Hi all,
> >
> > I have a problem using XML catalogs.
> > Basically, the project is like this:
> > - main jar file
> > -- including a "logic" jar file
> > --- including a few schemas + a catalog.xml file
> >
> > In the main program, I call an method that should validate an XML file,
> > but since it could happen offline, I wanted to use XML catalogs in 
> order
> > to have the schema locally. For some reasons, the schemas need to stay
> > where they are (in the second jar file).
> > I use the XSD directly into a Schema object
> > (schemaFactory.newSchema(....)), but this schema imports another XSD
> > (schema.xsd) which points somewhere online.
> >
> > It does not quite work, I can not actually read the catalog.xml file
> > from the XMLCatalogResolver.
> >
> > Catalog.xml:
> > <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog
> > V1.0//EN"
> > "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
> > <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
> > prefer="public">
> > <uri name="http://www.example.org/schema" uri="schema.xsd"/>
> > </catalog>
> >
> > The XMLCatalogResolver accepts an array of String for the 
> setCatalogList
> > method. What kind of String should I pass to that method?
> >
> > Thanks for the help,
> > Yoann
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-users-help@xerces.apache.org 

Re: XMLCatalogResolver and catalog.xml within jar file

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
... looked at little deeper there. --> ... looked a little deeper there.

Michael Glavassevich
XML Technologies and WAS Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Michael Glavassevich <mr...@ca.ibm.com> wrote on 30/03/2012 02:15:18 
PM:
 
> Hi Yoann, 
> 
> The XMLCatalogResolver just passes the catalog file names down to 
> the XML Commons Resolver's Catalog.parseCatalog() method [1]. So 
> XMLCatalogResolver accepts whatever Catalog.parseCatalog() accepts. 
> I know that doesn't really answer your question, though hope you 
> might get closer if you looked at little deeper there. 
> 
> Thanks. 
> 
> [1] http://xml.apache.org/commons/components/apidocs/resolver/org/
> apache/xml/resolver/Catalog.html#parseCatalog%28java.lang.String%29 
> 
> Michael Glavassevich
> XML Technologies and WAS Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com 
> E-mail: mrglavas@apache.org 
> 
> Yoann Moranville <yo...@gmail.com> wrote on 29/03/2012 
09:32:19 AM:
> 
> > From: Yoann Moranville <yo...@gmail.com> 
> > To: j-users@xerces.apache.org, 
> > Date: 29/03/2012 09:38 AM 
> > Subject: XMLCatalogResolver and catalog.xml within jar file 
> > 
> > Hi all,
> > 
> > I have a problem using XML catalogs.
> > Basically, the project is like this:
> > - main jar file
> > -- including a "logic" jar file
> > --- including a few schemas + a catalog.xml file
> > 
> > In the main program, I call an method that should validate an XML 
file, 
> > but since it could happen offline, I wanted to use XML catalogs in 
order 
> > to have the schema locally. For some reasons, the schemas need to stay 

> > where they are (in the second jar file).
> > I use the XSD directly into a Schema object 
> > (schemaFactory.newSchema(....)), but this schema imports another XSD 
> > (schema.xsd) which points somewhere online.
> > 
> > It does not quite work, I can not actually read the catalog.xml file 
> > from the XMLCatalogResolver.
> > 
> > Catalog.xml:
> > <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog 
> > V1.0//EN" 
> > "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
> > <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" 
> > prefer="public">
> > <uri name="http://www.example.org/schema" uri="schema.xsd"/>
> > </catalog>
> > 
> > The XMLCatalogResolver accepts an array of String for the 
setCatalogList 
> > method. What kind of String should I pass to that method?
> > 
> > Thanks for the help,
> > Yoann
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail: j-users-help@xerces.apache.org

Re: XMLCatalogResolver and catalog.xml within jar file

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Yoann,

The XMLCatalogResolver just passes the catalog file names down to the XML 
Commons Resolver's Catalog.parseCatalog() method [1]. So 
XMLCatalogResolver accepts whatever Catalog.parseCatalog() accepts. I know 
that doesn't really answer your question, though hope you might get closer 
if you looked at little deeper there.

Thanks.

[1] 
http://xml.apache.org/commons/components/apidocs/resolver/org/apache/xml/resolver/Catalog.html#parseCatalog%28java.lang.String%29

Michael Glavassevich
XML Technologies and WAS Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Yoann Moranville <yo...@gmail.com> wrote on 29/03/2012 09:32:19 
AM:

> From: Yoann Moranville <yo...@gmail.com>
> To: j-users@xerces.apache.org, 
> Date: 29/03/2012 09:38 AM
> Subject: XMLCatalogResolver and catalog.xml within jar file
> 
> Hi all,
> 
> I have a problem using XML catalogs.
> Basically, the project is like this:
> - main jar file
> -- including a "logic" jar file
> --- including a few schemas + a catalog.xml file
> 
> In the main program, I call an method that should validate an XML file, 
> but since it could happen offline, I wanted to use XML catalogs in order 

> to have the schema locally. For some reasons, the schemas need to stay 
> where they are (in the second jar file).
> I use the XSD directly into a Schema object 
> (schemaFactory.newSchema(....)), but this schema imports another XSD 
> (schema.xsd) which points somewhere online.
> 
> It does not quite work, I can not actually read the catalog.xml file 
> from the XMLCatalogResolver.
> 
> Catalog.xml:
> <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog 
> V1.0//EN" 
> "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" 
> prefer="public">
> <uri name="http://www.example.org/schema" uri="schema.xsd"/>
> </catalog>
> 
> The XMLCatalogResolver accepts an array of String for the setCatalogList 

> method. What kind of String should I pass to that method?
> 
> Thanks for the help,
> Yoann
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org