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#d0e 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]
