CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
XMLDOMBlock.h
Go to the documentation of this file.
1 #ifndef HCALConfigDBTools_XMLTools_XMLDOMBlock_h
2 #define HCALConfigDBTools_XMLTools_XMLDOMBlock_h
3 // -*- C++ -*-
4 //
5 // Package: XMLTools
6 // Class : XMLDOMBlock
7 //
16 //
17 // Original Author: Gena Kukartsev
18 // Created: Thu Sep 27 01:46:46 CEST 2007
19 //
20 
21 #include <string>
22 #include <xercesc/parsers/XercesDOMParser.hpp>
23 #include <xercesc/sax/HandlerBase.hpp>
24 #include <xercesc/dom/DOM.hpp>
25 
26 //
27 //_____ following removed as a xalan-c component_____________________
28 //
29 //#include <xalanc/DOMSupport/XalanDocumentPrefixResolver.hpp>
31 //#include <xalanc/XalanSourceTree/XalanSourceTreeDOMSupport.hpp>
32 //#include <xalanc/XalanSourceTree/XalanSourceTreeInit.hpp>
33 //#include <xalanc/XalanSourceTree/XalanSourceTreeParserLiaison.hpp>
34 //#include <xercesc/framework/LocalFileInputSource.hpp>
35 //#include <xalanc/XPath/XPathEvaluator.hpp>
36 
37 class XMLProcessor;
38 
39 class XMLDOMBlock {
40  friend class XMLProcessor;
41 
42 public:
43  XMLDOMBlock();
44  XMLDOMBlock(std::string xmlFileName); // create XML from template file
45  XMLDOMBlock(XERCES_CPP_NAMESPACE::InputSource& _source);
46  XMLDOMBlock(std::string _root, int rootElementName); // create XML from scratch, second parameter is a dummy
47 
48  XERCES_CPP_NAMESPACE::DOMDocument* getDocument(void);
49  XERCES_CPP_NAMESPACE::DOMDocument* getDocumentConst(void) const;
50  XERCES_CPP_NAMESPACE::DOMDocument* getNewDocument(std::string xmlFileName);
51  std::string& getString(void);
52  std::string& getString(XERCES_CPP_NAMESPACE::DOMNode* _node);
53  int write(std::string target = "stdout");
54  virtual ~XMLDOMBlock();
55 
56  const char* getTagValue(const std::string& tagName,
57  int _item = 0,
58  XERCES_CPP_NAMESPACE::DOMDocument* _document = nullptr);
59  const char* getTagValue(const std::string& tagName, int _item, XERCES_CPP_NAMESPACE::DOMElement* _document);
60  const char* getTagAttribute(const std::string& tagName, const std::string& attrName, int _item = 0);
61 
62  XERCES_CPP_NAMESPACE::DOMElement* add_element(XERCES_CPP_NAMESPACE::DOMElement* parent, XMLCh* tagname, XMLCh* value);
63 
64  XERCES_CPP_NAMESPACE::DOMNode* setTagValue(const std::string& tagName,
65  const std::string& tagValue,
66  int _item = 0,
67  XERCES_CPP_NAMESPACE::DOMDocument* _document = nullptr);
68  XERCES_CPP_NAMESPACE::DOMNode* setTagValue(XERCES_CPP_NAMESPACE::DOMElement* _elem,
69  const std::string& tagName,
70  const std::string& tagValue,
71  int _item = 0);
72  XERCES_CPP_NAMESPACE::DOMNode* setTagValue(const std::string& tagName,
73  const int& tagValue,
74  int _item = 0,
75  XERCES_CPP_NAMESPACE::DOMDocument* _document = nullptr);
76  XERCES_CPP_NAMESPACE::DOMNode* setTagValue(XERCES_CPP_NAMESPACE::DOMElement* _elem,
77  const std::string& tagName,
78  const int& tagValue,
79  int _item = 0);
80  XERCES_CPP_NAMESPACE::DOMNode* setTagAttribute(const std::string& tagName,
81  const std::string& attrName,
82  const std::string& attrValue,
83  int _item = 0);
84  XERCES_CPP_NAMESPACE::DOMNode* setTagAttribute(XERCES_CPP_NAMESPACE::DOMElement* _elem,
85  const std::string& tagName,
86  const std::string& attrName,
87  const std::string& attrValue,
88  int _item = 0);
89  XERCES_CPP_NAMESPACE::DOMNode* setTagAttribute(const std::string& tagName,
90  const std::string& attrName,
91  const int& attrValue,
92  int _item = 0);
93  XERCES_CPP_NAMESPACE::DOMNode* setTagAttribute(XERCES_CPP_NAMESPACE::DOMElement* _elem,
94  const std::string& tagName,
95  const std::string& attrName,
96  const int& attrValue,
97  int _item = 0);
98  std::string getTimestamp(time_t _time);
99 
100  void parse(XERCES_CPP_NAMESPACE::InputSource& _source);
101 
102  XMLDOMBlock& operator+=(const XMLDOMBlock& other);
103 
104  //
105  //_____ following removed as a xalan-c component_____________________
106  //
107  //===> Xalan-c (XPath) stuff
108  //int read_xml_file_xalan( std::string filename );
109  //const XObjectPtr eval_xpath( std::string context, std::string expression );
110 
111 protected:
112  int init(std::string _root);
113 
115  XERCES_CPP_NAMESPACE::XercesDOMParser* parser;
116  XERCES_CPP_NAMESPACE::ErrorHandler* errHandler;
117  XERCES_CPP_NAMESPACE::DOMDocument* document;
120 
121  //
122  //_____ following removed as a xalan-c component_____________________
123  //
124  // xalan objects for XPath
125  //XalanSourceTreeInit * theSourceTreeInit;
126  //XalanSourceTreeDOMSupport * theDOMSupport;
127  //XalanSourceTreeParserLiaison * theLiaison;
128  //const LocalFileInputSource * theInputSource;
129  //XalanDocument * theDocument;
130  //XalanDocumentPrefixResolver * thePrefixResolver;
131  //XPathEvaluator * theEvaluator;
132 };
133 
134 #endif
std::string * the_string
Definition: XMLDOMBlock.h:119
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:117
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:272
XMLProcessor * theProcessor
Definition: XMLDOMBlock.h:114
XERCES_CPP_NAMESPACE::ErrorHandler * errHandler
Definition: XMLDOMBlock.h:116
std::string getTimestamp(time_t _time)
Definition: XMLDOMBlock.cc:410
XERCES_CPP_NAMESPACE::DOMDocument * getDocumentConst(void) const
Definition: XMLDOMBlock.cc:270
XERCES_CPP_NAMESPACE::DOMNode * setTagValue(const std::string &tagName, const std::string &tagValue, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=nullptr)
std::string theFileName
Definition: XMLDOMBlock.h:118
std::string & getString(void)
Definition: XMLDOMBlock.cc:419
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:268
virtual ~XMLDOMBlock()
Definition: XMLDOMBlock.cc:278
XERCES_CPP_NAMESPACE::DOMDocument * getNewDocument(std::string xmlFileName)
Definition: XMLDOMBlock.cc:229
XERCES_CPP_NAMESPACE::XercesDOMParser * parser
Definition: XMLDOMBlock.h:115
XMLDOMBlock & operator+=(const XMLDOMBlock &other)
Definition: XMLDOMBlock.cc:33
int init(std::string _root)
Definition: XMLDOMBlock.cc:142
XERCES_CPP_NAMESPACE::DOMElement * add_element(XERCES_CPP_NAMESPACE::DOMElement *parent, XMLCh *tagname, XMLCh *value)
Definition: XMLDOMBlock.cc:474
const char * getTagValue(const std::string &tagName, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=nullptr)
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute(const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
Definition: XMLDOMBlock.cc:363
void parse(XERCES_CPP_NAMESPACE::InputSource &_source)
Definition: XMLDOMBlock.cc:107
const char * getTagAttribute(const std::string &tagName, const std::string &attrName, int _item=0)
Definition: XMLDOMBlock.cc:356