class auto_xmlfree: public UI::Util::auto_base
{
public:
/** @brief Control this memory allocated via std::*alloc. */
auto_xmlfree(P * const p)
:UI::Util::auto_base
(p)
{}
/** @brief Free memory via std::free. */
virtual ~auto_xmlfree()
{
xmlFree(UI::Util::auto_base
::p_);
}
};
}}
#endif
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/PaxHeaders.12816/Tree.cpp 0000644 0000000 0000000 00000000132 13554621605 017632 x ustar 00 30 mtime=1572021125.213833194
30 atime=1583248809.543595822
30 ctime=1583249814.949216966
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/Tree.cpp 0000644 0001750 0001750 00000037132 13554621605 020724 0 ustar 00absurd absurd 0000000 0000000 /**
* @file
* @version @$Id$
* @author
* ui-gxmlcpp: C++ wrapper for Gnome libxml2/libxsl.
* Copyright (C) Schlund+Partner AG 2002-2004.
* Licensed under the GNU Lesser General Public License (LGPL). See
* @ref License, or the file COPYING in distribution.
*/
// Local configuration
#include "config.h"
// Implementation
#include "Tree.hpp"
// STDC++
#include
#include
// C libraries
#include
// C++ libraries
#include
// Local
#include "Util.hpp"
#include "XPathObject.hpp"
namespace UI {
namespace GXML {
std::string const Tree::DefaultEncoding_("UTF-8");
std::string const Tree::DefaultEncodings_("UTF-8,UTF8");
std::string const Tree::DefaultDocbase_("noname.xml");
xmlDoc * Tree::create(char const * xml, int len, std::string const & base, int const options)
{
assert(xml);
xmlDoc * result(0);
len = len < 0 ? strlen(xml) : len;
// xmlDocPtr xmlReadMemory(const char * buffer, int size, const char * URL, const char * encoding, int options)
result = xmlReadMemory(xml, len, base.c_str(), 0, XML_PARSE_NOBLANKS | options);
if (!result)
{
UI_THROW_CODE(Parse_, "Can't parse XML");
}
return result;
}
xmlDoc * Tree::create(xmlDoc const * const doc)
{
xmlDoc * result(xmlCopyDoc((xmlDoc *)doc, true));
if (result == NULL)
{
UI_THROW_CODE(Mem_, "Error copying doc tree");
}
return result;
}
xmlDoc * Tree::create(std::string const & file, int const options)
{
xmlDoc * result(xmlReadFile(file.c_str(), 0, XML_PARSE_NOBLANKS | options));
if (result == NULL)
{
UI_THROW_CODE(Parse_, "Can't parse XML file: " + file);
}
return result;
}
Tree::Tree()
:dontFreeDoc_(false)
,context_(0)
{}
Tree::Tree(char const * xml, int len, std::string const & base, int const options)
:dontFreeDoc_(false)
,context_(0)
{
set(create(xml, len, base, options));
}
Tree::Tree(std::string const & xml, std::string const & base, int const options)
:dontFreeDoc_(false)
,context_(0)
{
set(create(xml.c_str(), xml.size(), base.c_str(), options));
}
Tree::Tree(std::istream & xml, std::string const & base, int const options)
:dontFreeDoc_(false)
,context_(0)
{
set(create(UI::Util::istream2String(xml).c_str(), -1, base.c_str(), options));
}
Tree::Tree(FileConstructor const &, std::string const & file, int const options)
:dontFreeDoc_(false)
,context_(0)
{
set(create(file, options));
}
Tree::Tree(Tree const & tree)
:Util::auto_base()
,dontFreeDoc_(false)
,context_(0)
{
set(create(tree.get()));
}
void Tree::dealloc()
{
if (!dontFreeDoc_)
{
xmlFreeDoc(get());
}
delete context_;
}
Tree::~Tree()
{
dealloc();
}
Tree & Tree::operator=(Tree const & tree)
{
dealloc();
set(create(tree.get()));
return *this;
}
bool Tree::operator==(Tree const & tree)
{
return dump() == tree.dump();
}
Tree & Tree::setContext(bool on)
{
if (on)
{
if (!context_)
{
context_ = new XPathContext(get());
}
}
else
{
delete context_;
context_ = 0;
}
return *this;
}
XPathContext * Tree::getContext() const
{
return context_;
}
Tree & Tree::setTopLevelNamespaces()
{
if (!context_)
{
UI_THROW_CODE(Internal_, "We need a fixed context to prepare top level namespaces");
}
xmlDoc * doc(get());
xmlXPathContext * context(context_->get());
if (doc->children)
{
context->namespaces = ::xmlGetNsList(doc, doc->children);
context->nsNr = 0;
if (context->namespaces != 0)
{
while (context->namespaces[context->nsNr])
{
++context->nsNr;
}
}
}
return *this;
}
Tree & Tree::setXPathNamespace(std::string const & prefix, std::string const & uri)
{
if (prefix.size())
{
if (uri.empty())
{
xPathNamespaces_.erase(prefix);
}
else
{
xPathNamespaces_.insert(std::make_pair(prefix, uri));
}
}
return *this;
}
Tree & Tree::setDontFreeDoc(bool on)
{
dontFreeDoc_=on;
return *this;
}
//
// Tree::Node
//
xmlNode * const Tree::Node::NullNode_(xmlNewNode(0, (xmlChar*)""));
Tree::Node::Node(xmlNode * const node)
{
set(node ? node : NullNode_);
}
bool Tree::Node::isNull() const
{
return get() == NullNode_;
}
void Tree::Node::unlink()
{
if (!isNull())
{
xmlUnlinkNode(get());
xmlFreeNode(get());
set(NullNode_);
}
}
Tree::Node Tree::Node::getParent() const
{
return Node(get()->parent);
}
Tree::Node Tree::Node::getChild() const
{
return Node(get()->children);
}
Tree::Node Tree::Node::getNext() const
{
return Node(get()->next);
}
Tree::Node Tree::Node::getPrev() const
{
return Node(get()->prev);
}
Tree::NodeSet Tree::Node::getChilds(std::string const & name) const
{
return NodeSet(*this, true, name);
}
xmlElementType Tree::Node::getType() const
{
return get()->type;
}
std::string Tree::Node::getXPath() const
{
auto_xmlfree path(xmlGetNodePath(get()));
return (char *) path.get();
}
char const * Tree::Node::getNameC() const
{
return get()->name ? (char *) get()->name : UI::Util::EmptyString_.c_str();
}
std::string Tree::Node::getName() const
{
return getNameC();
}
void Tree::Node::setName(std::string const & name)
{
/** @bug Imho, this should also work for attribute nodes, but this currently segfaults. */
switch (getType())
{
case XML_ELEMENT_NODE:
xmlNodeSetName(get(), (xmlChar *) name.c_str());
break;
default:
UI_THROW_CODE(Internal_, "Don't know how to set name for node type: " + UI::Util::tos(getType()));
break;
}
}
char const * Tree::Node::getContentC() const
{
return get()->children && get()->children->content ? (char *) get()->children->content : UI::Util::EmptyString_.c_str();
}
std::string Tree::Node::getContent() const
{
return getContentC();
}
void Tree::Node::setContent(std::string const & content)
{
xmlNodeSetContent(get(), (xmlChar *) content.c_str());
}
char const * Tree::Node::hasAttribute(std::string const & name) const
{
xmlAttrPtr attr(xmlHasProp(get(), (xmlChar *)name.c_str()));
return attr ? (char *) attr->children->content : 0;
}
char const * Tree::Node::getAttributeC(std::string const & name) const
{
char const * result(hasAttribute(name));
return result ? result : UI::Util::EmptyString_.c_str();
}
std::string Tree::Node::getAttribute(std::string const & name) const
{
return getAttributeC(name);
}
void Tree::Node::setAttribute(std::string const & name, std::string const & content)
{
xmlAttr * attr(xmlSetProp(get(), (xmlChar *) name.c_str(), (xmlChar *) content.c_str()));
if (!attr)
{
UI_THROW_CODE(Internal_, "Error setting attribute " + name + " to " + content);
}
}
Tree::NodeSet Tree::Node::getNodeSet(std::string const & xpath) const
{
/** @note XPathContext is created each time we call => thread-safe,
but possibly non-performant. A solution like in Tree would be
better, or even some other more general solution for both Tree +
Tree::Node. */
return NodeSet(XPathObject(XPathContext(get()->doc, get()), xpath));
}
Tree::Node Tree::Node::getNode(std::string const & xpath, bool const & doThrow) const
{
NodeSet ns(getNodeSet(xpath));
if (ns.empty() && doThrow)
{
UI_THROW_CODE(NoNode_, "No such node: " + xpath);
}
return ns.empty() ? Node(0) : ns[0];
}
Tree::Node Tree::Node::copy() const
{
xmlNode * copy(xmlCopyNode(get(), 1));
if (!copy)
{
UI_THROW_CODE(Internal_, "Error copying node: " + getName());
}
return Node(copy);
}
Tree::Node Tree::Node::addChild(std::string const & name, std::string const & content)
{
xmlNode * newNode(xmlNewChild(get(), 0, (xmlChar *) name.c_str(), (xmlChar *) content.c_str()));
if (!newNode)
{
UI_THROW_CODE(Internal_, "Error adding new child node: " + name);
}
return Node(newNode);
}
Tree::Node Tree::Node::addChild(Node const & n)
{
Node newNode(n.copy());
if (xmlAddChild(get(), newNode.get()) == 0)
{
xmlFreeNode(newNode.get());
UI_THROW_CODE(Internal_, "addChild: Can't add node " + n.getName() + " to " + getName());
}
return newNode;
}
Tree::Node Tree::Node::addSiblingAfter(std::string const & name, std::string const & content)
{
xmlNode * newXmlNode(xmlNewNode(0, (xmlChar *)name.c_str()));
if (!newXmlNode)
{
UI_THROW_CODE(Internal_, "Error creating sibling node: " + name);
}
Node newNode(newXmlNode);
newNode.setContent(content);
if (xmlAddNextSibling(get(), newNode.get()) == 0)
{
xmlFreeNode(newXmlNode);
UI_THROW_CODE(Internal_, "addSiblingAfter: Can't add node " + name + " as sibling of " + getName());
}
return newNode;
}
Tree::Node Tree::Node::addSiblingAfter(Node const & n)
{
Node newNode(n.copy());
if (xmlAddNextSibling(get(), newNode.get()) == 0)
{
xmlFreeNode(newNode.get());
UI_THROW_CODE(Internal_, "addSiblingAfter: Can't add node " + n.getName() + " as sibling of " + getName());
}
return newNode;
}
std::string Tree::Node::dump(bool const & format, std::string const & encoding) const
{
return NodeSet::Dump(NodeSet(*this), format, encoding).getC();
}
//
// Tree::NodeSet
//
Tree::NodeSet::NodeSet(XPathObject const & xPathObject)
{
if (xPathObject->type == XPATH_NODESET && xPathObject->nodesetval)
{
for (int i(0); i < xPathObject->nodesetval->nodeNr; ++i)
{
push_back(Node(xPathObject->nodesetval->nodeTab[i]));
}
}
}
Tree::NodeSet::NodeSet(Node const & node, bool const & childs, std::string const & name)
{
add(node, childs, name);
}
Tree::NodeSet::NodeSet(NodeSet const & ns, bool const & childs, std::string const & name)
:std::vector()
{
add(ns, childs, name);
}
void Tree::NodeSet::add(Node const & node, bool const & childs, std::string const & name)
{
class Help
{
public:
static void addMatching(NodeSet & o, Node const & n, std::string const & name)
{
if (name.empty() || name == n.getName())
{
o.push_back(n);
}
}
};
if (!node.isNull())
{
if (childs)
{
Node n(node.getChild());
while (!n.isNull())
{
Help::addMatching(*this, n, name);
n = n.getNext();
}
}
else
{
Help::addMatching(*this, node, name);
}
}
}
void Tree::NodeSet::add(NodeSet const & ns, bool const & childs, std::string const & name)
{
for (NodeSet::const_iterator i(ns.begin()); i != ns.end(); ++i)
{
add((*i), childs, name);
}
}
void Tree::NodeSet::unlink()
{
for (Tree::NodeSet::iterator n(this->begin()); n != this->end(); ++n)
{
n->unlink();
}
}
Tree::NodeSet Tree::NodeSet::getChilds(std::string const & name) const
{
return NodeSet(*this, true, name);
}
std::string Tree::NodeSet::getContent(std::string const & nodeSeparator) const
{
std::string content("");
for (Tree::NodeSet::const_iterator n(this->begin()); n != this->end(); ++n)
{
content += n->getContentC() + ((n+1) == this->end() ? "" : nodeSeparator);
}
return content;
}
//
// Tree::NodeSet::Dump
//
Tree::NodeSet::Dump::Dump()
{}
/** @brief Append a free text to the dump. */
int Tree::NodeSet::Dump::concat(std::string const & text)
{
int writtenPre(outbuf_.getSize());
outbuf_.concat(text);
return outbuf_.getSize() - writtenPre;
}
int Tree::NodeSet::Dump::concat(Node const & node, bool const & format, std::string const & encoding)
{
int writtenPre(outbuf_.getSize());
xmlNodeDumpOutput(outbuf_.get(), node.get()->doc, node.get(), 0, format ? 1 : 0, encoding.c_str());
return outbuf_.getSize() - writtenPre;
}
Tree::NodeSet::Dump::Dump(Node const & node,
bool const & format, std::string const & encoding)
{
concat(node, format, encoding);
}
int Tree::NodeSet::Dump::concat(NodeSet const & nodeSet,
bool const & format, std::string const & encoding)
{
int written(0);
for (Tree::NodeSet::const_iterator n(nodeSet.begin()); n != nodeSet.end(); ++n)
{
written += concat(*n, format, encoding);
}
return written;
}
Tree::NodeSet::Dump::Dump(NodeSet const & nodeSet,
bool const & format, std::string const & encoding)
{
concat(nodeSet, format, encoding);
}
char const * Tree::NodeSet::Dump::getC() const
{
return outbuf_.getBuf();
}
std::string Tree::NodeSet::Dump::get() const
{
return getC();
}
int Tree::NodeSet::Dump::getSize() const
{
return outbuf_.getSize();
}
std::string Tree::NodeSet::dump(bool const & format, std::string const & encoding) const
{
return NodeSet::Dump(*this, format, encoding).getC();
}
//
// Tree::Dump
//
Tree::Dump::Dump(Tree const & tree, bool const & format, std::string const & encoding)
:buf_(0)
,size_(0)
{
xmlDocDumpFormatMemoryEnc(tree.get(), &buf_, &size_, encoding.c_str(), format ? 1 : 0);
if (!buf_)
{
UI_THROW_CODE(Mem_, "xmlDocDumpMemoryEnc: Allocation error?");
}
}
Tree::Dump::~Dump()
{
xmlFree(buf_);
}
char const * Tree::Dump::getC() const
{
return (char *) buf_;
}
std::string Tree::Dump::get() const
{
return getC();
}
int Tree::Dump::getSize() const
{
return size_;
}
std::string Tree::dump(bool const & format, std::string const & encoding) const
{
return Dump(*this, format, encoding).getC();
}
std::string Tree::formatDump(std::string const & encoding) const
{
return UI::GXML::Tree(dump()).dump(true, encoding);
}
std::string Tree::getOrigEncoding() const
{
return get()->encoding ? (char *) get()->encoding : UI::Util::EmptyString_;
}
XPathObject Tree::getXPathObject(std::string const & xpath) const
{
return XPathObject(XPathContextSwitch(*this, xPathNamespaces_).get(), xpath);
}
Tree::NodeSet Tree::getNodeSet(std::string const & xpath) const
{
return NodeSet(XPathObject(XPathContextSwitch(*this, xPathNamespaces_).get(), xpath));
}
Tree::Node Tree::getNode(std::string const & xpath, bool const & doThrow) const
{
NodeSet ns(getNodeSet(xpath));
if (ns.empty() && doThrow)
{
UI_THROW_CODE(NoNode_, "No such node: " + xpath);
}
return ns.empty() ? Node(0) : ns[0];
}
Tree::Node Tree::getRootNode() const
{
return getNode("/*", true);
}
int Tree::getCount(std::string const & xpath) const
{
return getNodeSet(xpath).size();
}
bool Tree::exists(std::string const & xpath, int const times) const
{
return getCount(xpath) >= times;
}
std::string Tree::getContent(std::string const & xpath) const
{
return getNodeSet(xpath).getContent();
}
void Tree::setContent(std::string const & xpath, std::string const & content)
{
getNode(xpath, true).setContent(content);
}
void Tree::setName(std::string const & xpath, std::string const & name)
{
getNode(xpath, true).setName(name);
}
void Tree::setAttribute(std::string const & xpath, std::string const & name, std::string const & content)
{
getNode(xpath, true).setAttribute(name, content);
}
std::string Tree::getAttribute(std::string const & xpath, std::string const & name) const
{
return getNode(xpath, false).getAttribute(name);
}
Tree::Node Tree::addChild(std::string const & xpath, Node const & node)
{
return getNode(xpath, true).addChild(node);
}
Tree::Node Tree::addChild(std::string const & xpath, std::string const & name, std::string const & content)
{
return getNode(xpath, true).addChild(name, content);
}
void Tree::unlink(std::string const & xpath)
{
getNode(xpath, true).unlink();
}
void Tree::addTree(std::string const & xpath, Tree const & source, std::string const & sourceXPath)
{
NodeSet ns(source.getNodeSet(sourceXPath));
for (NodeSet::const_iterator i(ns.begin()); i != ns.end(); ++i)
{
addChild(xpath, *i);
}
}
void Tree::addXML(std::string const & xpath, std::string const & source, std::string const & sourceXPath)
{
return addTree(xpath, Tree(source), sourceXPath);
}
//
// Internal helper XPathContextSwitch
//
Tree::XPathContextSwitch::XPathContextSwitch(Tree const & tree, NamespaceMap const & ns)
:treeContext_(tree.context_)
,tempContext_(treeContext_ ? 0 : new XPathContext(tree))
{
if (!ns.empty())
{
XPathContext * ctx(treeContext_ ? treeContext_ : tempContext_);
for (NamespaceMap::const_iterator i(ns.begin()); i != ns.end(); ++i)
{
ctx->registerNamespace(i->first, i->second);
}
}
}
Tree::XPathContextSwitch::~XPathContextSwitch()
{
delete tempContext_;
}
XPathContext & Tree::XPathContextSwitch::get()
{
assert(treeContext_ || tempContext_);
return treeContext_ ? *treeContext_ : *tempContext_;
}
}}
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/PaxHeaders.12816/Makefile.am 0000644 0000000 0000000 00000000074 12363527547 020277 x ustar 00 30 atime=1583248781.112270452
30 ctime=1583249814.929217404
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/Makefile.am 0000644 0001750 0001750 00000001357 12363527547 021364 0 ustar 00absurd absurd 0000000 0000000 AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/compat-1.0 $(XML_CFLAGS) $(XSLT_CFLAGS)
AM_CXXFLAGS = -pthread -Wall
incdir = $(includedir)/$(PACKAGE)
inc_HEADERS = \
Exception.hpp \
Util.hpp \
Conf.hpp \
XPathContext.hpp XPathObject.hpp Buffer.hpp \
Tree.hpp XSLTree.hpp XSLTransTree.hpp ValidatorTree.hpp SchemaTree.hpp RelaxNGTree.hpp \
\
Shortcuts.hpp
lib_LTLIBRARIES = libui-gxmlcpp.la
libui_gxmlcpp_la_SOURCES = \
Conf.cpp \
XPathContext.cpp XPathObject.cpp Buffer.cpp \
Tree.cpp XSLTree.cpp XSLTransTree.cpp ValidatorTree.cpp SchemaTree.cpp RelaxNGTree.cpp
libui_gxmlcpp_la_LDFLAGS = -version-info @SO_VERSION@ $(XML_LIBS) $(XSLT_LIBS) -lexslt
libui_gxmlcpp_la_LIBADD = ../compat-1.0/ui-gxmlcpp/libui-gxmlcpp-compat-1.0.la
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/PaxHeaders.12816/XSLTransTree.cpp 0000644 0000000 0000000 00000000074 12363527547 021245 x ustar 00 30 atime=1583248809.543595822
30 ctime=1583249814.949216966
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/XSLTransTree.cpp 0000644 0001750 0001750 00000004465 12363527547 022335 0 ustar 00absurd absurd 0000000 0000000 /**
* @file
* @version @$Id$
* @author
* ui-gxmlcpp: C++ wrapper for Gnome libxml2/libxsl.
* Copyright (C) Schlund+Partner AG 2002-2004.
* Licensed under the GNU Lesser General Public License (LGPL). See
* @ref License, or the file COPYING in distribution.
*/
// Local configuration
#include "config.h"
// Implementation
#include "XSLTransTree.hpp"
// STDC++
#include
// C libraries
#include
#include
#include
// Local
#include "Util.hpp"
namespace UI {
namespace GXML {
XSLTransTree::Params & XSLTransTree::Params::add(std::string const & name, std::string const & value)
{
CStrArray::add(name);
CStrArray::add(value);
return *this;
}
XSLTransTree::XSLTransTree(XSLTree const & style, Tree const & tree, Params const & params)
:xslTree_(&style)
{
xmlDoc * const doc(xsltApplyStylesheet(style.getStylesheet(), tree.get(), params.get()));
if (!doc)
{
UI_THROW_CODE(Apply_, "Error applying stylesheet");
}
set(doc);
}
XSLTransTree::XSLTransTree(XSLTree const & style, XMLTree const * const tree, Params const & params)
:xslTree_(&style)
{
assert(tree);
xmlDoc * const doc(xsltApplyStylesheet(style.getStylesheet(), tree->getDocPtr(), params.get()));
if (!doc)
{
UI_THROW_CODE(Apply_, "Error applying stylesheet");
}
set(doc);
}
std::string XSLTransTree::getOutputEncoding() const
{
return xslTree_->getOutputEncoding();
}
XSLTransTree::Dump::Dump(XSLTransTree const & xslTransTree)
:xslTransTree_(&xslTransTree)
,buf_(0)
,size_(0)
{
// Note: (1.1.8) xsltSaveResultToString does NOT return the amount of bytes on success as described in the docs.
int res(xsltSaveResultToString(&buf_, &size_, xslTransTree_->get(), xslTransTree_->getStylesheet()));
if (res < 0)
{
UI_THROW_CODE(Mem_, "Error dumping xsl translation result");
}
}
XSLTransTree::Dump::~Dump()
{
if (buf_)
{
xmlFree(buf_);
}
}
char const * XSLTransTree::Dump::getC() const
{
return buf_ ? (char *) buf_ : UI::Util::EmptyString_.c_str();
}
std::string XSLTransTree::Dump::get() const
{
return getC();
}
int XSLTransTree::Dump::getSize() const
{
return size_;
}
std::string XSLTransTree::Dump::getEncoding() const
{
return xslTransTree_->getOutputEncoding();
}
xsltStylesheet * XSLTransTree::getStylesheet() const
{
return xslTree_->getStylesheet();
}
}}
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/PaxHeaders.12816/SchemaTree.hpp 0000644 0000000 0000000 00000000074 12363527547 020774 x ustar 00 30 atime=1583248809.543595822
30 ctime=1583249814.941217141
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/SchemaTree.hpp 0000644 0001750 0001750 00000002316 12363527547 022055 0 ustar 00absurd absurd 0000000 0000000 /**
* @file
* @version @$Id$
* @author
* ui-gxmlcpp: C++ wrapper for Gnome libxml2/libxsl.
* Copyright (C) Schlund+Partner AG 2002-2004.
* Licensed under the GNU Lesser General Public License (LGPL). See
* @ref License, or the file COPYING in distribution.
*/
#ifndef UI_GXML_SCHEMATREE_HPP
#define UI_GXML_SCHEMATREE_HPP
// STDC++
#include
// C++ Libraries
#include
// C libraries
#include
namespace UI {
namespace GXML {
/** @brief XML Schema Tree. */
class SchemaTree: public ValidatorTree
{
private:
void init();
public:
/** @name Standard tree constructors.
* @{ @see UI::GXML::Tree. */
SchemaTree(char const * xml, int len=-1, std::string const & base=DefaultDocbase_, int const options=0);
SchemaTree(std::string const & xml, std::string const & base=DefaultDocbase_, int const options=0);
SchemaTree(std::istream & xml, std::string const & base=DefaultDocbase_, int const options=0);
SchemaTree(FileConstructor const dummy, std::string const & file, int const options=0);
/** @} */
~SchemaTree();
private:
virtual int libxml2Validate(Tree const & tree) const;
xmlSchemaParserCtxt * parserCtxt_;
xmlSchema * schema_;
};
}}
#endif
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/PaxHeaders.12816/Conf.hpp 0000644 0000000 0000000 00000000132 13627473367 017640 x ustar 00 30 mtime=1583249143.443669175
30 atime=1583249160.051274799
30 ctime=1583249814.933217316
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/Conf.hpp 0000644 0001750 0001750 00000003742 13627473367 020732 0 ustar 00absurd absurd 0000000 0000000 /**
* @file
* @version @$Id$
* @author
* ui-gxmlcpp: C++ wrapper for Gnome libxml2/libxsl.
* Copyright (C) Schlund+Partner AG 2002-2004.
* Licensed under the GNU Lesser General Public License (LGPL). See
* @ref License, or the file COPYING in distribution.
*/
#ifndef UI_GXML_CONF_HPP
#define UI_GXML_CONF_HPP
// STDC++
#include
namespace UI {
namespace GXML {
/** @brief libxml2/libxslt configuration helper.
*
* You would normally have one instance of this alive while
* operational. For custom logging, overwrite customLog().
*
*/
class Conf
{
public:
Conf();
virtual ~Conf();
/** @brief Overwrite this for custom logging.
*
* This defaults to logging to std::clog.
*
* @param msg Fragmented log stream including newlines.
*
* If you have line based logging, you might consider streaming msg
* into a stream buffer (with multi thread safety) and log only when
* you got a complete line. Unfortunately, msg may or may not
* include newlines and/or be a complete log line or not (i.e.,
* lines are being broadcast to the hooks in fragments).
*/
virtual void customLog(std::string const & msg);
/** @brief Set/unset custom logging (optionally with custom prefix).
*
* When enabled, logging will be done through us (i.e.,
* libxmlLog()). You would normally want to call this in a derived
* class' constructor where customLog() is overwritten.
*/
Conf & setCustomLogging(bool on=true, std::string prefix="[libxml2/xslt] ");
/** @brief En/disable custom logging. Defaults to "enable" ("don't care" if custom logging is unset). */
Conf & setCustomLoggingEnable(bool on=true);
/** @brief Odd libxml2 global feature ;). See libxml2 docs. */
static void setKeepBlanks(bool on=true);
/** @brief Register exslt functions for use with xsl transformations. */
Conf & setEXSLT();
private:
void memberLog(std::string const & msg);
static void libxmlLog(void * ctx, const char * msg, ...);
bool customLoggingEnabled_;
std::string logPrefix_;
};
}}
#endif
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/PaxHeaders.12816/XPathContext.cpp 0000644 0000000 0000000 00000000074 12363527547 021340 x ustar 00 30 atime=1583248809.543595822
30 ctime=1583249814.945217053
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/XPathContext.cpp 0000644 0001750 0001750 00000002526 12363527547 022424 0 ustar 00absurd absurd 0000000 0000000 /**
* @file
* @version @$Id$
* @author
* ui-gxmlcpp: C++ wrapper for Gnome libxml2/libxsl.
* Copyright (C) Schlund+Partner AG 2002-2004.
* Licensed under the GNU Lesser General Public License (LGPL). See
* @ref License, or the file COPYING in distribution.
*/
// Local configuration
#include "config.h"
// Implementation
#include "XPathContext.hpp"
// STDC++
#include
#include
// C libraries
#include
// C++ libraries
#include
#include
// Local
#include "Util.hpp"
namespace UI {
namespace GXML {
xmlXPathContext * XPathContext::create(xmlDoc * doc, xmlNode * node)
{
xmlXPathContextPtr context(xmlXPathNewContext(doc));
if (!context)
{
UI_THROW_CODE(Create_, "Could not create XPath context for tree");
}
context->node = node;
return context;
}
XPathContext::XPathContext(xmlDoc * doc, xmlNode * node)
{
set(create(doc, node));
}
XPathContext::XPathContext(Tree const & tree, xmlNode * node)
{
set(create(tree.get(), node));
}
XPathContext::~XPathContext()
{
xmlXPathFreeContext(get());
}
void XPathContext::registerNamespace(std::string const & prefix, std::string const & uri)
{
::xmlXPathRegisterNs(get(), reinterpret_cast(prefix.c_str()),
reinterpret_cast(uri.c_str()));
}
}}
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/PaxHeaders.12816/Shortcuts.hpp 0000644 0000000 0000000 00000000074 12363527547 020752 x ustar 00 30 atime=1583248809.543595822
30 ctime=1583249814.941217141
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/Shortcuts.hpp 0000644 0001750 0001750 00000000332 12363527547 022027 0 ustar 00absurd absurd 0000000 0000000 /**
* @file
* @version @$Id$
* @brief Include this to use the namespace shortcuts.
*/
#ifndef UI_GXML_SHORTCUTS_HPP
#define UI_GXML_SHORTCUTS_HPP
namespace UI { namespace GXML {}}
namespace X = UI::GXML;
#endif
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/PaxHeaders.12816/ValidatorTree.hpp 0000644 0000000 0000000 00000000074 12363527547 021521 x ustar 00 30 atime=1583248809.543595822
30 ctime=1583249814.937217228
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/ValidatorTree.hpp 0000644 0001750 0001750 00000003313 12363527547 022600 0 ustar 00absurd absurd 0000000 0000000 /**
* @file
* @version @$Id$
* @author
* ui-gxmlcpp: C++ wrapper for Gnome libxml2/libxsl.
* Copyright (C) Schlund+Partner AG 2002-2004.
* Licensed under the GNU Lesser General Public License (LGPL). See
* @ref License, or the file COPYING in distribution.
*/
#ifndef UI_GXML_VALIDATORTREE_HPP
#define UI_GXML_VALIDATORTREE_HPP
// STDC++
#include
// C++ Libraries
#include
namespace UI {
namespace GXML {
/** @brief Common abstract base class for validator trees (XML Schema and RelaxNG). */
class ValidatorTree: public Tree
{
public:
/** @name Standard tree constructors.
* @{ @see UI::GXML::Tree. */
ValidatorTree(char const * xml, int len=-1, std::string const & base=DefaultDocbase_, int const options=0);
ValidatorTree(std::string const & xml, std::string const & base=DefaultDocbase_, int const options=0);
ValidatorTree(std::istream & xml, std::string const & base=DefaultDocbase_, int const options=0);
ValidatorTree(FileConstructor const dummy, std::string const & file, int const options=0);
/** @} */
virtual ~ValidatorTree();
private:
/** @name Not implemented -- protect against segfaults.
* @{ */
ValidatorTree(ValidatorTree const & tree);
ValidatorTree & operator=(ValidatorTree const & tree);
/** @} */
public:
/** @brief Error codes for exceptions. */
enum ErrorCode
{
Ctxt_=1,
Parse_,
ValidCtxt_,
Internal_,
TreeInvalid_
};
/** @brief Exceptions for this class. */
typedef CodeException Exception;
private:
virtual int libxml2Validate(Tree const & tree) const = 0;
public:
/** @name Validate given trees.
* @{ */
bool isValid(Tree const & tree) const;
Tree const & validate(Tree const & tree) const;
/** @} */
};
}}
#endif
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/PaxHeaders.12816/Exception.hpp 0000644 0000000 0000000 00000000074 12363527547 020712 x ustar 00 30 atime=1583248809.543595822
30 ctime=1583249814.929217404
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/Exception.hpp 0000644 0001750 0001750 00000002241 12363527547 021770 0 ustar 00absurd absurd 0000000 0000000 /**
* @file
* @version @$Id$
* @author
* ui-gxmlcpp: C++ wrapper for Gnome libxml2/libxsl.
* Copyright (C) Schlund+Partner AG 2002-2004.
* Licensed under the GNU Lesser General Public License (LGPL). See
* @ref License, or the file COPYING in distribution.
*/
#ifndef UI_GXML_EXCEPTION_HPP
#define UI_GXML_EXCEPTION_HPP
// STDC++
#include
// C++ libraries
#include
namespace UI {
namespace GXML {
/** @brief Mother exception class for this namespace. */
class Exception: public UI::Exception
{
public:
Exception(std::string const & what=NoWhatGiven_, std::string const & debug=NoDebugGiven_)
:UI::Exception(what, debug)
{}
virtual ~Exception() throw() {};
};
/** @brief Adding code facility to Exception. */
template
class CodeException: public Exception
{
public:
/** @brief Construct with code and description text. */
CodeException(Code const & code, std::string const & what=NoWhatGiven_, std::string const & debug=NoDebugGiven_)
:UI::GXML::Exception(what, debug)
,code_(code)
{};
/** @brief Get code. */
Code const & getCode() const { return code_; }
private:
Code const code_;
};
}}
#endif
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/PaxHeaders.12816/Tree.hpp 0000644 0000000 0000000 00000000132 13554621605 017637 x ustar 00 30 mtime=1572021125.213833194
30 atime=1583248809.543595822
30 ctime=1583249814.937217228
ui-gxmlcpp-1.4.5/src/ui-gxmlcpp/Tree.hpp 0000644 0001750 0001750 00000030502 13554621605 020723 0 ustar 00absurd absurd 0000000 0000000 /**
* @file
* @version @$Id$
* @author
* ui-gxmlcpp: C++ wrapper for Gnome libxml2/libxsl.
* Copyright (C) Schlund+Partner AG 2002-2004.
* Licensed under the GNU Lesser General Public License (LGPL). See
* @ref License, or the file COPYING in distribution.
*/
#ifndef UI_GXML_TREE_HPP
#define UI_GXML_TREE_HPP
// STDC++
#include
#include
#include
#include
// C++ libraries
#include
#include
#include
#include
#include
namespace UI {
namespace GXML {
/** @brief XML tree. */
class Tree: private UI::Util::auto_base
{
friend class XSLTransTree;
friend class SchemaTree;
friend class RelaxNGTree;
private:
/* Create a libxml2