CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/CalibCalorimetry/HcalTPGAlgos/interface/XMLDOMBlock.h

Go to the documentation of this file.
00001 #ifndef HCALConfigDBTools_XMLTools_XMLDOMBlock_h
00002 #define HCALConfigDBTools_XMLTools_XMLDOMBlock_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     XMLTools
00006 // Class  :     XMLDOMBlock
00007 // 
00016 //
00017 // Original Author:  Gena Kukartsev
00018 //         Created:  Thu Sep 27 01:46:46 CEST 2007
00019 // $Id: XMLDOMBlock.h,v 1.3 2010/08/06 20:24:02 wmtan Exp $
00020 //
00021 
00022 
00023 #include <boost/shared_ptr.hpp>
00024 #include <string>
00025 #include <xercesc/parsers/XercesDOMParser.hpp>
00026 #include <xercesc/sax/HandlerBase.hpp>
00027 #include <xercesc/dom/DOM.hpp>
00028 
00029 //
00030 //_____ following removed as a xalan-c component_____________________
00031 //
00032 //#include <xalanc/DOMSupport/XalanDocumentPrefixResolver.hpp>
00034 //#include <xalanc/XalanSourceTree/XalanSourceTreeDOMSupport.hpp>
00035 //#include <xalanc/XalanSourceTree/XalanSourceTreeInit.hpp>
00036 //#include <xalanc/XalanSourceTree/XalanSourceTreeParserLiaison.hpp>  
00037 //#include <xercesc/framework/LocalFileInputSource.hpp>
00038 //#include <xalanc/XPath/XPathEvaluator.hpp>
00039 
00040 XERCES_CPP_NAMESPACE_USE 
00041 
00042 class XMLProcessor;
00043 
00044 class XMLDOMBlock
00045 {
00046 
00047   friend class XMLProcessor;
00048   
00049  public:
00050 
00051   XMLDOMBlock();
00052   XMLDOMBlock( std::string xmlFileName ); // create XML from template file
00053   XMLDOMBlock( InputSource & _source );
00054   XMLDOMBlock( std::string _root, int rootElementName ); // create XML from scratch, second parameter is a dummy
00055 
00056   DOMDocument * getDocument( void );
00057   DOMDocument * getDocumentConst( void ) const;
00058   DOMDocument * getNewDocument( std::string xmlFileName );
00059   std::string & getString( void );
00060   std::string & getString( DOMNode * _node );
00061   int write( std::string target = "stdout" );
00062   virtual ~XMLDOMBlock();
00063   
00064   const char * getTagValue( const std::string & tagName, int _item = 0, DOMDocument * _document = NULL );
00065   const char * getTagValue( const std::string & tagName, int _item, DOMElement * _document );
00066   const char * getTagAttribute( const std::string & tagName, const std::string & attrName, int _item = 0 );
00067 
00068   DOMElement * add_element(DOMElement * parent, XMLCh * tagname, XMLCh * value);
00069 
00070   DOMNode * setTagValue( const std::string & tagName, const std::string & tagValue, int _item = 0, DOMDocument * _document = NULL );
00071   DOMNode * setTagValue( DOMElement * _elem, const std::string & tagName, const std::string & tagValue, int _item = 0 );
00072   DOMNode * setTagValue( const std::string & tagName, const int & tagValue, int _item = 0, DOMDocument * _document = NULL );
00073   DOMNode * setTagValue( DOMElement * _elem, const std::string & tagName, const int & tagValue, int _item = 0 );
00074   DOMNode * setTagAttribute( const std::string & tagName, const std::string & attrName, const std::string & attrValue, int _item = 0 );
00075   DOMNode * setTagAttribute( DOMElement * _elem, const std::string & tagName, const std::string & attrName, const std::string & attrValue, int _item = 0);
00076   DOMNode * setTagAttribute( const std::string & tagName, const std::string & attrName, const int & attrValue, int _item = 0 );
00077   DOMNode * setTagAttribute( DOMElement * _elem, const std::string & tagName, const std::string & attrName, const int & attrValue, int _item = 0);
00078   std::string getTimestamp( time_t _time );  
00079 
00080   void parse( InputSource & _source );
00081 
00082   XMLDOMBlock & operator+=( const XMLDOMBlock & other);
00083 
00084   //
00085   //_____ following removed as a xalan-c component_____________________
00086   //
00087   //===> Xalan-c (XPath) stuff
00088   //int read_xml_file_xalan( std::string filename );
00089   //const XObjectPtr eval_xpath( std::string context, std::string expression );
00090 
00091  protected:
00092 
00093   int init( std::string _root );
00094 
00095   XMLProcessor * theProcessor;
00096   XercesDOMParser * parser;
00097   ErrorHandler * errHandler;
00098   DOMDocument * document;
00099   std::string theFileName;
00100   std::string * the_string;
00101 
00102   //
00103   //_____ following removed as a xalan-c component_____________________
00104   //
00105   // xalan objects for XPath
00106   //XalanSourceTreeInit * theSourceTreeInit;
00107   //XalanSourceTreeDOMSupport * theDOMSupport;
00108   //XalanSourceTreeParserLiaison * theLiaison;
00109   //const LocalFileInputSource * theInputSource;
00110   //XalanDocument * theDocument;
00111   //XalanDocumentPrefixResolver * thePrefixResolver;
00112   //XPathEvaluator * theEvaluator;
00113 
00114 };
00115 
00116 
00117 #endif