Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

SAX and XML Schema

Im using an XML achema to validate an XML document

the schema declaration is
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>

the root tag in the xml file is
<SendingAdapterTransactions
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation='JGA_Sending_Adapter_Transactions_2.xsd'>
the code is as follows
protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";

/**
* Initalise the SAX Parser
*/
public JGA_Properties() {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(true);

try {
parser = factory.newSAXParser();
parser.getXMLReader().setFeature(SCHEMA_VALIDATION_FEATURE_ID,
true);

} catch(ParserConfigurationException exception) {
System.out.println("JGA_eAIMHeader: Parser Configuration Exception
" + exception);

} catch(SAXException exception) {
System.out.println("JGA_eAIMHeader: SAX Exception when creating
parser." + exception);
}
}

but there seems to be no validation taking place. What am i doing wrong ?
[1216 byte] By [Damien] at [2007-11-9 15:22:17]