Main Page | Class Hierarchy | Compound List | File List | Compound Members

BxDomParser.h

00001 // ##################################################################
00002 // Binx
00003 // $Id: BxDomParser_8h-source.html,v 1.1.1.1 2006/04/19 14:19:02 edikt2 Exp $
00004 //
00005 // BxDomParser is a wrapper around a third-party DOM parser.
00006 // ##################################################################
00007 /*
00008 
00009 //  edikt::BinX
00010 //  www.edikt.org
00011 //  support@edikt.org
00012 
00013 // Copyright (c) 2003 The University of Edinburgh.
00014 
00015 */
00016 
00017 
00018 #ifndef __BxDomParser__
00019 #define __BxDomParser__
00020 
00021 #include <xercesc/util/PlatformUtils.hpp>
00022 #include <xercesc/util/XMLString.hpp>
00023 #include <xercesc/dom/DOM.hpp>
00024 
00025 #include "BxObject.h"
00026 #include "BxDomNodeList.h"
00027 #include "BxDomAttributeList.h"
00028 #include "BxDomErrorHandler.h"
00029 
00030 XERCES_CPP_NAMESPACE_USE
00031 
00032 /*
00033  * Class implementing a wrapper for a third party DOM parser.
00034  * The current implementation is specific to the Xerces DOM parser.
00035  * The methods provided by this class are used by the class BxBinxFile
00036  * to read and parse the contents of a BinX document file.
00037  * <BR>Future versions of the BinX library may use a different DOM parser.
00038  * Only this class needs to be rewritten.
00039  */
00040 class DECLSPEC BxDomParser : public BxObject
00041 {
00042     BxDomErrorHandler * errorHandler_; //<error handler
00043     bool errorOccurred_; //<whether has error during parsing
00044 
00045     DOMBuilder * parser_;  //<a DOMBuilder object pointer
00046     DOMDocument * doc_;   //<DOMDocument object pointer
00047     DOMNode * rootNode_;  //< root element of the BinX file, should be <dataset>
00048     DOMNode * defNode_;     //< the <definitions> node
00049 
00050     int  binxVersion_;  //< 0=NON-BinX file, 1=1.0, 2=2.0, not implemented in this version of BinX
00051 
00052 public:
00053     BxDomParser();
00054     BxDomParser(const char * xmlFilename);
00055     virtual ~BxDomParser();
00056 
00057     bool parse(const char * xmlFilename);
00058     bool hasErrors() const { return errorOccurred_; }
00059     bool isBinxFile() const;
00060     BxDomNodeList * getElements() { return new BxDomNodeList(rootNode_->getChildNodes()); }
00061     BxDomNodeList * getTypeDefinitions();  // return a pointer to a list of nodes under <definitions>
00062     BxDomNodeList * getTypeDefinitions(const char * tag);  // return a pointer to a list of nodes under <definitions>
00063     BxDomAttributeList * getDatasetAttributes(); // return pointer to list of attributes for <dataset>
00064     BxDomNodeList * getFiles(); //return a pointer to a list of nodes <file> under <dataset>
00065 
00066 protected:
00067     virtual void init();
00068     virtual void terminate();
00069 };
00070 
00071 
00072 #endif

Generated on Fri May 6 13:36:17 2005 for edikt::BinX by doxygen 1.3.3