Hi all,
   I am using Xerces-J 2.9.1 and JRE, 1.4.2_05.

I am trying to parse and validate a XML document with Xerces.

I supply XSD Schema to the parser as follows,

xsi:noNamespaceSchemaLocation="schemaFileName.xsd" (this is an
attribute at the root element of the instance document).

My Java program is as below (I have pasted only the relevant portions,
and not the complete program):

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setValidating(true);
spf.setNamespaceAware(true);
SAXParser parser = spf.newSAXParser();
parser.setProperty(
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";,
"http://www.w3.org/2001/XMLSchema";);
parser.parse(new File(filename), this);

This works fine, and the program validates the XML document as expected.

But in this program, I want to get URI string (or the absolute file
path) of the Schema being used.

For this, I tried to change the program as follows:

//rest of the code here is same

parser.setProperty(
       "http://java.sun.com/xml/jaxp/properties/schemaLanguage";,
       "http://www.w3.org/2001/XMLSchema";);
parser.parse(new File(filename), this);

String schmLoc = (String)
parser.getProperty("http://java.sun.com/xml/properties/jaxp/schemaSource";);
System.out.println("schmLoc -->"+schmLoc);

But after running this program, I get the following error:

org.xml.sax.SAXNotRecognizedException: Property 'http://java.sun.com/xml/proper
ies/jaxp/schemaSource' is not recognized.
        at org.apache.xerces.parsers.AbstractSAXParser.getProperty(Unknown Sour
e)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.getProperty(Unkno
n Source)
        at org.apache.xerces.jaxp.SAXParserImpl.getProperty(Unknown Source)
        at SchmValidateSAX.parseFile(SchmValidateSAX.java:32)
        at SchmValidateSAX.main(SchmValidateSAX.java:17)

It seems, the XML parser does not set this property after it has
parsed and validated the XML document.

Can I achieve this with Xerces ...?

-- 
Regards,
Mukul Gandhi

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

Reply via email to