30#include "NCMLParser.h"
31#include "OtherXMLParser.h"
32#include "XMLHelpers.h"
37 _rParser(p), _depth(0), _otherXML(
"")
41OtherXMLParser::~OtherXMLParser()
63void OtherXMLParser::onStartDocument()
65 THROW_NCML_INTERNAL_ERROR(
"OtherXMLParser::onStartDocument called! This is a logic bug.");
68void OtherXMLParser::onEndDocument()
70 THROW_NCML_INTERNAL_ERROR(
"OtherXMLParser::onEndDocument called! This is a logic bug.");
75 appendOpenStartElementTag(name,
"");
76 appendAttributes(attrs);
78 appendCloseStartElementTag();
85 appendEndElementTag(name);
92 appendOpenStartElementTag(localname, prefix);
93 appendAttributes(attributes);
99 "Got depth 0 OtherXML element while parsing OtherXML attribute..." <<
" Pulling all un-shadowed ancestral namespaces into the element with localname=" << localname << std::endl);
105 _rParser.getXMLNamespaceStack().getFlattenedNamespacesUsingLexicalScoping(ancestralNamespaces);
106 appendNamespaces(ancestralNamespaces);
110 appendNamespaces(namespaces);
113 appendCloseStartElementTag();
128 _otherXML.append(content);
133 THROW_NCML_PARSE_ERROR(-1,
134 "OtherXMLParser: got SAX parse warning while parsing OtherXML. Msg was: " + msg);
139 THROW_NCML_PARSE_ERROR(-1,
"OtherXMLParser: got SAX parse error while parsing OtherXML. Msg was: " + msg);
142void OtherXMLParser::appendOpenStartElementTag(
const std::string& localname,
const std::string& prefix)
149void OtherXMLParser::appendAttributes(
const XMLAttributeMap& attributes)
151 for (XMLAttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); ++it) {
152 _otherXML += (string(
" ") + it->getQName() +
"=\"" + it->value +
"\"");
156void OtherXMLParser::appendNamespaces(
const XMLNamespaceMap& namespaces)
158 _otherXML += namespaces.getAllNamespacesAsAttributeString();
161void OtherXMLParser::appendCloseStartElementTag()
166void OtherXMLParser::appendEndElementTag(
const string& qname)
168 _otherXML += (string(
"</") + qname +
">");
171void OtherXMLParser::pushDepth()
176void OtherXMLParser::popDepth()
183 THROW_NCML_INTERNAL_ERROR(
"OtherXMLElement::onEndElement: _depth < 0! Logic error in parsing OtherXML.");
virtual void onStartElementWithNamespace(const std::string &localname, const std::string &prefix, const std::string &uri, const XMLAttributeMap &attributes, const XMLNamespaceMap &namespaces)
const std::string & getString() const
virtual void onParseWarning(std::string msg)
virtual void onParseError(std::string msg)
int getParseDepth() const
virtual void onEndElement(const std::string &name)
virtual void onStartElement(const std::string &name, const XMLAttributeMap &attrs)
virtual void onCharacters(const std::string &content)
virtual void onEndElementWithNamespace(const std::string &localname, const std::string &prefix, const std::string &uri)
NcML Parser for adding/modifying/removing metadata (attributes) to existing local datasets using NcML...
std::string getQName() const