Nevermind. I forgot to: ---------- parser->setErrorHandler(&errorHandler); ---------- Sorry for spamming the lists.
Vlad Vladutz Cananau <[EMAIL PROTECTED]> wrote: Hello. I am trying to validate a DOMDocument against a schema using an MemBufInputSource. If the document is valid, the method returns true, as expected. If it is invalid, it exits unexpectedly at the line I added the comment. My code is presented below these remarks: * [serializer] is a valid DOMWriter * [parser] is a valid DOMBuilder * ParseErrorHandler is simply a rename of the DOMCountErrorHandler from the samples. * The schema to use for validation is mentioned in the xml to validate ---------------------------------------------------------------------------------------------------------------- bool XmlDataAccess::Validate(DOMDocument* doc) { MemBufFormatTarget memTarget; serializer->writeNode(&memTarget, *doc); MemBufInputSource input(memTarget.getRawBuffer(), memTarget.getLen(), "1"); Wrapper4InputSource domWrapper(&input, false); ParseErrorHandler errorHandler; errorHandler.resetErrors(); try { cerr<<"here"; // this is outputted parser->parse(domWrapper); // this crashes it cerr<<"here"; // this is not outputted } catch (SAXException* s) { cerr<<"SAX Error during validation parsing"; // never gets here return false; } catch (DOMException* s) { cerr<<"DOM Error during validation parsing"; // never gets here return false; } catch (XMLException* s) { cerr<<"Error during validation parsing"; // never gets here return false; } catch (...) { cerr<<"Unexpected Error"; // never gets here return false; } if(errorHandler.getSawErrors()) { cerr<<"Validation parsing failed"; return false; } else { cerr<<"Validation parsing succeeded"; } return true; } ---------------------------------------------------------------------------------------------------------------- // // Initialization in the ctor // XmlDataAccess::XmlDataAccess() { static const XMLCh gLS[] = { chLatin_L, chLatin_S, chNull }; impl = DOMImplementationRegistry::getDOMImplementation(gLS); parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0); parser->setFeature(XMLUni::fgDOMNamespaces, true); parser->setFeature(XMLUni::fgXercesSchema, true); parser->setFeature(XMLUni::fgXercesSchemaFullChecking, true); parser->setFeature(XMLUni::fgDOMValidateIfSchema, true); parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true); serializer = ((DOMImplementationLS*)impl)->createDOMWriter(); serializer->setEncoding( X("UTF-16") ); } ------------------------------------------------------------------------------------------------------------ Can anyone tell what is wrong? Do you need more info? Thank you, Vlad --------------------------------- Ready for the edge of your seat? Check out tonight's top picks on Yahoo! TV. --------------------------------- Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.