29#ifndef __NCML_MODULE__XML_HELPERS_H__
30#define __NCML_MODULE__XML_HELPERS_H__
46#include <libxml/xmlstring.h>
53 static std::string xmlCharToString(
const xmlChar* pChars);
54 static void xmlCharToString(std::string& stringToFill,
const xmlChar* pChars);
55 static std::string xmlCharToStringFromIterators(
const xmlChar* startPtr,
const xmlChar* endPtr);
59 XMLAttribute(
const std::string& localName =
"",
const std::string& value =
"",
const std::string& prefix =
"",
60 const std::string& nsURI =
"");
66 XMLAttribute(
const xmlChar** chunkOfFivePointers);
67 XMLAttribute(
const XMLAttribute& proto);
68 XMLAttribute& operator=(
const XMLAttribute& rhs);
85 static std::string
getQName(
const std::string& prefix,
const std::string& localname);
87 std::string localname;
93class XMLAttributeMap {
98 typedef std::vector<XMLAttribute>::const_iterator const_iterator;
99 typedef std::vector<XMLAttribute>::iterator iterator;
101 XMLAttributeMap::const_iterator begin()
const;
102 XMLAttributeMap::const_iterator end()
const;
114 const std::string& defVal =
"")
const;
118 const XMLAttribute* getAttributeByQName(
const std::string& qname)
const;
119 const XMLAttribute* getAttributeByQName(
const std::string& prefix,
const std::string& localname)
const;
127 XMLAttributeMap::iterator findByQName(
const std::string& qname);
132 std::vector<XMLAttribute> _attributes;
136 XMLNamespace(
const std::string& prefix =
"",
const std::string& uri =
"");
137 XMLNamespace(
const XMLNamespace& proto);
138 XMLNamespace& operator=(
const XMLNamespace& rhs);
150class XMLNamespaceMap {
154 XMLNamespaceMap(
const XMLNamespaceMap& proto);
155 XMLNamespaceMap& operator=(
const XMLNamespaceMap& rhs);
165 typedef std::vector<XMLNamespace>::const_iterator const_iterator;
167 XMLNamespaceMap::const_iterator begin()
const;
168 XMLNamespaceMap::const_iterator end()
const;
171 XMLNamespaceMap::const_iterator
find(
const std::string& prefix)
const;
173 bool isInMap(
const std::string& prefix)
const;
184 typedef std::vector<XMLNamespace>::iterator iterator;
186 XMLNamespaceMap::iterator findNonConst(
const std::string& prefix);
189 std::vector<XMLNamespace> _namespaces;
192class XMLNamespaceStack {
195 ~XMLNamespaceStack();
196 XMLNamespaceStack(
const XMLNamespaceStack& proto);
197 XMLNamespaceStack& operator=(
const XMLNamespaceStack& rhs);
207 typedef std::vector<XMLNamespaceMap>::const_reverse_iterator const_iterator;
210 XMLNamespaceStack::const_iterator
begin()
const;
211 XMLNamespaceStack::const_iterator end()
const;
236 std::vector<XMLNamespaceMap> _stack;
const std::string getValueForLocalNameOrDefault(const std::string &localname, const std::string &defVal="") const
const XMLAttribute * getAttributeByLocalName(const std::string &localname) const
void addAttribute(const XMLAttribute &attribute)
std::string getAllAttributesAsString() const
void fromSAX2Namespaces(const xmlChar **pNamespaces, int numNamespaces)
std::string getAllNamespacesAsAttributeString() const
void addNamespace(const XMLNamespace &ns)
XMLNamespaceMap::const_iterator find(const std::string &prefix) const
void getFlattenedNamespacesUsingLexicalScoping(XMLNamespaceMap &nsFlattened) const
XMLNamespaceStack::const_iterator begin() const
NcML Parser for adding/modifying/removing metadata (attributes) to existing local datasets using NcML...
std::string getAsXMLString() const
std::string getQName() const
void fromSAX2NamespaceAttributes(const xmlChar **chunkOfFivePointers)
std::string getAsAttributeString() const
void fromSAX2Namespace(const xmlChar **namespaces)