X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2Fio%2FAbstractXMLObjectMarshaller.cpp;h=c28bcbfc2edf5fb0f8bbc06c760e72c3a147e3cf;hb=a0d768778a8f5f539b909baf5b115e70ea765f0f;hp=0157327494137c5e0e10e984e6bf491f3276f28c;hpb=2d0ee406f017bd67eef9e1b4b7a487025bc71f31;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltooling/io/AbstractXMLObjectMarshaller.cpp b/xmltooling/io/AbstractXMLObjectMarshaller.cpp index 0157327..c28bcbf 100644 --- a/xmltooling/io/AbstractXMLObjectMarshaller.cpp +++ b/xmltooling/io/AbstractXMLObjectMarshaller.cpp @@ -1,5 +1,5 @@ /* -* 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. @@ -43,6 +43,23 @@ using namespace xmltooling; using namespace xercesc; using namespace std; +AbstractXMLObjectMarshaller::AbstractXMLObjectMarshaller() +{ +} + +AbstractXMLObjectMarshaller::~AbstractXMLObjectMarshaller() +{ +} + +void AbstractXMLObjectMarshaller::setDocumentElement(DOMDocument* document, DOMElement* element) const +{ + DOMElement* documentRoot = document->getDocumentElement(); + if (documentRoot) + document->replaceChild(element, documentRoot); + else + document->appendChild(element); +} + DOMElement* AbstractXMLObjectMarshaller::marshall( DOMDocument* document #ifndef XMLTOOLING_NO_XMLSEC @@ -82,11 +99,11 @@ DOMElement* AbstractXMLObjectMarshaller::marshall( // We may need to create our own document. bool bindDocument=false; if (!document) { - document=DOMImplementationRegistry::getDOMImplementation(NULL)->createDocument(); + document=DOMImplementationRegistry::getDOMImplementation(nullptr)->createDocument(); bindDocument=true; } - XercesJanitor janitor(bindDocument ? document : NULL); + XercesJanitor janitor(bindDocument ? document : nullptr); m_log.debug("creating root element to marshall"); DOMElement* domElement = document->createElementNS( @@ -186,7 +203,7 @@ void AbstractXMLObjectMarshaller::marshallInto( chLatin_S, chLatin_c, chLatin_h, chLatin_e, chLatin_m, chLatin_a, chLatin_L, chLatin_o, chLatin_c, chLatin_a, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull }; - if (targetElement->getParentNode()==NULL || targetElement->getParentNode()->getNodeType()==DOMNode::DOCUMENT_NODE) { + if (targetElement->getParentNode()==nullptr || targetElement->getParentNode()->getNodeType()==DOMNode::DOCUMENT_NODE) { if (m_schemaLocation) targetElement->setAttributeNS(XSI_NS,schemaLocation,m_schemaLocation); if (m_noNamespaceSchemaLocation) @@ -211,8 +228,8 @@ void AbstractXMLObjectMarshaller::marshallInto( targetElement->setAttributeNS(XSI_NS, _nil, xmlconstants::XML_ZERO); break; } - m_log.debug("adding XSI namespace to list of namespaces used by XMLObject"); - addNamespace(Namespace(XSI_NS, XSI_PREFIX)); + m_log.debug("adding XSI namespace to list of namespaces visibly used by XMLObject"); + addNamespace(Namespace(XSI_NS, XSI_PREFIX, false, Namespace::VisiblyUsed)); } marshallElementType(targetElement); @@ -258,8 +275,8 @@ void AbstractXMLObjectMarshaller::marshallElementType(DOMElement* domElement) co if (xsivalue != typeLocalName) XMLString::release(&xsivalue); - m_log.debug("adding XSI namespace to list of namespaces used by XMLObject"); - addNamespace(Namespace(XSI_NS, XSI_PREFIX)); + m_log.debug("adding XSI namespace to list of namespaces visibly used by XMLObject"); + addNamespace(Namespace(XSI_NS, XSI_PREFIX, false, Namespace::VisiblyUsed)); } } @@ -296,12 +313,12 @@ public: } const XMLCh* lookupNamespaceURI(const DOMNode* n, const XMLCh* prefix) const { - // Return NULL if no declaration in effect. The empty string signifies the null namespace. + // Return nullptr if no declaration in effect. The empty string signifies the null namespace. if (!n || n->getNodeType()!=DOMNode::ELEMENT_NODE) { // At the root, the default namespace is set to the null namespace. if (!prefix || !*prefix) return &chNull; - return NULL; // we're done + return nullptr; // we're done } DOMNamedNodeMap* attributes = static_cast(n)->getAttributes(); if (!attributes) @@ -351,7 +368,7 @@ void AbstractXMLObjectMarshaller::marshallContent( for (list::const_iterator i=children.begin(); i!=children.end(); ++i) { if (*i) { #ifndef XMLTOOLING_NO_XMLSEC - (*i)->marshall(domElement,NULL,credential); + (*i)->marshall(domElement,nullptr,credential); #else (*i)->marshall(domElement); #endif @@ -361,3 +378,7 @@ void AbstractXMLObjectMarshaller::marshallContent( } } } + +void AbstractXMLObjectMarshaller::marshallAttributes(DOMElement* domElement) const +{ +}