DRDE/ACTK1_0/xml/NamespaceResolver.cpp

53 lines
1.6 KiB
C++

#include "xml/NamespaceResolver.hpp"
#include <algorithm>
using namespace xalanc;
using namespace std;
NamespaceResolver::NamespaceResolver(const char* baseURI)
{
if (baseURI)
{
this->baseURI = XalanDOMString(baseURI);
}
addNamespace("urn:ietf:params:xml:ns:epp-1.0", "e");
addNamespace("urn:ietf:params:xml:ns:contact-1.0", "contact");
addNamespace("urn:ietf:params:xml:ns:host-1.0", "host");
addNamespace("urn:ietf:params:xml:ns:domain-1.0", "domain");
addNamespace("urn:ietf:params:xml:ns:e164epp-1.0", "e164epp");
addNamespace("urn:ietf:params:xml:ns:launch-1.0", "launch");
addNamespace("urn:ietf:params:xml:ns:mark-1.0", "mark");
addNamespace("urn:ietf:params:xml:ns:signedMark-1.0", "smd");
addNamespace("urn:X-ac:params:xml:ns:sync-1.0", "sync");
addNamespace("urn:X-ac:params:xml:ns:kv-1.0", "kv");
addNamespace("urn:X-ac:params:xml:ns:registrant-1.0", "registrant");
addNamespace("urn:ietf:params:xml:ns:secDNS-1.1", "secDNS");
}
NamespaceResolver::~NamespaceResolver()
{ }
const xalanc::XalanDOMString& NamespaceResolver::getURI() const
{
return baseURI;
}
const XalanDOMString* NamespaceResolver::getNamespaceForPrefix(const XalanDOMString& prefix) const
{
MapType::const_iterator i = prefixMap.find(prefix);
if (i == prefixMap.end())
{
return NULL;
}
return &(i->second);
}
//// NB only first uri to prefix map call has an effect.
void NamespaceResolver::addNamespace(const char *uri, const char *prefix)
{
prefixMap.insert(std::make_pair(XalanDOMString(prefix), XalanDOMString(uri)));
}