1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
//-------------------------------------------------------------
// Initialisation de xerces pour la validation des fichiers XML
//-------------------------------------------------------------
XMLPlatformUtils::Initialize();
static const XMLCh gLS[] = {chLatin_L, chLatin_S, chNull};
DOMCountErrorHandler *errorHandler = new DOMCountErrorHandler();
DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(gLS);
DOMBuilder *parser = ((DOMImplementationLS*)impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
parser->setFeature(XMLUni::fgDOMNamespaces, true);
parser->setFeature(XMLUni::fgXercesSchema, true);
parser->setFeature(XMLUni::fgDOMValidation, true);//Always validate schema
// enable datatype normalization - default is off
parser->setFeature(XMLUni::fgDOMDatatypeNormalization, true);
parser->setErrorHandler(errorHandler); //Create error handler and install it
// Chargement du fichier xsd correspondant au fichier xml
XMLCh *schLoc = XMLString::transcode( pathXsdAccelio );
parser->setFeature( XMLUni::fgXercesUseCachedGrammarInParse, true );
parser->loadGrammar( pathXsdAccelio, Grammar::SchemaGrammarType, true );
// Chargement du fichier xml
strcpy( actualFile, tabDdrAccelio[i] );
sprintf( pathDdrAccelio, "%s\\%s", repertoireDdr, tabDdrAccelio[i] );
// Verification du fichier XML
parser->parseURI( XMLString::transcode( pathDdrAccelio ) );
//-----------------------------
// On libère le parseur Xerces
//-----------------------------
XMLPlatformUtils::Terminate(); |
Partager