1 #ifndef ots_XmlDocument_h
2 #define ots_XmlDocument_h
15 #include <xercesc/dom/DOM.hpp>
16 #include <xercesc/dom/DOMElement.hpp>
17 #include <xercesc/framework/LocalFileFormatTarget.hpp>
18 #include <xercesc/framework/StdOutFormatTarget.hpp>
19 #include <xercesc/parsers/XercesDOMParser.hpp>
20 #include <xercesc/util/OutOfMemoryException.hpp>
21 #include <xercesc/util/PlatformUtils.hpp>
22 #include <xercesc/util/XMLString.hpp>
24 #if defined(XERCES_NEW_IOSTREAMS)
44 xercesc::DOMElement* createChildElement(
const std::string& childClass, xercesc::DOMElement* parent);
45 xercesc::DOMElement* addAttributeToNode(
const std::string& attributeName,
const std::string& attributeValue, xercesc::DOMElement* node);
46 xercesc::DOMElement*
addTextElementToParent(
const std::string& childName,
const std::string& childText, xercesc::DOMElement* parent);
47 xercesc::DOMElement*
addTextElementToParent(
const std::string& childName,
const std::string& childText,
const std::string& parentName,
unsigned int parentIndex = 0);
50 bool loadXmlDocument(
const std::string& filePath);
52 void makeDirectoryBinaryTree(
const std::string& name,
const std::string& rootPath,
int indent, xercesc::DOMElement* anchorNode);
53 xercesc::DOMElement* populateBinaryTreeNode(xercesc::DOMElement* anchorNode,
const std::string& name,
int indent,
bool isLeaf);
54 void setAnchors(
const std::string& fSystemPath,
const std::string& fRootPath);
55 void setDocument(xercesc::DOMDocument* doc);
57 void setRootPath(
const std::string& rootPath) { fRootPath_ = rootPath; }
58 xercesc::DOMElement* getRootElement() {
return rootElement_; }
61 void copyDocument(
const xercesc::DOMDocument* toCopy, xercesc::DOMDocument* copy);
62 void recursiveElementCopy(
const xercesc::DOMElement* toCopy, xercesc::DOMElement* copy);
63 void initDocument(
void);
64 void initPlatform(
void);
65 void terminatePlatform(
void);
66 void recursiveOutputXmlDocument(xercesc::DOMElement* currEl, std::ostringstream* out,
bool dispStdOut =
false,
const std::string& tabStr =
"");
68 xercesc::DOMImplementation* theImplementation_;
69 xercesc::DOMDocument* theDocument_;
70 xercesc::DOMElement* rootElement_;
71 const std::string rootTagName_;
73 xercesc::DOMDocument* doc;
74 xercesc::DOMElement* rootElem;
81 std::string fullFPath;
82 std::stringstream ss_;
83 std::map<int, xercesc::DOMElement*> theNodes_;
84 std::map<int, std::string> theNames_;
85 std::vector<std::string> hierarchyPaths_;
86 xercesc::DOMImplementation* impl;
87 xercesc::DOMLSSerializer* pSerializer;
88 xercesc::DOMConfiguration* pDomConfiguration;
91 std::string fSystemPath_;
92 std::string fRootPath_;
93 std::string fFoldersPath_;
94 std::string fFileName_;
95 std::string fThisFolderPath_;
97 std::map<bool, std::string> isALeaf_;
Note that XmlDocument functionality is extended by HttpXmlDocument class.
xercesc::DOMElement * addTextElementToParent(const std::string &childName, const std::string &childText, xercesc::DOMElement *parent)
void copyDocument(const xercesc::DOMDocument *toCopy, xercesc::DOMDocument *copy)
void recursiveRemoveChild(xercesc::DOMElement *childEl, xercesc::DOMElement *parentEl)
void setDarioStyle(bool darioStyle)
Used by developer Dario Menasce for alternative XML requests at web user interface.
XmlDocument(const std::string &rootName="ROOT")
void saveXmlDocument(const std::string &filePath)
void outputXmlDocument(std::ostringstream *out, bool dispStdOut=false)
void recursiveOutputXmlDocument(xercesc::DOMElement *currEl, std::ostringstream *out, bool dispStdOut=false, const std::string &tabStr="")