Version: 8.3.0
xmlReader Class Reference

base class for parse an xml file, use a dedicated parser, runtime independant. More...

#include <xmlParserBase.hxx>

Inheritance diagram for xmlReader:
Collaboration diagram for xmlReader:

Public Member Functions

 xmlReader (xmlParserBase *parser)
 
virtual void parse (std::string xmlFile)
 

Protected Attributes

xmlParserBase_rootParser
 

Detailed Description

base class for parse an xml file, use a dedicated parser, runtime independant.

Definition at line 40 of file xmlParserBase.hxx.

Constructor & Destructor Documentation

xmlReader::xmlReader ( xmlParserBase parser)

libxml2 parser initialisation

Parameters
parserdedicated parser

Definition at line 336 of file xmlParserBase.cxx.

336  : _rootParser(parser)
337 {
338 }

Member Function Documentation

void xmlReader::parse ( std::string  xmlFile)
virtual

libxml2 parse

Parameters
xmlFilefile to parse

Reimplemented in YACS::ENGINE::stateLoader.

Definition at line 344 of file xmlParserBase.cxx.

References _rootParser, xmlParserBase::_stackParser, xmlParserBase::_xmlParser, xmlParserBase::cdata_block(), xmlParserBase::characters(), xmlParserBase::cleanGarbage(), xmlParserBase::comment(), DEBTRACE, xmlParserBase::end_document(), xmlParserBase::end_element(), xmlParserBase::error(), xmlParserBase::fatal_error(), xmlParserBase::getGarbageSize(), xmlParserBase::init(), saxContext, xmlParserBase::start_document(), xmlParserBase::start_element(), and xmlParserBase::warning().

Referenced by YACS::ENGINE::stateLoader::parse().

345 {
346  _rootParser->init(0);
348 
349  xmlSAXHandler baseHandler =
350  {
351  0, // internal_subset,
352  0, // isStandalone
353  0, // hasInternalSubset
354  0, // hasExternalSubset
355  0, // resolveEntity
356  0, // getEntity
357  0, // entityDecl
358  0, // notationDecl
359  0, // attributeDecl
360  0, // elementDecl
361  0, // unparsedEntityDecl
362  0, // setDocumentLocator
363  xmlParserBase::start_document, // startDocument
364  xmlParserBase::end_document, // endDocument
365  xmlParserBase::start_element, // startElement
366  xmlParserBase::end_element, // endElement
367  0, // reference
368  xmlParserBase::characters, // characters
369  0, // ignorableWhitespace
370  0, // processingInstruction
371  xmlParserBase::comment, // comment
372  xmlParserBase::warning, // warning
373  xmlParserBase::error, // error
374  xmlParserBase::fatal_error, // fatalError
375  0, // getParameterEntity
376  xmlParserBase::cdata_block, // cdataBlock
377  0 // externalSubset
378  };
379 
380  // --- sequence from libxml++, to have a libxml context
381 
382  _xmlParserCtxt* saxContext;
383  saxContext = xmlCreateFileParserCtxt(xmlFile.c_str());
384  if (!saxContext)
385  {
387  string what = "problem while trying to open the file for parsing " + xmlFile;
388  throw Exception(what);
389  }
390  xmlSAXHandlerPtr old_sax = saxContext->sax;
391  saxContext->sax = &baseHandler;
393  saxContext->userData = _rootParser;
394 
395  xmlParseDocument(saxContext);
397  if ( saxContext->myDoc != NULL ) {
398  xmlFreeDoc( saxContext->myDoc );
399  saxContext->myDoc = NULL;
400  }
401  if ( saxContext != NULL ) {
402  saxContext->sax = old_sax;
403  xmlFreeParserCtxt( saxContext );
404  }
405  DEBTRACE("xmlParserBase::end of parse, garbage size = " << _rootParser->getGarbageSize());
406 }

Member Data Documentation

xmlParserBase* xmlReader::_rootParser
protected

Definition at line 46 of file xmlParserBase.hxx.

Referenced by parse(), and YACS::ENGINE::stateLoader::parse().


The documentation for this class was generated from the following files: