Hi everybody, hope someone here can help me :)
I am currently trying to validate an XML document using Xerces 2.5.0 against an XML Schema. My problem: I get the following error message: TargetNamespace.2: Expecting no namespace, but the schema document has a target namespace of 'XYZ'. My customer tells me the XML file is valid and that my validator should tell the same, even if there is some problem with my namespace stuff ;) So currently I am trying to switch of the namespace validation. My code is: /** Namespaces feature id (http://xml.org/sax/features/namespaces). */ protected static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces"; /** Namespace prefixes feature id (http://xml.org/sax/features/namespace-prefixes). */ protected static final String NAMESPACE_PREFIXES_FEATURE_ID = "http://xml.org/sax/features/namespace-prefixes"; /** Validation feature id (http://xml.org/sax/features/validation). */ protected static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation"; /** Schema validation feature id (http://apache.org/xml/features/validation/schema). */ protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema"; /** Schema full checking feature id (http://apache.org/xml/features/valid...full-checking). */ protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking"; /** Dynamic validation feature id (http://apache.org/xml/features/validation/dynamic). */ protected static final String DYNAMIC_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/dynamic"; protected static final String SCHEMA_NONS_LOCATION_ID = "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation"; ... SAXParserFactory saxfactory = SAXParserFactory.newInstance(); saxfactory.setValidating(true); saxfactory.setNamespaceAware(false); SAXParser parser = saxfactory.newSAXParser(); XMLReader reader = parser.getXMLReader(); reader.setFeature(NAMESPACES_FEATURE_ID, false); reader.setFeature(NAMESPACE_PREFIXES_FEATURE_ID, false); reader.setFeature(VALIDATION_FEATURE_ID, true); reader.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true); reader.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, false); reader.setFeature(DYNAMIC_VALIDATION_FEATURE_ID, false); reader.setContentHandler(handler); reader.setErrorHandler(handler); reader.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", xsdFile.toURL().toString()); reader.parse(inp); Unfortunately this doesnt work and the validation exception concerning the namespace is still handed over to my error handler. Does anybody have an idea what I could do? Can I switch off the namespace awareness somehow? Is it somehow possible to differ between this namespace exception and other validation exceptions without dirty stuff like parsing the exception message text? -- View this message in context: http://www.nabble.com/Xerces-Validation%3A-No-Namespaces-tf3484801.html#a9728245 Sent from the Xerces - J - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]