/*
- * Copyright 2001-2009 Internet2
+ * Copyright 2001-2010 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <xmltooling/base.h>
+#include <set>
#include <iostream>
#include <xercesc/dom/DOM.hpp>
/**
* Returns resource held by this object.
*
- * @return the resource held or NULL
+ * @return the resource held or nullptr
*/
T* get() {
return m_held;
/**
* Returns resource held by this object.
*
- * @return the resource held or NULL
+ * @return the resource held or nullptr
*/
T* operator->() {
return m_held;
/**
* Returns resource held by this object and releases it to the caller.
*
- * @return the resource held or NULL
+ * @return the resource held or nullptr
*/
T* release() {
T* ret=m_held;
- m_held=NULL;
+ m_held=nullptr;
return ret;
}
};
*
* @param tree root of tree to search
* @param id ID value to locate
- * @return XMLObject in the tree with a matching ID value, or NULL
+ * @return XMLObject in the tree with a matching ID value, or nullptr
*/
static const XMLObject* getXMLObjectById(const XMLObject& tree, const XMLCh* id);
*
* @param tree root of tree to search
* @param id ID value to locate
- * @return XMLObject in the tree with a matching ID value, or NULL
+ * @return XMLObject in the tree with a matching ID value, or nullptr
*/
static XMLObject* getXMLObjectById(XMLObject& tree, const XMLCh* id);
/**
+ * Returns a list of non-visibly-used namespace prefixes found in a tree.
+ *
+ * @param tree root of tree to search
+ * @param prefixes container to store prefix list
+ */
+ static void getNonVisiblyUsedPrefixes(const XMLObject& tree, std::set<xstring>& prefixes);
+
+ /**
* Gets the QName for the given DOM node.
*
* @param domNode the DOM node
* @param local local name to compare with
* @return true iff the node's qualified name matches the other parameters
*/
- static bool isNodeNamed(const xercesc::DOMNode* n, const XMLCh* ns, const XMLCh* local) {
- return (n && xercesc::XMLString::equals(local,n->getLocalName()) && xercesc::XMLString::equals(ns,n->getNamespaceURI()));
- }
+ static bool isNodeNamed(const xercesc::DOMNode* n, const XMLCh* ns, const XMLCh* local);
/**
* Returns the first matching child element of the node if any.
*
* @param n node to check
- * @param localName local name to compare with or NULL for any match
- * @return the first matching child node of type Element, or NULL
+ * @param localName local name to compare with or nullptr for any match
+ * @return the first matching child node of type Element, or nullptr
*/
- static xercesc::DOMElement* getFirstChildElement(const xercesc::DOMNode* n, const XMLCh* localName=NULL);
+ static xercesc::DOMElement* getFirstChildElement(const xercesc::DOMNode* n, const XMLCh* localName=nullptr);
/**
* Returns the last matching child element of the node if any.
*
* @param n node to check
- * @param localName local name to compare with or NULL for any match
- * @return the last matching child node of type Element, or NULL
+ * @param localName local name to compare with or nullptr for any match
+ * @return the last matching child node of type Element, or nullptr
*/
- static xercesc::DOMElement* getLastChildElement(const xercesc::DOMNode* n, const XMLCh* localName=NULL);
+ static xercesc::DOMElement* getLastChildElement(const xercesc::DOMNode* n, const XMLCh* localName=nullptr);
/**
* Returns the next matching sibling element of the node if any.
*
* @param n node to check
- * @param localName local name to compare with or NULL for any match
- * @return the next matching sibling node of type Element, or NULL
+ * @param localName local name to compare with or nullptr for any match
+ * @return the next matching sibling node of type Element, or nullptr
*/
- static xercesc::DOMElement* getNextSiblingElement(const xercesc::DOMNode* n, const XMLCh* localName=NULL);
+ static xercesc::DOMElement* getNextSiblingElement(const xercesc::DOMNode* n, const XMLCh* localName=nullptr);
/**
* Returns the previous matching sibling element of the node if any.
*
* @param n node to check
- * @param localName local name to compare with or NULL for any match
- * @return the previous matching sibling node of type Element, or NULL
+ * @param localName local name to compare with or nullptr for any match
+ * @return the previous matching sibling node of type Element, or nullptr
*/
- static xercesc::DOMElement* getPreviousSiblingElement(const xercesc::DOMNode* n, const XMLCh* localName=NULL);
+ static xercesc::DOMElement* getPreviousSiblingElement(const xercesc::DOMNode* n, const XMLCh* localName=nullptr);
/**
* Returns the first matching child element of the node if any.
* @param n node to check
* @param ns namespace to compare with
* @param localName local name to compare with
- * @return the first matching child node of type Element, or NULL
+ * @return the first matching child node of type Element, or nullptr
*/
static xercesc::DOMElement* getFirstChildElement(const xercesc::DOMNode* n, const XMLCh* ns, const XMLCh* localName);
* @param n node to check
* @param ns namespace to compare with
* @param localName local name to compare with
- * @return the last matching child node of type Element, or NULL
+ * @return the last matching child node of type Element, or nullptr
*/
static xercesc::DOMElement* getLastChildElement(const xercesc::DOMNode* n, const XMLCh* ns, const XMLCh* localName);
* @param n node to check
* @param ns namespace to compare with
* @param localName local name to compare with
- * @return the next matching sibling node of type Element, or NULL
+ * @return the next matching sibling node of type Element, or nullptr
*/
static xercesc::DOMElement* getNextSiblingElement(const xercesc::DOMNode* n, const XMLCh* ns, const XMLCh* localName);
* @param n node to check
* @param ns namespace to compare with
* @param localName local name to compare with
- * @return the previous matching sibling node of type Element, or NULL
+ * @return the previous matching sibling node of type Element, or nullptr
*/
static xercesc::DOMElement* getPreviousSiblingElement(const xercesc::DOMNode* n, const XMLCh* ns, const XMLCh* localName);
* examples the immediate children of the element.
*
* @param e element to examine
- * @return the content of the first Text node found, or NULL
+ * @return the content of the first Text node found, or nullptr
*/
static const XMLCh* getTextContent(const xercesc::DOMElement* e);