Yes, that was very helpful. Thanks Stephen. I am still trying to get this to work. I have had bad experiences in the past in getting XSD validation to work with Java 1.4,
Currently I am getting the following exception: org.xml.sax.SAXParseException: http://www.w3.org/TR/xml-schema-1#SchemaLocation?http://www.nproj.com/japps/AcceptRunRequest at org.exolab.castor.xml.UnmarshalHandler.warning(UnmarshalHandler.java:2420) at org.apache.xerces.util.ErrorHandlerWrapper.warning(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) ...etc. As you can see the exception message is not very descriptive. I am not sure what it is trying to say. This is the code that I was executing: // load castor mapping file Mapping map = new Mapping(); map.loadMapping(mappingPath); // Create an instance of Castor's unmarshaller Unmarshaller unmarshaller = new Unmarshaller(RunDvpRequestVO.class); unmarshaller.setMapping(map); // Create a Reader to the input file that is to be unmarshalled from Reader reader = new FileReader(inputFilePath); // Create content handler for Castor's Unmarshaller UnmarshalHandler unmarshalHandler = unmarshaller.createHandler(); SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); saxParserFactory.setNamespaceAware(true); saxParserFactory.setValidating(true); saxParserFactory.setFeature("http://apache.org/xml/features/validation/schema", true); XMLReader xmlReader = saxParserFactory.newSAXParser().getXMLReader(); xmlReader.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation", "http://www.nproj.com/japps/AcceptRunRequest"); // Not sure if I should be using external-noNamespaceSchemaLocation property instead? //xmlReader.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", xsdFile); xmlReader.setContentHandler(unmarshalHandler); xmlReader.setErrorHandler(unmarshalHandler); xmlReader.parse(new InputSource(reader)); Object obj = unmarshalHandler.getObject(); The following is the XSD schema: <schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.nproj.com/japps/AcceptRunRequest" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:sc1="http://www.nproj.com/japps/AcceptRunRequest"> <element name="Document"> <complexType> [ ... remaining xml was omitted for brevity ...] </element> </schema> And input xml that is to be validated is of the form: <?xml version="1.0" encoding="UTF-8"?> <Document xmlns="http://www.nproj.com/japps/AcceptRunRequest"> <CRITERIAINPUT_LIST> <CRITERIAINPUT> <CRITERIAID>1</CRITERIAID> </CRITERIAINPUT> </CRITERIAINPUT_LIST> [ ... remaining xml was omitted for brevity ...] </Document> -Saladin --- Stephen Bash <[EMAIL PROTECTED]> wrote: > Saladin- > > Sorry, it's apparently on the Properties page rather > than the features page: > > http://xerces.apache.org/xerces2-j/properties.html > > Does that help? > > Stephen > > > On 3/15/07, Saladin Sharif <[EMAIL PROTECTED]> > wrote: > > > > > 1) Instantiate/configure a SAX parser (specify > the > > > external-schema-location feature) > > > > Stephen, > > > > I was not able to find the > external-schema-location > > feature. It is not listed with Xerces: > > > > http://xerces.apache.org/xerces2-j/features.html > > > > > > Could you provide me with a code example on how to > set > > the external-schema-location feature. > > Thanks. > > > > ********************************************************** * Saladin Sharif * e-mail: [EMAIL PROTECTED] * Visit homepage @ http://gaia.ecs.csus.edu/~sharifs ********************************************************** ____________________________________________________________________________________ Food fight? Enjoy some healthy debate in the Yahoo! Answers Food & Drink Q&A. http://answers.yahoo.com/dir/?link=list&sid=396545367 --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email

