mbxmlutils  1.3.0
Multi-Body XML Utils
dom.h
1 #ifndef _MBXMLUTILSHELPER_DOM_H_
2 #define _MBXMLUTILSHELPER_DOM_H_
3 
4 #include <fmatvec/atom.h>
5 #include <string>
6 #include <utility>
7 #include <vector>
8 #include <map>
9 #include <set>
10 #include <variant>
11 #include <boost/filesystem.hpp>
12 #include <xercesc/dom/DOMErrorHandler.hpp>
13 #include <xercesc/dom/DOMElement.hpp>
14 #include <xercesc/dom/DOMText.hpp>
15 #include <xercesc/dom/DOMLSParser.hpp>
16 #include <xercesc/dom/DOMLocator.hpp>
17 #include <xercesc/dom/DOMUserDataHandler.hpp>
18 #include <xercesc/dom/DOMDocument.hpp>
19 #include <xercesc/util/TransService.hpp>
20 #include <xercesc/util/XMLEntityResolver.hpp>
21 #include <xercesc/framework/psvi/PSVIHandler.hpp>
22 #include <boost/lexical_cast.hpp>
23 #include <fmatvec/toString.h>
24 
25 namespace XERCES_CPP_NAMESPACE {
26  class DOMProcessingInstruction;
27  class DOMImplementation;
28  class AbstractDOMParser;
29 }
30 
31 namespace boost {
32  template<> std::vector<double> lexical_cast(const std::string& str);
33  template<> std::vector<std::vector<double>> lexical_cast(const std::string& str);
34  template<> std::vector<int> lexical_cast(const std::string& str);
35  template<> std::vector<std::vector<int>> lexical_cast(const std::string& str);
36  template<> bool lexical_cast<bool>(const std::string& arg);
37 }
38 
39 namespace {
40 
41 template<class T>
42 struct CheckSize {
43  static void check(const xercesc::DOMElement *me, const T &value, int r, int c);
44 };
45 template<class T>
46 struct CheckSize<std::vector<T>> {
47  static void check(const xercesc::DOMElement *me, const std::vector<T> &value, int r, int c);
48 };
49 template<class T>
50 struct CheckSize<std::vector<std::vector<T>>> {
51  static void check(const xercesc::DOMElement *me, const std::vector<std::vector<T>> &value, int r, int c);
52 };
53 
54 }
55 
56 namespace MBXMLUtils {
57 
58 // forward declaration
59 template<typename DOMDocumentType>
61 template<typename DOMDocumentType>
62 DOMDocumentWrapper<DOMDocumentType> D(DOMDocumentType *me);
63 template<typename DOMElementType>
65 template<typename DOMElementType>
66 DOMElementWrapper<DOMElementType> E(DOMElementType *me);
67 
69 class InitXerces {
70  public:
71  InitXerces() {
72  xercesc::XMLPlatformUtils::Initialize();
73  }
74  ~InitXerces() {
75  xercesc::XMLPlatformUtils::Terminate();
76  }
77 };
78 
81 class X {
82  public:
83  const XMLCh *operator%(const std::string &str) {
84  if(str.empty())
85  return &xercesc::chNull;
86  const XMLCh *unicode=xercesc::TranscodeFromStr(reinterpret_cast<const XMLByte*>(str.c_str()), str.length(), "UTF8").adopt();
87  store.push_back(std::shared_ptr<const XMLCh>(unicode, &releaseXMLCh));
88  return unicode;
89  }
90  const XMLCh *operator()(const std::string &str) { return operator%(str); }
91  std::string operator%(const XMLCh *unicode) {
92  if(!unicode || unicode[0]==0)
93  return std::string();
94  return reinterpret_cast<const char*>(xercesc::TranscodeToStr(unicode, "UTF8").str());
95  }
96  std::string operator()(const XMLCh *unicode) { return operator%(unicode); }
97  static void releaseXMLCh(const XMLCh *s) { xercesc::XMLPlatformUtils::fgMemoryManager->deallocate(const_cast<XMLCh*>(s)); }
98  private:
99  std::vector<std::shared_ptr<const XMLCh> > store;
100 };
101 
104 class FQN : public std::pair<std::string, std::string> {
105  public:
107  FQN() = default;
109  FQN(const std::string &name) : std::pair<std::string, std::string>("", name) {}
111  FQN(const char *name) : std::pair<std::string, std::string>("", name) {}
113  FQN(const std::string &ns, const std::string &name) : std::pair<std::string, std::string>(ns, name) {}
114 };
115 
118  public:
119  NamespaceURI(std::string nsuri_) : nsuri(std::move(nsuri_)) {}
120  FQN operator%(const std::string &localName) const { return FQN(nsuri, localName); }
121  std::string getNamespaceURI() const { return nsuri; }
122  private:
123  std::string nsuri;
124 };
125 
127 const NamespaceURI XINCLUDE("http://www.w3.org/2001/XInclude");
129 const NamespaceURI XMLNS("http://www.w3.org/2000/xmlns/");
131 const NamespaceURI PV("http://www.mbsim-env.de/MBXMLUtils");
133 const NamespaceURI XMLCATALOG("urn:oasis:names:tc:entity:xmlns:xml:catalog");
134 
137 class EmbedDOMLocator : public xercesc::DOMLocator {
138  public:
139  EmbedDOMLocator(const boost::filesystem::path &file_, int row_, int embedCount_, std::string xpath_) : DOMLocator(),
140  file(x%file_.string()), row(row_), embedCount(embedCount_), xpath(std::move(xpath_)) {}
141  EmbedDOMLocator(const EmbedDOMLocator &src) : DOMLocator(),
142  file(x%(X()%src.file)), row(src.row), embedCount(src.embedCount), xpath(src.xpath) {}
143  EmbedDOMLocator& operator=(const EmbedDOMLocator &src) {
144  file=x%(X()%src.file);
145  row=src.row;
146  embedCount=src.embedCount;
147  xpath=src.xpath;
148  return *this;
149  }
150  ~EmbedDOMLocator() override = default;
151  EmbedDOMLocator(const EmbedDOMLocator &&src) = delete;
152  EmbedDOMLocator& operator=(const EmbedDOMLocator &&src) = delete;
153  XMLFileLoc getLineNumber() const override { return row; }
154  XMLFileLoc getColumnNumber() const override { return 0; }
155  XMLFilePos getByteOffset() const override { return ~(XMLFilePos(0)); }
156  XMLFilePos getUtf16Offset() const override { return ~(XMLFilePos(0)); }
157  xercesc::DOMNode *getRelatedNode() const override { return nullptr; }
158  const XMLCh *getURI() const override { return file; }
159  int getEmbedCount() const { return embedCount; }
160  std::string getRootXPathExpression() const { return xpath; }
161  private:
162  X x;
163  const XMLCh *file;
164  int row;
165  int embedCount;
166  std::string xpath;
167 };
168 
169 // Exception wrapping for DOMEvalException.
170 // Rethrow a exception as DOMEvalException with context e, a DOMEvalException is just rethrown unchanged.
171 #define RETHROW_AS_DOMEVALEXCEPTION(e) \
172  catch(MBXMLUtils::DOMEvalException &ex) { \
173  throw ex; \
174  } \
175  catch(const std::exception &ex) { \
176  throw DOMEvalException(ex.what(), e); \
177  }
178 
181 class DOMEvalException : public std::exception {
182  friend class DOMParser;
183  public:
184  DOMEvalException() = default;
185  DOMEvalException(const std::string &errorMsg_, const xercesc::DOMNode *n);
186  DOMEvalException(const std::string &errorMsg_, const xercesc::DOMLocator &loc);
187  DOMEvalException(const DOMEvalException &src) : errorMsg(src.errorMsg),
188  locationStack(src.locationStack) {}
189  DOMEvalException &operator=(const DOMEvalException &src) {
190  errorMsg=src.errorMsg; locationStack=src.locationStack;
191  return *this;
192  }
193  ~DOMEvalException() noexcept override = default;
194  void appendContext(const xercesc::DOMNode *n, int lineNr=0);
195  const std::string& getMessage() const { return errorMsg; }
196  void setMessage(const std::string& errorMsg_) { errorMsg=errorMsg_; }
197  void setSubsequentError(bool sse) { subsequentError=sse; }
198  const char* what() const noexcept override;
199  private:
222  static std::string convertToString(const EmbedDOMLocator &loc, const std::string &message, bool subsequentError=false);
223 
224  bool subsequentError{false};
225  std::string errorMsg;
226  std::vector<EmbedDOMLocator> locationStack;
227  mutable std::string whatStr;
228 };
229 
231 class DOMErrorPrinter: public xercesc::DOMErrorHandler, virtual public fmatvec::Atom
232 {
233  public:
234  DOMErrorPrinter() = default;
235  bool handleError(const xercesc::DOMError&) override;
236  bool hasError() { return errorSet; }
237  const DOMEvalException& getError() { return error; }
238  void resetError() { errorSet=false; }
239  private:
240  bool errorSet{false};
241  DOMEvalException error;
242 };
243 
245 template<typename DOMElementType>
246 class DOMElementWrapper {
247  public:
249  DOMElementWrapper(DOMElementType *me_) : me(me_) {}
251  FQN getTagName() const { return FQN(X()%me->getNamespaceURI(), X()%me->getLocalName()); }
253  const xercesc::DOMElement *getFirstElementChildNamed(const FQN &name) const;
255  xercesc::DOMElement *getFirstElementChildNamed(const FQN &name);
257  const xercesc::DOMElement *getNextElementSiblingNamed(const FQN &name) const;
259  xercesc::DOMElement *getNextElementSiblingNamed(const FQN &name);
261  const xercesc::DOMProcessingInstruction *getFirstProcessingInstructionChildNamed(const std::string &target) const;
263  xercesc::DOMProcessingInstruction *getFirstProcessingInstructionChildNamed(const std::string &target);
265  const xercesc::DOMText *getFirstTextChild() const;
267  xercesc::DOMText *getFirstTextChild();
269  template<class T> T getText(int r=0, int c=0) const {
270  try {
271  auto ret=boost::lexical_cast<T>(X()%E(me)->getFirstTextChild()->getData());
272  CheckSize<T>::check(me, ret, r, c);
273  return ret;
274  }
275  catch(const boost::bad_lexical_cast &ex) {
276  throw DOMEvalException(ex.what(), me);
277  }
278  catch(const std::exception &ex) {
279  throw DOMEvalException(ex.what(), me);
280  }
281  }
282 
283  template<class T> void addElementText(const FQN &name, const T &value) {
284  xercesc::DOMElement *ele=D(me->getOwnerDocument())->createElement(name);
285  ele->insertBefore(me->getOwnerDocument()->createTextNode(MBXMLUtils::X()%fmatvec::toString(value)), nullptr);
286  me->insertBefore(ele, nullptr);
287  }
290  bool isDerivedFrom(const FQN &baseTypeName) const;
296  boost::filesystem::path getOriginalFilename(bool skipThis=false,
297  const xercesc::DOMElement *&found=DOMElementWrapper<DOMElementType>::dummyArg) const;
301  void setOriginalFilename();
304  boost::filesystem::path convertPath(const boost::filesystem::path &relPath) const;
307  int getLineNumber() const;
310  int getEmbedCountNumber() const;
313  void setEmbedCountNumber(int embedCount);
316  int getEmbedXPathCount() const;
319  void setEmbedXPathCount(int xPathCount);
322  std::string getRootXPathExpression() const;
324  int getOriginalElementLineNumber() const;
326  void setOriginalElementLineNumber(int lineNr);
328  std::string getAttribute(const FQN &name) const;
330  FQN getAttributeQName(const FQN &name) const;
332  const xercesc::DOMAttr* getAttributeNode(const FQN &name) const;
334  xercesc::DOMAttr* getAttributeNode(const FQN &name);
336  template<class T>
337  void setAttribute(const FQN &name, const T &value) {
338  me->setAttributeNS(X()%name.first, X()%name.second, X()%fmatvec::toString(value));
339  }
341  void setAttribute(const FQN &name, const FQN &value);
343  bool hasAttribute(const FQN &name) const;
345  void removeAttribute(const FQN &name);
349  typename std::conditional<std::is_same<DOMElementType, const xercesc::DOMElement>::value,
351  return this;
352  }
353  static const xercesc::DOMElement *dummyArg;
354  private:
355  DOMElementType *me;
356 };
358 template<typename DOMElementType>
359 DOMElementWrapper<DOMElementType> E(DOMElementType *me) { return DOMElementWrapper<DOMElementType>(me); }
361 template<typename DOMElementType>
362 DOMElementWrapper<DOMElementType> E(std::shared_ptr<DOMElementType> me) { return DOMElementWrapper<DOMElementType>(me.get()); }
363 
364 template<> const xercesc::DOMElement *DOMElementWrapper< xercesc::DOMElement>::dummyArg;
365 template<> const xercesc::DOMElement *DOMElementWrapper<const xercesc::DOMElement>::dummyArg;
366 
368 template<typename DOMAttrType>
370  public:
372  DOMAttrWrapper(DOMAttrType *me_) : me(me_) {}
375  bool isDerivedFrom(const FQN &baseTypeName) const;
378  std::string getRootXPathExpression() const;
380  typename std::conditional<std::is_same<DOMAttrType, const xercesc::DOMAttr>::value,
382  return this;
383  }
384  private:
385  DOMAttrType *me;
386 };
388 template<typename DOMAttrType>
389 DOMAttrWrapper<DOMAttrType> A(DOMAttrType *me) { return DOMAttrWrapper<DOMAttrType>(me); }
391 template<typename DOMAttrType>
392 DOMAttrWrapper<DOMAttrType> A(std::shared_ptr<DOMAttrType> me) { return DOMAttrWrapper<DOMAttrType>(me.get()); }
393 
394 class DOMParser;
395 
397 template<typename DOMDocumentType>
398 class DOMDocumentWrapper {
399  public:
401  DOMDocumentWrapper(DOMDocumentType *me_) : me(me_) {}
403  void validate();
406  xercesc::DOMElement* createElement(const FQN &name);
408  std::shared_ptr<DOMParser> getParser() const;
411  boost::filesystem::path getDocumentFilename() const;
415  xercesc::DOMNode* evalRootXPathExpression(std::string xpathExpression, xercesc::DOMElement* context=nullptr);
417  typename std::conditional<std::is_same<DOMDocumentType, const xercesc::DOMDocument>::value,
419  return this;
420  }
421  private:
422  DOMDocumentType *me;
423 };
425 template<typename DOMDocumentType>
426 DOMDocumentWrapper<DOMDocumentType> D(DOMDocumentType *me) { return DOMDocumentWrapper<DOMDocumentType>(me); }
428 template<typename DOMDocumentType>
429 DOMDocumentWrapper<DOMDocumentType> D(std::shared_ptr<DOMDocumentType> me) { return DOMDocumentWrapper<DOMDocumentType>(me.get()); }
430 
431 class LocationInfoFilter : public xercesc::DOMLSParserFilter {
432  public:
433  void setParser(DOMParser *parser_) { parser=parser_; }
434  xercesc::DOMLSParserFilter::FilterAction acceptNode(xercesc::DOMNode *n) override;
435  xercesc::DOMLSParserFilter::FilterAction startElement(xercesc::DOMElement *e) override;
436  xercesc::DOMNodeFilter::ShowType getWhatToShow() const override;
437  private:
438  DOMParser *parser;
439  static const std::string lineNumberKey;
440 };
441 
442 class TypeDerivativeHandler : public xercesc::PSVIHandler, virtual public fmatvec::Atom {
443  public:
444  void setParser(DOMParser *parser_) { parser=parser_; }
445  void handleElementPSVI(const XMLCh *localName, const XMLCh *uri, xercesc::PSVIElement *info) override;
446  void handleAttributesPSVI(const XMLCh *localName, const XMLCh *uri, xercesc::PSVIAttributeList *psviAttributes) override;
447  private:
448  DOMParser *parser;
449 };
450 
451 class DOMParserUserDataHandler : public xercesc::DOMUserDataHandler {
452  public:
453  void handle(DOMOperationType operation, const XMLCh* key, void *data, const xercesc::DOMNode *src, xercesc::DOMNode *dst) override;
454 };
455 
456 class EntityResolver : public xercesc::XMLEntityResolver {
457  public:
458  void setParser(DOMParser *parser_) { parser=parser_; }
459  xercesc::InputSource* resolveEntity(xercesc::XMLResourceIdentifier *resourceIdentifier) override;
460  private:
461  DOMParser *parser;
462 };
463 
465 class DOMParser : public std::enable_shared_from_this<DOMParser> {
466  friend bool isDerivedFrom(const xercesc::DOMNode *me, const FQN &baseTypeName);
467  friend class TypeDerivativeHandler;
468  friend class LocationInfoFilter;
469  friend class DOMParserUserDataHandler;
470  friend class EntityResolver;
471  template<typename> friend class DOMDocumentWrapper;
472  public:
476  static std::shared_ptr<DOMParser> create(const std::variant<boost::filesystem::path, xercesc::DOMElement*> &xmlCatalog=nullptr);
480  std::shared_ptr<xercesc::DOMDocument> parse(const boost::filesystem::path &inputSource,
481  std::vector<boost::filesystem::path> *dependencies=nullptr, bool doXInclude=true);
484  static void serialize(xercesc::DOMNode *n, const boost::filesystem::path &outputSource, bool prettyPrint=true);
487  static void serializeToString(xercesc::DOMNode *n, std::string &outputData, bool prettyPrint=true);
489  void resetCachedGrammarPool();
491  std::shared_ptr<xercesc::DOMDocument> createDocument();
493  static void handleCDATA(xercesc::DOMElement *e);
494  private:
495  static const std::string domParserKey;
496 
497  xercesc::DOMImplementation *domImpl;
498  DOMParser(const std::variant<boost::filesystem::path, xercesc::DOMElement*> &xmlCatalog);
499  std::shared_ptr<xercesc::DOMLSParser> parser;
500  std::map<FQN, xercesc::XSTypeDefinition*> typeMap;
501  DOMErrorPrinter errorHandler;
502  LocationInfoFilter locationFilter;
503  TypeDerivativeHandler typeDerHandler;
504  EntityResolver entityResolver;
505  static DOMParserUserDataHandler userDataHandler;
506  std::map<std::string, boost::filesystem::path> registeredGrammar;
507 
508  static void handleXInclude(xercesc::DOMElement *&e, std::vector<boost::filesystem::path> *dependencies);
509 };
510 
511 }
512 
513 namespace {
514 
515 template<class T>
516 void CheckSize<T>::check(const xercesc::DOMElement *me, const T &value, int r, int c) {}
517 template<class T>
518 void CheckSize<std::vector<T>>::check(const xercesc::DOMElement *me, const std::vector<T> &value, int r, int c) {
519  if(r!=0 && r!=static_cast<int>(value.size()))
520  throw MBXMLUtils::DOMEvalException("Expected vector of size "+fmatvec::toString(r)+
521  " but got vector of size "+fmatvec::toString(value.size())+".", me);
522 }
523 template<class T>
524 void CheckSize<std::vector<std::vector<T>>>::check(const xercesc::DOMElement *me, const std::vector<std::vector<T>> &value, int r, int c) {
525  if(r!=0 && r!=static_cast<int>(value.size()))
526  throw MBXMLUtils::DOMEvalException("Expected matrix of row-size "+fmatvec::toString(r)+
527  " but got matrix of row-size "+fmatvec::toString(value.size())+".", me);
528  if(!value.empty() && c!=0 && c!=static_cast<int>(value[0].size()))
529  throw MBXMLUtils::DOMEvalException("Expected matrix of col-size "+fmatvec::toString(c)+
530  " but got matrix of col-size "+fmatvec::toString(value[0].size())+".", me);
531 }
532 
533 }
534 
535 #endif
const xercesc::DOMText * getFirstTextChild() const
Get first child text.
Definition: dom.cc:238
xercesc::DOMElement * createElement(const FQN &name)
Definition: dom.cc:555
void validate()
(re)validate the document using the parser this document was created
Definition: dom.cc:524
FQN()=default
Empty FQN.
FQN(const char *name)
Anonymous FQN (required for implicit casting of string literals to anonymous FQNs)
Definition: dom.h:111
int getOriginalElementLineNumber() const
Get the line number of the original element.
Definition: dom.cc:447
std::string getRootXPathExpression() const
Definition: dom.cc:409
Definition: dom.h:104
FQN getTagName() const
Get full qualified tag name.
Definition: dom.h:251
void workaroundDefaultAttributesOnImportNode()
Workaround: convert default attributes to normal attributes (must be used before importNode to also i...
Definition: dom.cc:464
xercesc::DOMNode * evalRootXPathExpression(std::string xpathExpression, xercesc::DOMElement *context=nullptr)
Definition: dom.cc:591
void setEmbedCountNumber(int embedCount)
Definition: dom.cc:384
std::conditional< std::is_same< DOMElementType, const xercesc::DOMElement >::value, const DOMElementWrapper *, DOMElementWrapper * >::type operator->()
Treat this object as a pointer (like DOMElement*)
Definition: dom.h:350
Helper class to easily construct full qualified XML names (FQN) using XML namespace prefixes.
Definition: dom.h:117
FQN(const std::string &ns, const std::string &name)
FQN.
Definition: dom.h:113
const xercesc::DOMAttr * getAttributeNode(const FQN &name) const
Get attribute node named name.
Definition: dom.cc:315
FQN(const std::string &name)
Anonymous FQN.
Definition: dom.h:109
Definition: dom.h:456
Definition: dom.h:431
void setAttribute(const FQN &name, const T &value)
Set attribute.
Definition: dom.h:337
bool isDerivedFrom(const FQN &baseTypeName) const
Definition: dom.cc:509
Definition: dom.h:81
Helper class for extending DOMDocument (use the function D(...)).
Definition: dom.h:60
DOMElementWrapper(DOMElementType *me_)
Wrap DOMElement to my special element.
Definition: dom.h:249
T getText(int r=0, int c=0) const
Get the child text as type T.
Definition: dom.h:269
void setEmbedXPathCount(int xPathCount)
Definition: dom.cc:401
bool isDerivedFrom(const FQN &baseTypeName) const
Definition: dom.cc:500
FQN getAttributeQName(const FQN &name) const
Get attribute named name of type QName.
Definition: dom.cc:304
bool hasAttribute(const FQN &name) const
check if this element has a attibute named name.
Definition: dom.cc:478
std::shared_ptr< xercesc::DOMDocument > createDocument()
create a empty document
Definition: dom.cc:1066
int getLineNumber() const
Definition: dom.cc:361
Definition: dom.h:137
Initialize Xerces on load and terminate it on unload of the library/program.
Definition: dom.h:69
boost::filesystem::path convertPath(const boost::filesystem::path &relPath) const
Definition: dom.cc:290
std::string getRootXPathExpression() const
Definition: dom.cc:515
static void handleCDATA(xercesc::DOMElement *e)
handle CDATA sections
Definition: dom.cc:930
const xercesc::DOMElement * getNextElementSiblingNamed(const FQN &name) const
Get next sibling element of the specified full qualified name.
Definition: dom.cc:198
Definition: dom.h:181
const xercesc::DOMElement * getFirstElementChildNamed(const FQN &name) const
Get first child element of the specified full qualified name.
Definition: dom.cc:181
Helper class for extending DOMAttr (use the function A(...)).
Definition: dom.h:369
void setOriginalElementLineNumber(int lineNr)
Set the line number of the original element.
Definition: dom.cc:456
static std::string convertToString(const EmbedDOMLocator &loc, const std::string &message, bool subsequentError=false)
Definition: dom.cc:705
boost::filesystem::path getOriginalFilename(bool skipThis=false, const xercesc::DOMElement *&found=DOMElementWrapper< DOMElementType >::dummyArg) const
Definition: dom.cc:255
void resetCachedGrammarPool()
reset all loaded grammars
Definition: dom.cc:1061
Print DOM error messages.
Definition: dom.h:231
Helper class for extending DOMElement (use the function E(...)).
Definition: dom.h:64
boost::filesystem::path getDocumentFilename() const
Definition: dom.cc:569
void removeAttribute(const FQN &name)
remove from this element the attibute named name.
Definition: dom.cc:370
std::shared_ptr< DOMParser > getParser() const
Get full qualified tag name.
Definition: dom.cc:563
A XML DOM parser.
Definition: dom.h:465
const xercesc::DOMProcessingInstruction * getFirstProcessingInstructionChildNamed(const std::string &target) const
Get first child processing instruction of the specified target.
Definition: dom.cc:215
std::conditional< std::is_same< DOMAttrType, const xercesc::DOMAttr >::value, const DOMAttrWrapper *, DOMAttrWrapper * >::type operator->()
Treat this object as a pointer (like DOMAttr*)
Definition: dom.h:381
static std::shared_ptr< DOMParser > create(const std::variant< boost::filesystem::path, xercesc::DOMElement * > &xmlCatalog=nullptr)
Definition: dom.cc:831
std::shared_ptr< xercesc::DOMDocument > parse(const boost::filesystem::path &inputSource, std::vector< boost::filesystem::path > *dependencies=nullptr, bool doXInclude=true)
Definition: dom.cc:972
DOMAttrWrapper(DOMAttrType *me_)
Wrap DOMAttr to my special element.
Definition: dom.h:372
DOMDocumentWrapper(DOMDocumentType *me_)
Wrap DOMDocument to my special element.
Definition: dom.h:401
static void serialize(xercesc::DOMNode *n, const boost::filesystem::path &outputSource, bool prettyPrint=true)
Definition: dom.cc:1026
void setOriginalFilename()
Definition: dom.cc:282
static void serializeToString(xercesc::DOMNode *n, std::string &outputData, bool prettyPrint=true)
Definition: dom.cc:1037
std::conditional< std::is_same< DOMDocumentType, const xercesc::DOMDocument >::value, const DOMDocumentWrapper *, DOMDocumentWrapper * >::type operator->()
Treat this object as a pointer (like DOMDocument*)
Definition: dom.h:418
int getEmbedCountNumber() const
Definition: dom.cc:375
int getEmbedXPathCount() const
Definition: dom.cc:392
std::string getAttribute(const FQN &name) const
Get attribute named name.
Definition: dom.cc:298