This is the code for parsing both the schema and the xml: public static void preParseSchema(final InputStream schema) throws AmtParseException {
grammarPool = new XMLGrammarPoolImpl(); XMLGrammarPreparser preparser = new XMLGrammarPreparser(); ParserErrorHandler errHandler = new ParserErrorHandler(); preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null ); preparser.setProperty(GRAMMAR_POOL, grammarPool); preparser.setFeature(NAMESPACES_FEATURE_ID, true); preparser.setFeature(VALIDATION_FEATURE_ID, true); preparser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true); preparser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); preparser.setFeature(SCHEMA_ELEMENT_DEFAULT_ID, true); preparser.setFeature(SCHEMA_NORMALIZED_VALUE_ID, true); preparser.setErrorHandler(errHandler); // parse the grammar... XMLInputSource inputSource = new XMLInputSource(null,null,null ,schema,null); try { preparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA, inputSource); } catch (IOException e) { throw new AmtParseException(new ParserError("","","" ,e.getMessage())); } catch (XMLParseException e) { //A fatal error has occured and will be reported through the error handler } if (errHandler.hasParseErrors()) throw new AmtParseException(errHandler.getParseErrors()); } /** * Creates a DOM tree, validates according to the schema in the grammer pool. * @param newSet the file to be parsed * @throws AmtParseException when errors occured. */ public static synchronized Document toDomTree(final InputStream newSet){ DOMLineParser parser = new DOMLineParser(); ParserErrorHandler errHandler = new ParserErrorHandler(); // attempt to activate desired features try{ //validate the xml definition according to the dtd/xml schema parser.setFeature(NAMESPACES_FEATURE_ID, true); parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true); parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true); parser.setFeature(SCHEMA_ELEMENT_DEFAULT_ID, true); parser.setFeature(SCHEMA_NORMALIZED_VALUE_ID, true); parser.setFeature(VALIDATION_FEATURE_ID, true); parser.setFeature(DEFERRED_NODE_EXPANSION_ID, false); if (grammarPool!=null) parser.setProperty(GRAMMAR_POOL, grammarPool); }catch (SAXException se) { throw new AmtParseException(new ParserError("","","" ,se.getMessage())); } parser.setErrorHandler(errHandler); InputSource in=new InputSource(newSet); try { parser.parse(in); } catch (SAXException e) { } catch (IOException e) { } return parser.getDocument(); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]