X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=xmltooling%2Futil%2FXMLHelper.cpp;h=26823958c5d9d4dce3fb3583828f4ba52f3162fd;hb=2d795c731e6729309044607154978696a87fd900;hp=f257b8c439e3e8ee57f3cabc0cfe55ec4a4749c4;hpb=81b488b2790e7bdeb2f43560b1d4a7d22c3dfdf5;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/util/XMLHelper.cpp b/xmltooling/util/XMLHelper.cpp index f257b8c..2682395 100644 --- a/xmltooling/util/XMLHelper.cpp +++ b/xmltooling/util/XMLHelper.cpp @@ -31,11 +31,16 @@ #include "util/XMLHelper.h" #include "util/XMLConstants.h" +#include +#include +#include #include #include using namespace xmltooling; using namespace xercesc; +using namespace boost::lambda; +using namespace boost; using namespace std; static const XMLCh type[]={chLatin_t, chLatin_y, chLatin_p, chLatin_e, chNull }; @@ -77,7 +82,7 @@ DOMAttr* XMLHelper::getIdAttribute(const DOMElement* domElement) DOMNamedNodeMap* attributes = domElement->getAttributes(); DOMAttr* attribute; - for(XMLSize_t i = 0; i < attributes->getLength(); i++) { + for(XMLSize_t i = 0; i < attributes->getLength(); ++i) { attribute = static_cast(attributes->item(i)); if(attribute->isId()) { return attribute; @@ -94,7 +99,7 @@ const XMLObject* XMLHelper::getXMLObjectById(const XMLObject& tree, const XMLCh* const XMLObject* ret; const list& children = tree.getOrderedChildren(); - for (list::const_iterator i=children.begin(); i!=children.end(); ++i) { + for (list::const_iterator i = children.begin(); i != children.end(); ++i) { if (*i) { ret = getXMLObjectById(*(*i), id); if (ret) @@ -109,10 +114,10 @@ XMLObject* XMLHelper::getXMLObjectById(XMLObject& tree, const XMLCh* id) { if (XMLString::equals(id, tree.getXMLID())) return &tree; - + XMLObject* ret; const list& children = tree.getOrderedChildren(); - for (list::const_iterator i=children.begin(); i!=children.end(); ++i) { + for (list::const_iterator i = children.begin(); i != children.end(); ++i) { if (*i) { ret = getXMLObjectById(*(*i), id); if (ret) @@ -126,10 +131,10 @@ XMLObject* XMLHelper::getXMLObjectById(XMLObject& tree, const XMLCh* id) void XMLHelper::getNonVisiblyUsedPrefixes(const XMLObject& tree, map& prefixes) { map child_prefixes; - const list& children = tree.getOrderedChildren(); - for (list::const_iterator i = children.begin(); i != children.end(); ++i) { - if (*i) + for(list::const_iterator i = tree.getOrderedChildren().begin(); i != tree.getOrderedChildren().end(); ++i) { + if (*i) { getNonVisiblyUsedPrefixes(*(*i), child_prefixes); + } } const set& nsset = tree.getNamespaces(); for (set::const_iterator ns = nsset.begin(); ns != nsset.end(); ++ns) { @@ -333,9 +338,11 @@ int XMLHelper::getAttrInt(const DOMElement* e, int defValue, const XMLCh* localN if (e) { const XMLCh* val = e->getAttributeNS(ns, localName); if (val && *val) { - int i = XMLString::parseInt(val); - if (i) - return i; + try { + return XMLString::parseInt(val); + } + catch (XMLException&) { + } } } return defValue; @@ -447,5 +454,11 @@ ostream& xmltooling::operator<<(ostream& ostr, const DOMNode& node) ostream& xmltooling::operator<<(ostream& ostr, const XMLObject& obj) { - return ostr << *(obj.marshall()); + try { + return ostr << *(obj.marshall()); + } + catch (DOMException& ex) { + auto_ptr_char msg(ex.getMessage()); + throw XMLParserException(msg.get()); + } }