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:
226  static std::string convertToString(const EmbedDOMLocator &loc, const std::string &message, bool subsequentError=false);
227 
228  bool subsequentError{false};
229  std::string errorMsg;
230  std::vector<EmbedDOMLocator> locationStack;
231  mutable std::string whatStr;
232 };
233 
235 class DOMErrorPrinter: public xercesc::DOMErrorHandler, virtual public fmatvec::Atom
236 {
237  public:
238  DOMErrorPrinter() = default;
239  bool handleError(const xercesc::DOMError&) override;
240  bool hasError() { return errorSet; }
241  const DOMEvalException& getError() { return error; }
242  void resetError() { errorSet=false; }
243  private:
244  bool errorSet{false};
245  DOMEvalException error;
246 };
247 
249 template<typename DOMElementType>
250 class DOMElementWrapper {
251  public:
253  DOMElementWrapper(DOMElementType *me_) : me(me_) {}
255  FQN getTagName() const { return FQN(X()%me->getNamespaceURI(), X()%me->getLocalName()); }
257  const xercesc::DOMElement *getFirstElementChildNamed(const FQN &name) const;
259  xercesc::DOMElement *getFirstElementChildNamed(const FQN &name);
261  const xercesc::DOMElement *getNextElementSiblingNamed(const FQN &name) const;
263  xercesc::DOMElement *getNextElementSiblingNamed(const FQN &name);
265  const xercesc::DOMProcessingInstruction *getFirstProcessingInstructionChildNamed(const std::string &target) const;
267  xercesc::DOMProcessingInstruction *getFirstProcessingInstructionChildNamed(const std::string &target);
269  const xercesc::DOMText *getFirstTextChild() const;
271  xercesc::DOMText *getFirstTextChild();
273  template<class T> T getText(int r=0, int c=0) const {
274  try {
275  auto ret=boost::lexical_cast<T>(X()%E(me)->getFirstTextChild()->getData());
276  CheckSize<T>::check(me, ret, r, c);
277  return ret;
278  }
279  catch(const boost::bad_lexical_cast &ex) {
280  throw DOMEvalException(ex.what(), me);
281  }
282  catch(const std::exception &ex) {
283  throw DOMEvalException(ex.what(), me);
284  }
285  }
286 
287  template<class T> void addElementText(const FQN &name, const T &value) {
288  xercesc::DOMElement *ele=D(me->getOwnerDocument())->createElement(name);
289  ele->insertBefore(me->getOwnerDocument()->createTextNode(MBXMLUtils::X()%fmatvec::toString(value)), nullptr);
290  me->insertBefore(ele, nullptr);
291  }
294  bool isDerivedFrom(const FQN &baseTypeName) const;
300  boost::filesystem::path getOriginalFilename(bool skipThis=false,
301  const xercesc::DOMElement *&found=DOMElementWrapper<DOMElementType>::dummyArg) const;
306  void setOriginalFilename(boost::filesystem::path orgFileName=boost::filesystem::path());
309  boost::filesystem::path convertPath(const boost::filesystem::path &relPath) const;
312  int getLineNumber() const;
315  int getEmbedCountNumber() const;
318  void setEmbedCountNumber(int embedCount);
321  int getEmbedXPathCount() const;
324  void setEmbedXPathCount(int xPathCount);
327  std::string getRootXPathExpression() const;
329  int getOriginalElementLineNumber() const;
331  void setOriginalElementLineNumber(int lineNr);
333  std::string getAttribute(const FQN &name) const;
335  FQN getAttributeQName(const FQN &name) const;
337  const xercesc::DOMAttr* getAttributeNode(const FQN &name) const;
339  xercesc::DOMAttr* getAttributeNode(const FQN &name);
341  template<class T>
342  void setAttribute(const FQN &name, const T &value) {
343  me->setAttributeNS(X()%name.first, X()%name.second, X()%fmatvec::toString(value));
344  }
346  void setAttribute(const FQN &name, const FQN &value);
348  bool hasAttribute(const FQN &name) const;
350  void removeAttribute(const FQN &name);
354  typename std::conditional<std::is_same<DOMElementType, const xercesc::DOMElement>::value,
356  return this;
357  }
358  static const xercesc::DOMElement *dummyArg;
359  private:
360  DOMElementType *me;
361 };
363 template<typename DOMElementType>
364 DOMElementWrapper<DOMElementType> E(DOMElementType *me) { return DOMElementWrapper<DOMElementType>(me); }
366 template<typename DOMElementType>
367 DOMElementWrapper<DOMElementType> E(std::shared_ptr<DOMElementType> me) { return DOMElementWrapper<DOMElementType>(me.get()); }
368 
369 template<> const xercesc::DOMElement *DOMElementWrapper< xercesc::DOMElement>::dummyArg;
370 template<> const xercesc::DOMElement *DOMElementWrapper<const xercesc::DOMElement>::dummyArg;
371 
373 template<typename DOMAttrType>
375  public:
377  DOMAttrWrapper(DOMAttrType *me_) : me(me_) {}
380  bool isDerivedFrom(const FQN &baseTypeName) const;
383  std::string getRootXPathExpression() const;
385  typename std::conditional<std::is_same<DOMAttrType, const xercesc::DOMAttr>::value,
387  return this;
388  }
389  private:
390  DOMAttrType *me;
391 };
393 template<typename DOMAttrType>
394 DOMAttrWrapper<DOMAttrType> A(DOMAttrType *me) { return DOMAttrWrapper<DOMAttrType>(me); }
396 template<typename DOMAttrType>
397 DOMAttrWrapper<DOMAttrType> A(std::shared_ptr<DOMAttrType> me) { return DOMAttrWrapper<DOMAttrType>(me.get()); }
398 
399 class DOMParser;
400 
402 template<typename DOMDocumentType>
403 class DOMDocumentWrapper {
404  public:
406  DOMDocumentWrapper(DOMDocumentType *me_) : me(me_) {}
408  void validate();
411  xercesc::DOMElement* createElement(const FQN &name);
413  void normalizeDocument();
415  std::shared_ptr<DOMParser> getParser() const;
418  boost::filesystem::path getDocumentFilename() const;
422  xercesc::DOMNode* evalRootXPathExpression(std::string xpathExpression, xercesc::DOMElement* context=nullptr);
424  typename std::conditional<std::is_same<DOMDocumentType, const xercesc::DOMDocument>::value,
426  return this;
427  }
428  private:
429  DOMDocumentType *me;
430 };
432 template<typename DOMDocumentType>
433 DOMDocumentWrapper<DOMDocumentType> D(DOMDocumentType *me) { return DOMDocumentWrapper<DOMDocumentType>(me); }
435 template<typename DOMDocumentType>
436 DOMDocumentWrapper<DOMDocumentType> D(std::shared_ptr<DOMDocumentType> me) { return DOMDocumentWrapper<DOMDocumentType>(me.get()); }
437 
438 class LocationInfoFilter : public xercesc::DOMLSParserFilter {
439  public:
440  void setParser(DOMParser *parser_) { parser=parser_; }
441  xercesc::DOMLSParserFilter::FilterAction acceptNode(xercesc::DOMNode *n) override;
442  xercesc::DOMLSParserFilter::FilterAction startElement(xercesc::DOMElement *e) override;
443  xercesc::DOMNodeFilter::ShowType getWhatToShow() const override;
444  private:
445  DOMParser *parser;
446  static const std::string lineNumberKey;
447 };
448 
449 class TypeDerivativeHandler : public xercesc::PSVIHandler, virtual public fmatvec::Atom {
450  public:
451  void setParser(DOMParser *parser_) { parser=parser_; }
452  void handleElementPSVI(const XMLCh *localName, const XMLCh *uri, xercesc::PSVIElement *info) override;
453  void handleAttributesPSVI(const XMLCh *localName, const XMLCh *uri, xercesc::PSVIAttributeList *psviAttributes) override;
454  private:
455  DOMParser *parser;
456 };
457 
458 class DOMParserUserDataHandler : public xercesc::DOMUserDataHandler {
459  public:
460  void handle(DOMOperationType operation, const XMLCh* key, void *data, const xercesc::DOMNode *src, xercesc::DOMNode *dst) override;
461 };
462 
463 class EntityResolver : public xercesc::XMLEntityResolver {
464  public:
465  void setParser(DOMParser *parser_) { parser=parser_; }
466  xercesc::InputSource* resolveEntity(xercesc::XMLResourceIdentifier *resourceIdentifier) override;
467  private:
468  DOMParser *parser;
469 };
470 
472 class DOMParser : public std::enable_shared_from_this<DOMParser> {
473  friend bool isDerivedFrom(const xercesc::DOMNode *me, const FQN &baseTypeName);
474  friend class TypeDerivativeHandler;
475  friend class LocationInfoFilter;
476  friend class DOMParserUserDataHandler;
477  friend class EntityResolver;
478  template<typename> friend class DOMDocumentWrapper;
479  public:
483  static std::shared_ptr<DOMParser> create(const std::variant<boost::filesystem::path, xercesc::DOMElement*> &xmlCatalog=nullptr);
487  std::shared_ptr<xercesc::DOMDocument> parse(const boost::filesystem::path &inputSource,
488  std::vector<boost::filesystem::path> *dependencies=nullptr, bool doXInclude=true);
491  static void serialize(xercesc::DOMNode *n, const boost::filesystem::path &outputSource, bool prettyPrint=true);
494  static void serializeToString(xercesc::DOMNode *n, std::string &outputData, bool prettyPrint=true);
496  void resetCachedGrammarPool();
498  std::shared_ptr<xercesc::DOMDocument> createDocument();
501  static void handleCDATA(xercesc::DOMElement *e);
502  private:
503  static const std::string domParserKey;
504 
505  xercesc::DOMImplementation *domImpl;
506  DOMParser(const std::variant<boost::filesystem::path, xercesc::DOMElement*> &xmlCatalog);
507  std::shared_ptr<xercesc::DOMLSParser> parser;
508  std::map<FQN, xercesc::XSTypeDefinition*> typeMap;
509  DOMErrorPrinter errorHandler;
510  LocationInfoFilter locationFilter;
511  TypeDerivativeHandler typeDerHandler;
512  EntityResolver entityResolver;
513  static DOMParserUserDataHandler userDataHandler;
514  std::map<std::string, boost::filesystem::path> registeredGrammar;
515 
516  static void handleXInclude(xercesc::DOMElement *&e, std::vector<boost::filesystem::path> *dependencies);
517 };
518 
519 }
520 
521 namespace {
522 
523 template<class T>
524 void CheckSize<T>::check(const xercesc::DOMElement *me, const T &value, int r, int c) {}
525 template<class T>
526 void CheckSize<std::vector<T>>::check(const xercesc::DOMElement *me, const std::vector<T> &value, int r, int c) {
527  if(r!=0 && r!=static_cast<int>(value.size()))
528  throw MBXMLUtils::DOMEvalException("Expected vector of size "+fmatvec::toString(r)+
529  " but got vector of size "+fmatvec::toString(value.size())+".", me);
530 }
531 template<class T>
532 void CheckSize<std::vector<std::vector<T>>>::check(const xercesc::DOMElement *me, const std::vector<std::vector<T>> &value, int r, int c) {
533  if(r!=0 && r!=static_cast<int>(value.size()))
534  throw MBXMLUtils::DOMEvalException("Expected matrix of row-size "+fmatvec::toString(r)+
535  " but got matrix of row-size "+fmatvec::toString(value.size())+".", me);
536  if(!value.empty() && c!=0 && c!=static_cast<int>(value[0].size()))
537  throw MBXMLUtils::DOMEvalException("Expected matrix of col-size "+fmatvec::toString(c)+
538  " but got matrix of col-size "+fmatvec::toString(value[0].size())+".", me);
539 }
540 
541 }
542 
543 #endif
const xercesc::DOMText * getFirstTextChild() const
Get first child text.
Definition: dom.cc:253
xercesc::DOMElement * createElement(const FQN &name)
Definition: dom.cc:577
void validate()
(re)validate the document using the parser this document was created
Definition: dom.cc:546
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:469
std::string getRootXPathExpression() const
Definition: dom.cc:425
Definition: dom.h:104
FQN getTagName() const
Get full qualified tag name.
Definition: dom.h:255
void workaroundDefaultAttributesOnImportNode()
Workaround: convert default attributes to normal attributes (must be used before importNode to also i...
Definition: dom.cc:486
xercesc::DOMNode * evalRootXPathExpression(std::string xpathExpression, xercesc::DOMElement *context=nullptr)
Definition: dom.cc:632
void setEmbedCountNumber(int embedCount)
Definition: dom.cc:400
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:355
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:331
FQN(const std::string &name)
Anonymous FQN.
Definition: dom.h:109
Definition: dom.h:463
Definition: dom.h:438
void setAttribute(const FQN &name, const T &value)
Set attribute.
Definition: dom.h:342
bool isDerivedFrom(const FQN &baseTypeName) const
Definition: dom.cc:531
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:253
T getText(int r=0, int c=0) const
Get the child text as type T.
Definition: dom.h:273
void setEmbedXPathCount(int xPathCount)
Definition: dom.cc:417
bool isDerivedFrom(const FQN &baseTypeName) const
Definition: dom.cc:522
FQN getAttributeQName(const FQN &name) const
Get attribute named name of type QName.
Definition: dom.cc:320
bool hasAttribute(const FQN &name) const
check if this element has a attibute named name.
Definition: dom.cc:500
std::shared_ptr< xercesc::DOMDocument > createDocument()
create a empty document
Definition: dom.cc:1130
int getLineNumber() const
Definition: dom.cc:377
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:306
std::string getRootXPathExpression() const
Definition: dom.cc:537
static void handleCDATA(xercesc::DOMElement *e)
Definition: dom.cc:985
const xercesc::DOMElement * getNextElementSiblingNamed(const FQN &name) const
Get next sibling element of the specified full qualified name.
Definition: dom.cc:213
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:196
void normalizeDocument()
Just calls normalizeDocument of the DOMDocument but with a workaround for a xerces-c bug,...
Definition: dom.cc:585
Helper class for extending DOMAttr (use the function A(...)).
Definition: dom.h:374
void setOriginalElementLineNumber(int lineNr)
Set the line number of the original element.
Definition: dom.cc:478
static std::string convertToString(const EmbedDOMLocator &loc, const std::string &message, bool subsequentError=false)
Definition: dom.cc:749
boost::filesystem::path getOriginalFilename(bool skipThis=false, const xercesc::DOMElement *&found=DOMElementWrapper< DOMElementType >::dummyArg) const
Definition: dom.cc:270
void resetCachedGrammarPool()
reset all loaded grammars
Definition: dom.cc:1125
Print DOM error messages.
Definition: dom.h:235
Helper class for extending DOMElement (use the function E(...)).
Definition: dom.h:64
boost::filesystem::path getDocumentFilename() const
Definition: dom.cc:607
void removeAttribute(const FQN &name)
remove from this element the attibute named name.
Definition: dom.cc:386
std::shared_ptr< DOMParser > getParser() const
Get full qualified tag name.
Definition: dom.cc:601
A XML DOM parser.
Definition: dom.h:472
const xercesc::DOMProcessingInstruction * getFirstProcessingInstructionChildNamed(const std::string &target) const
Get first child processing instruction of the specified target.
Definition: dom.cc:230
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:386
static std::shared_ptr< DOMParser > create(const std::variant< boost::filesystem::path, xercesc::DOMElement * > &xmlCatalog=nullptr)
Definition: dom.cc:886
std::shared_ptr< xercesc::DOMDocument > parse(const boost::filesystem::path &inputSource, std::vector< boost::filesystem::path > *dependencies=nullptr, bool doXInclude=true)
Definition: dom.cc:1034
DOMAttrWrapper(DOMAttrType *me_)
Wrap DOMAttr to my special element.
Definition: dom.h:377
DOMDocumentWrapper(DOMDocumentType *me_)
Wrap DOMDocument to my special element.
Definition: dom.h:406
static void serialize(xercesc::DOMNode *n, const boost::filesystem::path &outputSource, bool prettyPrint=true)
Definition: dom.cc:1090
static void serializeToString(xercesc::DOMNode *n, std::string &outputData, bool prettyPrint=true)
Definition: dom.cc:1101
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:425
void setOriginalFilename(boost::filesystem::path orgFileName=boost::filesystem::path())
Definition: dom.cc:297
int getEmbedCountNumber() const
Definition: dom.cc:391
int getEmbedXPathCount() const
Definition: dom.cc:408
std::string getAttribute(const FQN &name) const
Get attribute named name.
Definition: dom.cc:314