Hi, I am developing a WebServices server and I want to use Xerces to validate XML instances that clients send me with SOAP messages.
First, I tried a simple example to validate an XML instance contained in a file and then validate it with an XSD Schema (i.e. using URIs), and It worked perfectly. Code: parser.setFeature("http://xml.org/sax/features/validation", true); parser.setFeature("http://apache.org/xml/features/validation/schema", true); parser.setFeature( "http://apache.org/xml/features/validation/schema-full-checking",true); parser.setProperty( "http://apache.org/xml/properties/schema/external-schemaLocation", SchemaURI); parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",true); Validator handler = new Validator(); parser.setErrorHandler(handler); parser.parse(XMLDocumentUri); The problem is that then I tried to validate an string containing an XML document, which is the method I want to use, Xerces throws this SAXParseException: cvc-elt.1: Cannot find the declaration of element 'tns:contract'. Code: // the same configuration stuff above written changing the parse call for: parser.parse(new InputSource(new StringReader(StringXmlDocument))); Then I tried to write an empty XML file with the StringXmlDocument content and validate it with its URI, and it worked! But, so as not to have problems with deployment I would like to parse directly the string XML instance... I have used unsuccessfully two different versions of Xerces: 2.6.2 and 2.9.0 The String XML declaration looks like: String StringXmlDocument = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<tns:contract currency=\"\" id=\"\" messageVersion=\"1.0\" providerID=\"\" title=\"\" xmlns:tns=\"http://globalip:8080/hotelres\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://globalip:8080/hotelres hotelres.xsd \">\n" + "<tns:hotel id=\"\" name=\"\"/>\n" + "<tns:roomtypes>\n" + "<tns:roomtype code=\"\" maxpaxes=\"0\" minChildren=\"0\" minadults=\"0\" minpaxes=\"0\"/>\n" + "</tns:roomtypes>\n" + "<tns:paxtypes>\n" .... The XML instance used is the same as the string one. The XML Schema (XSD file) looks like: <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://globalip:8080/hotelres" xmlns:tns="http://globalip:8080/hotelres" elementFormDefault="qualified"> <element name="contract"> <complexType> <sequence> <element name="hotel" type="tns:hotelType"> <annotation> <documentation> Definición del hotel para el cual es el contrato. </documentation> </annotation> </element> .... Any idea? Thanks in advance, Pau --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]