Thx Michael.

I read the document and so tried to implement a catalog. Unfortunately
what I did is not working.

First in Java:

        System.setProperty("xml.catalog.files", "C:\\data\\\\config");
        XMLCatalogResolver catalog = new XMLCatalogResolver();
        System.out.println(catalog.getClass().getName());
        builder.setEntityResolver(catalog); 

The output of the system command:

        org.apache.xerces.util.XMLCatalogResolver

By the way I am using DOM for parsing my file.

In my CatalogManager,properties:

        <?xml version="1.0" encoding="UTF-8"?>
        <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
prefer="public">
                <uri name="http://my.uri.com/jmsProperties";
                        uri="JMS_properties.xsd "/>
        </catalog>

In my XML file:

        <JMSProperties xmlns="http://my.uri.com/GRIPP/jmsProperties";
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
                xsi:schemaLocation="http://my.uri.com/jmsProperties
JMS_properties.xsd" >

        .....
        </JMSProperties>

The error I got:

        schema_reference.4: Failed to read schema document
'JMS_properties.xsd', because 1) could not find the document; 2) the
document could not be read; 3) the root element of the document is not
<xsd:schema>. 

Any idea?

Thx!
-----Original Message-----
From: Michael Glavassevich [mailto:[EMAIL PROTECTED] 
Sent: Sunday, September 24, 2006 21:41
To: [email protected]
Subject: RE: Trying to validate XML files using several XSD

"Decoker, Lydie \(Lydie\)" <[EMAIL PROTECTED]> wrote on 09/22/2006
10:43:46 AM:

> Looking into details the xerces documentation, I found that maybe 
> XMLCatalogResolver would fix my issue.
> 
> But how to implement it? 
> If I understood well, it works with target namespace, right?

That's the default behaviour. You can extend the class or write your own
EntityResolver which calls the resolveURI() method on the
XMLCatalogResolver if you want to do something else.

> Also if
> someone could explain with simple words :o) how to write a catalog, it

> would be great.

Try reading this (
http://www-128.ibm.com/developerworks/xml/library/x-mxd3.html)
developerWorks article.

> Lydie.
> 
> From: Prashant [mailto:[EMAIL PROTECTED]
> Sent: Friday, September 22, 2006 14:41
> To: [email protected]
> Subject: Re: Trying to validate XML files using several XSD

> Well, it is a good question. 
> 
> I realize i referred to the "System id" some what loosely. In a DTD 
> the System Id usually points to the http location where DTD is
available. 
> 
> You want to choose a string that is going will uniquely identify the 
> Schema a XML instance is based on. So natural candidate would be the 
> targetNamespace.
> 
> Another candidate can be the http location hint for schema suggested 
> by the XML instance.
> 
> E.g: Consider the web.xml:
> 
> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"; xmlns:xsi="http:
> //www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:
> //java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";
> version="2.4">
> 
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.
> com/xml/ns/j2ee/web-app_2_4.xsd"
> 
> System Id can be : http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd
> 
> However it is not mandatory that the all XMLs leave schemaLocation
hint. 

> 
> -Prashant
> 
> Decoker, Lydie (Lydie) wrote: 
> Yes Prashant. It does help a lot.
> 
> One more question: hou is the system ID set? Is it via the XML?
> 
> Lydie. 
> 
> -----Original Message-----
> From: Prashant [mailto:[EMAIL PROTECTED]
> Sent: Friday, September 22, 2006 10:39
> To: [email protected]
> Subject: Re: Trying to validate XML files using several XSD
> 
> Decoker, Lydie (Lydie) wrote:
> 
> Hello!
> 
> I have corrected my target namespace errors in my diffents xsd files.
> Now when I try to validate my XML file, I got errors like:
> schema_reference.4: Failed to read schema document 'RIRName.xsd', 
> because 1) could not find the document; 2) the document could not be 
> read; 3) the root element of the document is not <xsd:schema>.
> 
> If I use an EntityResolver, this error will not occur again. What I
> 
> did:
> 
>    public InputSource resolveEntity(String publicId, String
> systemId) throws SAXException, IOException {
>       if (systemId.endsWith("Order_L_0_96.xsd")) {
>          return new
> 
> 
>
InputSource(System.getProperty("schemaLocation").concat(File.separator).
> 
> concat("Order_L_0_96.xsd"));
>       } else if (systemId.endsWith("WISkeletons.xsd")) {
>          return new
> 
> 
>
InputSource(System.getProperty("schemaLocation").concat(File.separator).
> 
> concat("WISkeletons.xsd"));
>       }
>       return null;
>    }
> 
> Now I would prefer to avoid to hard-code such an information. Is the 
> catalog a good solution?
> 
> 
> 
> If hard-coding the Schema name does not please your aesthetics, you 
> could very well maintain the mappings between the xsd to local URI 
> like
> this:
> 
> #Properties file that maintains mapping between xsd, local URI.
> Order_L_0_96.xsd=schemas/Order_L_0_96.xsd
> WISkeletons.xsd=schemas/WISkeletons.xsd
> 
> You then put 'schemas' in the classpath, then your implementation of 
> EntityResolver will get the bytes by using 
> Classloader.getResourceAsStream().
> 
> This is infact what Catalog[1] does for you. You have to externalize 
> the mappings between the system Id to local URI to an XML file.
> 
> Hope this helps
> -Prashant
> 
> [1]:http://www.oasis-open.org/committees/entity/spec-2001-08-06.html#d
> 0e
> 533
> 
> Lydie.
> -----Original Message-----
> From: Prashant [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 21, 2006 16:50
> To: [email protected]
> Subject: Re: Trying to validate XML files using several XSD
> 
> Are you talking about OASIS Catalog ? 
> http://www.oasis-open.org/committees/entity/
> 
> I think Catalog is just a standardized way of writing an
> 
> EntityResolver.
> 
> OASIS needs you to produce a standard XML that maps the public Ids to 
> local URIs. By using this method you simply would use library supplied
> 
> 
> 
> implementation of EntityResolve like OASISEntityResolver that 
> understands the Catalog XML.
> 
> Because Catalog is a standardized way, it will come in handy if you 
> were to use tools like <xslt> task of ANT.
> 
> Hope this helps.
> 
> -Prashant
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED] For 
> additional commands, e-mail: [EMAIL PROTECTED]

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to