Thanks for your swift answer. I'll get a deeper look on all the hints you gave me before to go further on the problem.
Until then, I explain what I meant by the documentation is wrong (sorry if I was rude using that term). In the XMLEntityResolver Class Reference, one can find the following resolver example: The following resolver would provide the application with a special character stream for the entity with the system identifier "http://www.myhost.com/today": #include <xercesc/util/XMLEntityResolver.hpp> #include <xercesc/sax/InputSource.hpp> class MyResolver : public XMLEntityResolver { public: InputSource resolveEntity (XMLResourceIdentifier* xmlri); ... }; MyResolver::resolveEntity(XMLResourceIdentifier* xmlri) { switch(xmlri->getResourceIdentifierType()) { case XMLResourceIdentifier::SystemId: if (XMLString::compareString(xmlri->getSystemId(), "http://www.myhost.com/today")) { MyReader* reader = new MyReader(); return new InputSource(reader); } else { return null; } break; default: return null; } } And here are the mistakes I noticed, except if I am the one who makes the mistake : - the interface resolveEntity member returns InputSource* instead of InputSource : virtual InputSource* XMLEntityResolver::resolveEntity ( XMLResourceIdentifier * resourceIdentifier ) - XMLResourceIdentifier::SystemId does not exist (that's what my compiler said). >From the documentation, getResourceIdentifierType returns an XMLResourceIdentifier::ResourceIdentifierType value which can be one of the following : SchemaGrammar SchemaImport SchemaInclude SchemaRedefine ExternalEntity UnKnown No SystemId here. So who is wrong: me? the documentation? the source code (I didn't check)? All of us? :) - Emmanuel David Bertoni wrote: > Emmanuel Guiton wrote: >> Hello, >> >> I want to force an XML document validation using an XML Schema. >> I am trying to register an XMLEntityResolver handler to do that (Iam >> suing a DOMParser). Quite difficult for a beginner like me since the >> documentation on http://xml.apache.org/xerces-c/apiDocs is wrong. > > The C++ documentation is generated from the source code using Doxygen, > so I don't know what you mean by saying it's "wrong." Is it > out-of-date? Does it not answer your questions? It's always helpful to > know what's wrong, so we can fix it. > >> Does someone have good hints (a webpage with an example?) on how to >> register an XMLEntityResolver handler? > > You cannot force validation using an XMLEntityResolver, although you can > force the parser to use a particular schema document or documents. Can > you describe exactly what you're doing? For example, users often forget > to set all of the options necessary for schema validation. > >> >> Or does someone have a simpler way to validate an XML file against an >> XML schema (which is stored on my local filesystem)? I've tried using >> setExternalSchemaLocation without any success. > > As long as the document element contains a reference to the schema > location hint you provided, and the proper options are set, it should > work. Have you taken a look at the sample applications to see how to > enable validation? SAX2Print is a good place to start. > > Another option for forcing validation against a particular schema is to > use the proprietary loadGrammar() API. You can then set the feature to > use the cached grammar during parsing: > > http://xml.apache.org/xerces-c/program-sax2.html#use-cached > > Dave > > -- Directeur Elodig SARL 30-32, avenue de la République 94800 Villejuif Tel: 01 46 77 47 68 E-mail: [EMAIL PROTECTED] http://www.elodig.fr
