From 77769b2e300d1295b8a5d717d9ede50e27d70cea Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Thu, 12 Oct 2006 20:36:12 +0000 Subject: [PATCH] Multi-line svn commit, see body. Track DOM text nodes to ensure fidelity. Promoted text node handling to XMLObject, simplified subclasses. --- xmltooling/AbstractChildlessElement.h | 70 ---------------------- xmltooling/AbstractComplexElement.cpp | 25 +++++++- xmltooling/AbstractComplexElement.h | 19 ++++-- xmltooling/AbstractElementProxy.h | 13 ++-- ...ldlessElement.cpp => AbstractSimpleElement.cpp} | 10 ++-- xmltooling/AbstractSimpleElement.h | 25 ++++++-- xmltooling/AbstractXMLObject.cpp | 6 +- xmltooling/ElementProxy.h | 9 ++- xmltooling/Makefile.am | 4 +- xmltooling/SimpleElement.h | 59 ------------------ xmltooling/XMLObject.h | 18 ++++++ xmltooling/XMLToolingConfig.cpp | 2 +- xmltooling/base.h | 25 ++------ xmltooling/encryption/Encryption.h | 4 +- xmltooling/encryption/impl/EncryptionImpl.cpp | 23 ++++--- .../encryption/impl/EncryptionSchemaValidators.cpp | 1 + xmltooling/impl/AnyElement.cpp | 10 ---- xmltooling/impl/AnyElement.h | 4 +- xmltooling/impl/UnknownElement.h | 14 ++++- xmltooling/io/AbstractXMLObjectMarshaller.cpp | 29 +++++---- xmltooling/io/AbstractXMLObjectMarshaller.h | 11 +--- xmltooling/io/AbstractXMLObjectUnmarshaller.cpp | 33 +++++----- xmltooling/io/AbstractXMLObjectUnmarshaller.h | 13 +--- xmltooling/signature/KeyInfo.h | 6 +- xmltooling/signature/impl/InlineKeyResolver.cpp | 1 + xmltooling/signature/impl/KeyInfoImpl.cpp | 35 ++++++----- .../signature/impl/KeyInfoSchemaValidators.cpp | 1 + xmltooling/soap/SOAP.h | 4 +- xmltooling/soap/impl/SOAPImpl.cpp | 12 ++-- xmltooling/soap/impl/SOAPSchemaValidators.cpp | 1 + xmltooling/util/XMLHelper.h | 4 +- xmltooling/xmltooling.vcproj | 14 ++--- xmltoolingtest/ComplexXMLObjectTest.h | 7 ++- xmltoolingtest/KeyInfoTest.h | 1 + xmltoolingtest/XMLObjectBaseTestCase.h | 39 +++++------- 35 files changed, 225 insertions(+), 327 deletions(-) delete mode 100644 xmltooling/AbstractChildlessElement.h rename xmltooling/{AbstractChildlessElement.cpp => AbstractSimpleElement.cpp} (74%) delete mode 100644 xmltooling/SimpleElement.h diff --git a/xmltooling/AbstractChildlessElement.h b/xmltooling/AbstractChildlessElement.h deleted file mode 100644 index bb87812..0000000 --- a/xmltooling/AbstractChildlessElement.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file AbstractChildlessElement.h - * - * AbstractXMLObject mixin that blocks children - */ - -#ifndef __xmltooling_absnokids_h__ -#define __xmltooling_absnokids_h__ - -#include - -#if defined (_MSC_VER) - #pragma warning( push ) - #pragma warning( disable : 4250 4251 ) -#endif - -namespace xmltooling { - - /** - * AbstractXMLObject mixin that blocks children. - * Inherit from this class to implement a childless element. - */ - class XMLTOOL_API AbstractChildlessElement : public virtual AbstractXMLObject - { - public: - virtual ~AbstractChildlessElement() {} - - bool hasChildren() const { - return false; - } - - const std::list& getOrderedChildren() const { - return m_no_children; - } - - void removeChild(XMLObject* child); - - protected: - AbstractChildlessElement() {} - - /** Copy constructor. */ - AbstractChildlessElement(const AbstractChildlessElement& src) {} - - private: - static std::list m_no_children; - }; - -}; - -#if defined (_MSC_VER) - #pragma warning( pop ) -#endif - -#endif /* __xmltooling_absnokids_h__ */ diff --git a/xmltooling/AbstractComplexElement.cpp b/xmltooling/AbstractComplexElement.cpp index c3aa5aa..5555971 100644 --- a/xmltooling/AbstractComplexElement.cpp +++ b/xmltooling/AbstractComplexElement.cpp @@ -26,12 +26,33 @@ #include using namespace xmltooling; +using namespace std; AbstractComplexElement::~AbstractComplexElement() { - std::for_each(m_children.begin(), m_children.end(), cleanup()); + for_each(m_children.begin(), m_children.end(), cleanup()); + for (vector::iterator i=m_text.begin(); i!=m_text.end(); ++i) + XMLString::release(&(*i)); } void AbstractComplexElement::removeChild(XMLObject* child) { - m_children.erase(std::remove(m_children.begin(), m_children.end(), child), m_children.end()); + m_children.erase(remove(m_children.begin(), m_children.end(), child), m_children.end()); +} + +AbstractComplexElement::AbstractComplexElement(const AbstractComplexElement& src) +{ + for (vector::const_iterator i=src.m_text.begin(); i!=src.m_text.end(); ++i) + m_text.push_back(XMLString::replicate(*i)); +} + +void AbstractComplexElement::setTextContent(const XMLCh* value, unsigned int position) +{ + if (position > m_children.size()) + throw XMLObjectException("Can't set text content relative to non-existent child position."); + vector::size_type size = m_text.size(); + while (position >= size) { + m_text.push_back(NULL); + ++size; + } + m_text[position]=prepareForAssignment(m_text[position],value); } diff --git a/xmltooling/AbstractComplexElement.h b/xmltooling/AbstractComplexElement.h index 9f71657..ba8b862 100644 --- a/xmltooling/AbstractComplexElement.h +++ b/xmltooling/AbstractComplexElement.h @@ -15,7 +15,7 @@ */ /** - * @file AbstractComplexElement.h + * @file xmltooling/AbstractComplexElement.h * * AbstractXMLObject mixin that implements children */ @@ -34,8 +34,7 @@ namespace xmltooling { /** * AbstractXMLObject mixin that implements children. - * Inherit from this class to implement an element with child objects. - * No unprotected access to them is supplied here. + * Inherit from this class to implement an element with child objects and mixed content. */ class XMLTOOL_API AbstractComplexElement : public virtual AbstractXMLObject { @@ -52,17 +51,29 @@ namespace xmltooling { void removeChild(XMLObject* child); + const XMLCh* getTextContent(unsigned int position=0) const { + return (m_text.size() > position) ? m_text[position] : NULL; + } + + void setTextContent(const XMLCh* value, unsigned int position=0); + protected: AbstractComplexElement() {} /** Copy constructor. */ - AbstractComplexElement(const AbstractComplexElement& src) {} + AbstractComplexElement(const AbstractComplexElement& src); /** * Underlying list of child objects. * Manages the lifetime of the children. */ std::list m_children; + + /** + * Interstitial text nodes. + * Needed to support mixed content, and preserve DOM whitespace across rebuilds. + */ + std::vector m_text; }; }; diff --git a/xmltooling/AbstractElementProxy.h b/xmltooling/AbstractElementProxy.h index b8bd05f..ed95e53 100644 --- a/xmltooling/AbstractElementProxy.h +++ b/xmltooling/AbstractElementProxy.h @@ -15,7 +15,7 @@ */ /** - * @file AbstractElementProxy.h + * @file xmltooling/AbstractElementProxy.h * * AbstractXMLObject mixin that implements an open content model */ @@ -24,7 +24,6 @@ #define __xmltooling_abseleproxy_h__ #include -#include #include #if defined (_MSC_VER) @@ -35,12 +34,11 @@ namespace xmltooling { /** - * AbstractXMLObject mixin that implements an open content model. - * Inherit from this class to merge both simple and complex content + * AbstractXMLObject mixin that layers ElementProxy on top of a complex element. + * Inherit from this class to implement complex content * and expose the underlying child collection in read/write mode. */ - class XMLTOOL_API AbstractElementProxy - : public virtual ElementProxy, public AbstractSimpleElement, public AbstractComplexElement + class XMLTOOL_API AbstractElementProxy : public virtual ElementProxy, public AbstractComplexElement { public: virtual ~AbstractElementProxy() {} @@ -57,8 +55,7 @@ namespace xmltooling { AbstractElementProxy() {} /** Copy constructor. */ - AbstractElementProxy(const AbstractElementProxy& src) - : AbstractXMLObject(src), AbstractSimpleElement(src) {} + AbstractElementProxy(const AbstractElementProxy& src) : AbstractXMLObject(src), AbstractComplexElement(src) {} }; }; diff --git a/xmltooling/AbstractChildlessElement.cpp b/xmltooling/AbstractSimpleElement.cpp similarity index 74% rename from xmltooling/AbstractChildlessElement.cpp rename to xmltooling/AbstractSimpleElement.cpp index 1a37855..920aa3b 100644 --- a/xmltooling/AbstractChildlessElement.cpp +++ b/xmltooling/AbstractSimpleElement.cpp @@ -15,22 +15,22 @@ */ /** - * AbstractChildlessElement.cpp + * AbstractSimpleElement.cpp * - * Extension of AbstractXMLObject that implements childlessness + * Extension of AbstractXMLObject that implements simple elements */ #include "internal.h" -#include "AbstractChildlessElement.h" +#include "AbstractSimpleElement.h" using namespace xmltooling; using namespace std; // shared "empty" list of children for childless objects -list AbstractChildlessElement::m_no_children; +list AbstractSimpleElement::m_no_children; -void AbstractChildlessElement::removeChild(XMLObject* child) +void AbstractSimpleElement::removeChild(XMLObject* child) { throw XMLObjectException("Cannot remove child from a childless object."); } diff --git a/xmltooling/AbstractSimpleElement.h b/xmltooling/AbstractSimpleElement.h index 853da26..86e0e80 100644 --- a/xmltooling/AbstractSimpleElement.h +++ b/xmltooling/AbstractSimpleElement.h @@ -15,7 +15,7 @@ */ /** - * @file AbstractSimpleElement.h + * @file xmltooling/AbstractSimpleElement.h * * AbstractXMLObject mixin that implements a simple string-based content model */ @@ -24,7 +24,6 @@ #define __xmltooling_abssimpleel_h__ #include -#include #if defined (_MSC_VER) #pragma warning( push ) @@ -37,18 +36,30 @@ namespace xmltooling { * AbstractXMLObject mixin that implements a simple string-based content model. * Inherit from this class to support string-based element content. */ - class XMLTOOL_API AbstractSimpleElement : public virtual SimpleElement, public virtual AbstractXMLObject + class XMLTOOL_API AbstractSimpleElement : public virtual AbstractXMLObject { public: virtual ~AbstractSimpleElement() { XMLString::release(&m_value); } - virtual const XMLCh* getTextContent() const { - return m_value; + bool hasChildren() const { + return false; + } + + const std::list& getOrderedChildren() const { + return m_no_children; + } + + void removeChild(XMLObject* child); + + virtual const XMLCh* getTextContent(unsigned int position=0) const { + return (position==0) ? m_value : NULL; } - virtual void setTextContent(const XMLCh* value) { + virtual void setTextContent(const XMLCh* value, unsigned int position=0) { + if (position > 0) + throw XMLObjectException("Cannot set text content in simple element at position > 0."); m_value=prepareForAssignment(m_value,value); } @@ -61,6 +72,8 @@ namespace xmltooling { private: XMLCh* m_value; + + static std::list m_no_children; }; }; diff --git a/xmltooling/AbstractXMLObject.cpp b/xmltooling/AbstractXMLObject.cpp index 13a7e5c..e019f4e 100644 --- a/xmltooling/AbstractXMLObject.cpp +++ b/xmltooling/AbstractXMLObject.cpp @@ -50,15 +50,13 @@ AbstractXMLObject::AbstractXMLObject(const AbstractXMLObject& src) XMLCh* AbstractXMLObject::prepareForAssignment(XMLCh* oldValue, const XMLCh* newValue) { - XMLCh* newString = XMLString::replicate(newValue); - XMLString::trim(newString); if (!XMLString::equals(oldValue,newValue)) { releaseThisandParentDOM(); + XMLCh* newString = XMLString::replicate(newValue); XMLString::release(&oldValue); return newString; } - XMLString::release(&newString); - return oldValue; + return oldValue; } QName* AbstractXMLObject::prepareForAssignment(QName* oldValue, const QName* newValue) diff --git a/xmltooling/ElementProxy.h b/xmltooling/ElementProxy.h index b62d7ab..a10d873 100644 --- a/xmltooling/ElementProxy.h +++ b/xmltooling/ElementProxy.h @@ -15,15 +15,14 @@ */ /** - * @file ElementProxy.h + * @file xmltooling/ElementProxy.h * * An XMLObject with an open content model */ -#if !defined(__xmltooling_eleproxy_h__) +#ifndef __xmltooling_eleproxy_h__ #define __xmltooling_eleproxy_h__ -#include #include #include @@ -32,9 +31,9 @@ using namespace xercesc; namespace xmltooling { /** - * An XMLObject with an open content model. + * An XMLObject that exposes its children via mutable list. */ - class XMLTOOL_API ElementProxy : public virtual SimpleElement + class XMLTOOL_API ElementProxy : public virtual XMLObject { public: ElementProxy() {} diff --git a/xmltooling/Makefile.am b/xmltooling/Makefile.am index 8099251..94062fe 100644 --- a/xmltooling/Makefile.am +++ b/xmltooling/Makefile.am @@ -22,7 +22,6 @@ valincludedir = $(includedir)/xmltooling/validation libxmltoolinginclude_HEADERS = \ AbstractAttributeExtensibleXMLObject.h \ - AbstractChildlessElement.h \ AbstractComplexElement.h \ AbstractDOMCachingXMLObject.h \ AbstractElementProxy.h \ @@ -37,7 +36,6 @@ libxmltoolinginclude_HEADERS = \ Namespace.h \ PluginManager.h \ QName.h \ - SimpleElement.h \ unicode.h \ version.h \ XMLObject.h \ @@ -121,9 +119,9 @@ endif libxmltooling_la_SOURCES = \ AbstractAttributeExtensibleXMLObject.cpp \ - AbstractChildlessElement.cpp \ AbstractComplexElement.cpp \ AbstractDOMCachingXMLObject.cpp \ + AbstractSimpleElement.cpp \ AbstractXMLObject.cpp \ exceptions.cpp \ Namespace.cpp \ diff --git a/xmltooling/SimpleElement.h b/xmltooling/SimpleElement.h deleted file mode 100644 index 6386f4a..0000000 --- a/xmltooling/SimpleElement.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2001-2006 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file SimpleElement.h - * - * An XMLObject with a simple content model. - */ - -#ifndef __xmltooling_simpleel_h__ -#define __xmltooling_simpleel_h__ - -#include -#include - -using namespace xercesc; - -namespace xmltooling { - - /** - * An XMLObject with a simple content model. - */ - class XMLTOOL_API SimpleElement : public virtual XMLObject - { - public: - SimpleElement() {} - virtual ~SimpleElement() {} - - /** - * Gets the text content of the object - * - * @return the text content, or NULL - */ - virtual const XMLCh* getTextContent() const=0; - - /** - * Sets (or clears) the text content of the object - * - * @param value value to set, or NULL to clear - */ - virtual void setTextContent(const XMLCh* value)=0; - }; - -}; - -#endif /* __xmltooling_simpleel_h__ */ diff --git a/xmltooling/XMLObject.h b/xmltooling/XMLObject.h index cc8e54b..1fb26d6 100644 --- a/xmltooling/XMLObject.h +++ b/xmltooling/XMLObject.h @@ -171,6 +171,24 @@ namespace xmltooling { virtual void removeChild(XMLObject* child)=0; /** + * Returns the text content at the specified position relative to + * any child elements. A zero represents leading text, 1 comes after + * the first child, and so forth. + * + * @param position the relative child element position of the text + * @return the designated text value + */ + virtual const XMLCh* getTextContent(unsigned int position=0) const=0; + + /** + * Sets (or clears) text content relative to a child element's position. + * + * @param value value to set, or NULL to clear + * @param position position relative to child element + */ + virtual void setTextContent(const XMLCh* value, unsigned int position=0)=0; + + /** * Gets the DOM representation of this XMLObject, if one exists. * * @return the DOM representation of this XMLObject diff --git a/xmltooling/XMLToolingConfig.cpp b/xmltooling/XMLToolingConfig.cpp index e9bfc5e..c2a0749 100644 --- a/xmltooling/XMLToolingConfig.cpp +++ b/xmltooling/XMLToolingConfig.cpp @@ -33,7 +33,7 @@ #include "util/ReplayCache.h" #include "util/StorageService.h" #include "util/XMLConstants.h" -#include "validation/Validator.h" +#include "validation/ValidatorSuite.h" #ifdef HAVE_DLFCN_H # include diff --git a/xmltooling/base.h b/xmltooling/base.h index 228640d..106816f 100644 --- a/xmltooling/base.h +++ b/xmltooling/base.h @@ -961,11 +961,11 @@ } /** - * Declares aliased get/set methods for named XML element content. + * Declares aliased get/set methods for named XML element simple content. * * @param proper the proper name to label the element's content */ -#define DECL_XMLOBJECT_CONTENT(proper) \ +#define DECL_SIMPLE_CONTENT(proper) \ XMLTOOLING_DOXYGEN(Returns proper.) \ const XMLCh* get##proper() const { \ return getTextContent(); \ @@ -998,21 +998,6 @@ } /** - * Implements marshalling/unmarshalling for element content. - */ -#define IMPL_XMLOBJECT_CONTENT \ - protected: \ - void marshallElementContent(DOMElement* domElement) const { \ - if(getTextContent()) { \ - domElement->appendChild(domElement->getOwnerDocument()->createTextNode(getTextContent())); \ - } \ - } \ - void processElementContent(const XMLCh* elementContent) { \ - setTextContent(elementContent); \ - } - - -/** * Implements cloning methods for an XMLObject specialization implementation class. * * @param cname the name of the XMLObject specialization @@ -1041,8 +1026,8 @@ * @param desc documentation for class */ #define DECL_XMLOBJECT_SIMPLE(linkage,cname,proper,desc) \ - BEGIN_XMLOBJECT(linkage,cname,xmltooling::SimpleElement,desc); \ - DECL_XMLOBJECT_CONTENT(proper); \ + BEGIN_XMLOBJECT(linkage,cname,xmltooling::XMLObject,desc); \ + DECL_SIMPLE_CONTENT(proper); \ END_XMLOBJECT /** @@ -1056,7 +1041,6 @@ class linkage cname##Impl \ : public virtual cname, \ public xmltooling::AbstractSimpleElement, \ - public xmltooling::AbstractChildlessElement, \ public xmltooling::AbstractDOMCachingXMLObject, \ public xmltooling::AbstractXMLObjectMarshaller, \ public xmltooling::AbstractXMLObjectUnmarshaller \ @@ -1071,7 +1055,6 @@ xmltooling::AbstractSimpleElement(src), \ xmltooling::AbstractDOMCachingXMLObject(src) {} \ IMPL_XMLOBJECT_CLONE(cname) \ - IMPL_XMLOBJECT_CONTENT \ } /** diff --git a/xmltooling/encryption/Encryption.h b/xmltooling/encryption/Encryption.h index b6d5fc6..2bb3d58 100644 --- a/xmltooling/encryption/Encryption.h +++ b/xmltooling/encryption/Encryption.h @@ -15,7 +15,7 @@ */ /** - * @file Encryption.h + * @file xmltooling/encryption/Encryption.h * * XMLObjects representing XML Encryption content */ @@ -39,7 +39,7 @@ namespace xmlencryption { DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,CipherValue,Value,XML Encryption CipherValue element); DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,OAEPparams,Name,XML Encryption OAEPparams element); - BEGIN_XMLOBJECT(XMLTOOL_API,KeySize,xmltooling::SimpleElement,XML Encryption KeySize element); + BEGIN_XMLOBJECT(XMLTOOL_API,KeySize,xmltooling::XMLObject,XML Encryption KeySize element); DECL_INTEGER_CONTENT(Size); END_XMLOBJECT; diff --git a/xmltooling/encryption/impl/EncryptionImpl.cpp b/xmltooling/encryption/impl/EncryptionImpl.cpp index cc9a9ab..1b29a62 100644 --- a/xmltooling/encryption/impl/EncryptionImpl.cpp +++ b/xmltooling/encryption/impl/EncryptionImpl.cpp @@ -22,7 +22,7 @@ #include "internal.h" #include "AbstractAttributeExtensibleXMLObject.h" -#include "AbstractChildlessElement.h" +#include "AbstractSimpleElement.h" #include "AbstractElementProxy.h" #include "exceptions.h" #include "encryption/Encryption.h" @@ -74,7 +74,8 @@ namespace xmlencryption { init(); } - EncryptionMethodImpl(const EncryptionMethodImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + EncryptionMethodImpl(const EncryptionMethodImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setAlgorithm(src.getAlgorithm()); if (src.getKeySize()) @@ -133,7 +134,8 @@ namespace xmlencryption { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - TransformsImpl(const TransformsImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + TransformsImpl(const TransformsImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { VectorOf(xmlsignature::Transform) v=getTransforms(); for (vector::const_iterator i=src.m_Transforms.begin(); i!=src.m_Transforms.end(); i++) { if (*i) { @@ -174,7 +176,8 @@ namespace xmlencryption { init(); } - CipherReferenceImpl(const CipherReferenceImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + CipherReferenceImpl(const CipherReferenceImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setURI(src.getURI()); if (src.getTransforms()) @@ -224,7 +227,8 @@ namespace xmlencryption { init(); } - CipherDataImpl(const CipherDataImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + CipherDataImpl(const CipherDataImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getCipherValue()) setCipherValue(src.getCipherValue()->cloneCipherValue()); @@ -334,7 +338,8 @@ namespace xmlencryption { init(); } - EncryptionPropertiesImpl(const EncryptionPropertiesImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + EncryptionPropertiesImpl(const EncryptionPropertiesImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setId(src.getId()); VectorOf(EncryptionProperty) v=getEncryptionPropertys(); @@ -464,7 +469,8 @@ namespace xmlencryption { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - ReferenceListImpl(const ReferenceListImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + ReferenceListImpl(const ReferenceListImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { if (*i) { DataReference* data=dynamic_cast(*i); @@ -536,7 +542,8 @@ namespace xmlencryption { init(); } - EncryptedTypeImpl(const EncryptedTypeImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + EncryptedTypeImpl(const EncryptedTypeImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setId(src.getId()); setType(src.getType()); diff --git a/xmltooling/encryption/impl/EncryptionSchemaValidators.cpp b/xmltooling/encryption/impl/EncryptionSchemaValidators.cpp index 0ee9467..1efc93b 100644 --- a/xmltooling/encryption/impl/EncryptionSchemaValidators.cpp +++ b/xmltooling/encryption/impl/EncryptionSchemaValidators.cpp @@ -23,6 +23,7 @@ #include "internal.h" #include "exceptions.h" #include "encryption/Encryption.h" +#include "validation/ValidatorSuite.h" using namespace xmlencryption; using namespace xmltooling; diff --git a/xmltooling/impl/AnyElement.cpp b/xmltooling/impl/AnyElement.cpp index a19060d..bdb3ccc 100644 --- a/xmltooling/impl/AnyElement.cpp +++ b/xmltooling/impl/AnyElement.cpp @@ -55,12 +55,6 @@ void AnyElementImpl::marshallAttributes(DOMElement* domElement) const { marshallExtensionAttributes(domElement); } -void AnyElementImpl::marshallElementContent(DOMElement* domElement) const { - if(getTextContent()) { - domElement->appendChild(domElement->getOwnerDocument()->createTextNode(getTextContent())); - } -} - void AnyElementImpl::processChildElement(XMLObject* childXMLObject, const DOMElement* root) { getXMLObjects().push_back(childXMLObject); } @@ -69,10 +63,6 @@ void AnyElementImpl::processAttribute(const DOMAttr* attribute) { unmarshallExtensionAttribute(attribute); } -void AnyElementImpl::processElementContent(const XMLCh* elementContent) { - setTextContent(elementContent); -} - XMLObject* AnyElementBuilder::buildObject( const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType ) const { diff --git a/xmltooling/impl/AnyElement.h b/xmltooling/impl/AnyElement.h index 0418beb..4e668c8 100644 --- a/xmltooling/impl/AnyElement.h +++ b/xmltooling/impl/AnyElement.h @@ -15,7 +15,7 @@ */ /** - * @file AnyElement.h + * @file xmltooling/impl/AnyElement.h * * Advanced anyType implementation suitable for deep processing of unknown content. */ @@ -58,10 +58,8 @@ namespace xmltooling { AnyElementImpl(const AnyElementImpl& src); void marshallAttributes(DOMElement* domElement) const; - void marshallElementContent(DOMElement* domElement) const; void processChildElement(XMLObject* childXMLObject, const DOMElement* root); void processAttribute(const DOMAttr* attribute); - void processElementContent(const XMLCh* elementContent); }; /** diff --git a/xmltooling/impl/UnknownElement.h b/xmltooling/impl/UnknownElement.h index ded9183..ce23b31 100644 --- a/xmltooling/impl/UnknownElement.h +++ b/xmltooling/impl/UnknownElement.h @@ -15,7 +15,7 @@ */ /** - * @file UnknownElement.h + * @file xmltooling/impl/UnknownElement.h * * Basic implementation suitable for use as default for unrecognized content */ @@ -23,7 +23,7 @@ #ifndef __xmltooling_unkelement_h__ #define __xmltooling_unkelement_h__ -#include +#include #include #include #include @@ -39,7 +39,7 @@ namespace xmltooling { /// @cond off - class XMLTOOL_DLLLOCAL UnknownElementImpl : public AbstractChildlessElement, public AbstractDOMCachingXMLObject + class XMLTOOL_DLLLOCAL UnknownElementImpl : public AbstractSimpleElement, public AbstractDOMCachingXMLObject { public: UnknownElementImpl(const XMLCh* namespaceURI=NULL, const XMLCh* elementLocalName=NULL, const XMLCh* namespacePrefix=NULL) @@ -49,6 +49,14 @@ namespace xmltooling { XMLObject* clone() const; + const XMLCh* getTextContent(unsigned int position=0) const { + throw XMLObjectException("Direct access to content is not permitted."); + } + + void setTextContent(const XMLCh*, unsigned int position=0) { + throw XMLObjectException("Direct access to content is not permitted."); + } + DOMElement* marshall( DOMDocument* document=NULL #ifndef XMLTOOLING_NO_XMLSEC diff --git a/xmltooling/io/AbstractXMLObjectMarshaller.cpp b/xmltooling/io/AbstractXMLObjectMarshaller.cpp index e6a10f4..a33016c 100644 --- a/xmltooling/io/AbstractXMLObjectMarshaller.cpp +++ b/xmltooling/io/AbstractXMLObjectMarshaller.cpp @@ -181,8 +181,7 @@ void AbstractXMLObjectMarshaller::marshallInto( marshallElementType(targetElement); marshallNamespaces(targetElement); marshallAttributes(targetElement); - marshallChildElements(targetElement); - marshallElementContent(targetElement); + marshallContent(targetElement); #ifndef XMLTOOLING_NO_XMLSEC if (sigs) { @@ -290,17 +289,21 @@ void AbstractXMLObjectMarshaller::marshallNamespaces(DOMElement* domElement) con for_each(namespaces.begin(),namespaces.end(),bind1st(_addns(),domElement)); } -class _marshallit : public binary_function { -public: - void operator()(const XMLObject* xo, DOMElement* e) const { - if (xo) xo->marshall(e); - } -}; - -void AbstractXMLObjectMarshaller::marshallChildElements(DOMElement* domElement) const +void AbstractXMLObjectMarshaller::marshallContent(DOMElement* domElement) const { - XT_log.debug("marshalling child elements for XMLObject"); - + XT_log.debug("marshalling text and child elements for XMLObject"); + + const XMLCh* val; + unsigned int pos=0; const list& children=getOrderedChildren(); - for_each(children.begin(),children.end(),bind2nd(_marshallit(),domElement)); + for (list::const_iterator i=children.begin(); i!=children.end(); ++i, ++pos) { + val = getTextContent(pos); + if (val && *val) + domElement->appendChild(domElement->getOwnerDocument()->createTextNode(val)); + if (*i) + (*i)->marshall(domElement); + } + val = getTextContent(pos); + if (val && *val) + domElement->appendChild(domElement->getOwnerDocument()->createTextNode(val)); } diff --git a/xmltooling/io/AbstractXMLObjectMarshaller.h b/xmltooling/io/AbstractXMLObjectMarshaller.h index 18d9056..cbab2fe 100644 --- a/xmltooling/io/AbstractXMLObjectMarshaller.h +++ b/xmltooling/io/AbstractXMLObjectMarshaller.h @@ -107,13 +107,13 @@ namespace xmltooling { void marshallNamespaces(DOMElement* domElement) const; /** - * Marshalls the child elements of the XMLObject. + * Marshalls the text content and/or child elements of the XMLObject. * * @param domElement the DOM element that will recieved the marshalled children * * @throws MarshallingException thrown if there is a problem marshalling a child element */ - void marshallChildElements(DOMElement* domElement) const; + void marshallContent(DOMElement* domElement) const; /** * Marshalls the attributes from the XMLObject into the given DOM element. @@ -123,13 +123,6 @@ namespace xmltooling { * @throws MarshallingException thrown if there is a problem marshalling an attribute */ virtual void marshallAttributes(DOMElement* domElement) const {} - - /** - * Marshalls data from the XMLObject into content of the DOM Element. - * - * @param domElement the DOM element recieving the content - */ - virtual void marshallElementContent(DOMElement* domElement) const {} }; }; diff --git a/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp b/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp index 6532d53..0ba988a 100644 --- a/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp +++ b/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp @@ -60,7 +60,7 @@ XMLObject* AbstractXMLObjectUnmarshaller::unmarshall(DOMElement* element, bool b unmarshallAttributes(element); } - unmarshallChildElements(element); + unmarshallContent(element); setDOM(element,bindDocument); return this; @@ -134,26 +134,25 @@ void AbstractXMLObjectUnmarshaller::unmarshallAttributes(const DOMElement* domEl } } -void AbstractXMLObjectUnmarshaller::unmarshallChildElements(const DOMElement* domElement) +void AbstractXMLObjectUnmarshaller::unmarshallContent(const DOMElement* domElement) { #ifdef _DEBUG - xmltooling::NDC ndc("unmarshallChildElements"); + xmltooling::NDC ndc("unmarshallContent"); #endif if (XT_log.isDebugEnabled()) { auto_ptr_char dname(domElement->getNodeName()); - XT_log.debug("unmarshalling child elements of DOM element (%s)", dname.get()); + XT_log.debug("unmarshalling child nodes of DOM element (%s)", dname.get()); } - DOMNodeList* childNodes = domElement->getChildNodes(); - DOMNode* childNode; - if (!childNodes || childNodes->getLength()==0) { + DOMNode* childNode = domElement->getFirstChild(); + if (!childNode) { XT_log.debug("element had no children"); return; } - for (XMLSize_t i = 0; i < childNodes->getLength(); i++) { - childNode = childNodes->item(i); + unsigned int position = 0; + while (childNode) { if (childNode->getNodeType() == DOMNode::ELEMENT_NODE) { const XMLObjectBuilder* builder = XMLObjectBuilder::getBuilder(static_cast(childNode)); if (!builder) { @@ -171,11 +170,16 @@ void AbstractXMLObjectUnmarshaller::unmarshallChildElements(const DOMElement* do auto_ptr childObject(builder->buildFromElement(static_cast(childNode))); processChildElement(childObject.get(), static_cast(childNode)); childObject.release(); + + // Advance the text node position marker. + ++position; } - else if (childNode->getNodeType() == DOMNode::TEXT_NODE && !XMLString::isAllWhiteSpace(childNode->getNodeValue())) { - XT_log.debug("processing element content"); - processElementContent(childNode->getNodeValue()); + else if (childNode->getNodeType() == DOMNode::TEXT_NODE) { + XT_log.debug("processing text content at position (%d)", position); + setTextContent(childNode->getNodeValue(), position); } + + childNode = childNode->getNextSibling(); } } @@ -189,8 +193,3 @@ void AbstractXMLObjectUnmarshaller::processAttribute(const DOMAttr* attribute) auto_ptr q(XMLHelper::getNodeQName(attribute)); throw UnmarshallingException("Invalid attribute: $1",params(1,q->toString().c_str())); } - -void AbstractXMLObjectUnmarshaller::processElementContent(const XMLCh* elementContent) -{ - throw UnmarshallingException("Invalid text content in element."); -} diff --git a/xmltooling/io/AbstractXMLObjectUnmarshaller.h b/xmltooling/io/AbstractXMLObjectUnmarshaller.h index 9ed78bd..80d0909 100644 --- a/xmltooling/io/AbstractXMLObjectUnmarshaller.h +++ b/xmltooling/io/AbstractXMLObjectUnmarshaller.h @@ -58,14 +58,14 @@ namespace xmltooling { virtual void unmarshallAttributes(const DOMElement* domElement); /** - * Unmarshalls a given Element's children. The resulting XMLObject child is passed to - * processChildElement() for further processing. + * Unmarshalls a given Element's child nodes. The resulting XMLObject children and content + * are passed to processChildElement() or processText() for further processing. * * @param domElement the DOM Element whose children will be unmarshalled * * @throws UnmarshallingException thrown if an error occurs unmarshalling the child elements */ - virtual void unmarshallChildElements(const DOMElement* domElement); + virtual void unmarshallContent(const DOMElement* domElement); /** * Called after a child element has been unmarshalled so that it can be added to the parent XMLObject. @@ -85,13 +85,6 @@ namespace xmltooling { * @throws UnmarshallingException thrown if there is a problem adding the attribute to the XMLObject */ virtual void processAttribute(const DOMAttr* attribute); - - /** - * Called if the element being unmarshalled contained textual content so that it can be added to the XMLObject. - * - * @param elementContent the Element's text content - */ - virtual void processElementContent(const XMLCh* elementContent); }; }; diff --git a/xmltooling/signature/KeyInfo.h b/xmltooling/signature/KeyInfo.h index e5ffe32..eee9920 100644 --- a/xmltooling/signature/KeyInfo.h +++ b/xmltooling/signature/KeyInfo.h @@ -15,7 +15,7 @@ */ /** - * @file KeyInfo.h + * @file xmltooling/signature/KeyInfo.h * * XMLObjects representing XML Digital Signature, version 20020212, KeyInfo element * and related content. @@ -25,10 +25,8 @@ #define __xmltooling_keyinfo_h__ #include -#include #include #include -#include #define DECL_XMLSIGOBJECTBUILDER(cname) \ DECL_XMLOBJECTBUILDER(XMLTOOL_API,cname,xmltooling::XMLConstants::XMLSIG_NS,xmltooling::XMLConstants::XMLSIG_PREFIX) @@ -76,7 +74,7 @@ namespace xmlsignature { static const XMLCh TYPE_NAME[]; END_XMLOBJECT; - BEGIN_XMLOBJECT(XMLTOOL_API,KeyValue,xmltooling::SimpleElement,XML Digital Signature version 20020212 KeyValue element); + BEGIN_XMLOBJECT(XMLTOOL_API,KeyValue,xmltooling::XMLObject,XML Digital Signature version 20020212 KeyValue element); DECL_TYPED_CHILD(DSAKeyValue); DECL_TYPED_CHILD(RSAKeyValue); DECL_XMLOBJECT_CHILD(OtherKeyValue); diff --git a/xmltooling/signature/impl/InlineKeyResolver.cpp b/xmltooling/signature/impl/InlineKeyResolver.cpp index a31908e..9ad79df 100644 --- a/xmltooling/signature/impl/InlineKeyResolver.cpp +++ b/xmltooling/signature/impl/InlineKeyResolver.cpp @@ -26,6 +26,7 @@ #include "util/NDC.h" #include "util/Threads.h" #include "util/XMLConstants.h" +#include "validation/ValidatorSuite.h" #include #include diff --git a/xmltooling/signature/impl/KeyInfoImpl.cpp b/xmltooling/signature/impl/KeyInfoImpl.cpp index 922d583..885af02 100644 --- a/xmltooling/signature/impl/KeyInfoImpl.cpp +++ b/xmltooling/signature/impl/KeyInfoImpl.cpp @@ -21,7 +21,7 @@ */ #include "internal.h" -#include "AbstractChildlessElement.h" +#include "AbstractSimpleElement.h" #include "AbstractComplexElement.h" #include "AbstractElementProxy.h" #include "AbstractSimpleElement.h" @@ -58,7 +58,8 @@ namespace xmlsignature { init(); } - DSAKeyValueImpl(const DSAKeyValueImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + DSAKeyValueImpl(const DSAKeyValueImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getP()) setP(src.getP()->cloneP()); @@ -142,7 +143,8 @@ namespace xmlsignature { init(); } - RSAKeyValueImpl(const RSAKeyValueImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + RSAKeyValueImpl(const RSAKeyValueImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getModulus()) setModulus(src.getModulus()->cloneModulus()); @@ -173,7 +175,6 @@ namespace xmlsignature { }; class XMLTOOL_DLLLOCAL KeyValueImpl : public virtual KeyValue, - public AbstractSimpleElement, public AbstractComplexElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, @@ -188,7 +189,7 @@ namespace xmlsignature { } KeyValueImpl(const KeyValueImpl& src) - : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) { + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getDSAKeyValue()) setDSAKeyValue(src.getDSAKeyValue()->cloneDSAKeyValue()); @@ -216,7 +217,6 @@ namespace xmlsignature { IMPL_TYPED_CHILD(DSAKeyValue); IMPL_TYPED_CHILD(RSAKeyValue); IMPL_XMLOBJECT_CHILD(OtherKeyValue); - IMPL_XMLOBJECT_CONTENT; protected: void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { @@ -267,7 +267,6 @@ namespace xmlsignature { IMPL_XMLOBJECT_CLONE(Transform); IMPL_STRING_ATTRIB(Algorithm); IMPL_TYPED_CHILDREN(XPath,m_children.end()); - IMPL_XMLOBJECT_CONTENT; protected: void marshallAttributes(DOMElement* domElement) const { @@ -306,7 +305,8 @@ namespace xmlsignature { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - TransformsImpl(const TransformsImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + TransformsImpl(const TransformsImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { VectorOf(Transform) v=getTransforms(); for (vector::const_iterator i=src.m_Transforms.begin(); i!=src.m_Transforms.end(); i++) { if (*i) { @@ -342,7 +342,8 @@ namespace xmlsignature { init(); } - RetrievalMethodImpl(const RetrievalMethodImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + RetrievalMethodImpl(const RetrievalMethodImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); setURI(getURI()); setType(getType()); @@ -394,7 +395,8 @@ namespace xmlsignature { init(); } - X509IssuerSerialImpl(const X509IssuerSerialImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + X509IssuerSerialImpl(const X509IssuerSerialImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getX509IssuerName()) setX509IssuerName(src.getX509IssuerName()->cloneX509IssuerName()); @@ -437,7 +439,8 @@ namespace xmlsignature { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - X509DataImpl(const X509DataImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + X509DataImpl(const X509DataImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { if (*i) { X509Certificate* xcert=dynamic_cast(*i); @@ -515,7 +518,8 @@ namespace xmlsignature { : AbstractXMLObject(nsURI, localName, prefix, schemaType) { } - SPKIDataImpl(const SPKIDataImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + SPKIDataImpl(const SPKIDataImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { VectorOfPairs(SPKISexp,XMLObject) v=getSPKISexps(); for (vector< pair >::const_iterator i=src.m_SPKISexps.begin(); i!=src.m_SPKISexps.end(); i++) { if (i->first) { @@ -579,7 +583,8 @@ namespace xmlsignature { init(); } - PGPDataImpl(const PGPDataImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + PGPDataImpl(const PGPDataImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getPGPKeyID()) setPGPKeyID(src.getPGPKeyID()->clonePGPKeyID()); @@ -626,7 +631,6 @@ namespace xmlsignature { class XMLTOOL_DLLLOCAL KeyInfoImpl : public virtual KeyInfo, public AbstractComplexElement, - public AbstractSimpleElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller @@ -641,7 +645,7 @@ namespace xmlsignature { } KeyInfoImpl(const KeyInfoImpl& src) - : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src), + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src), m_Id(XMLString::replicate(src.m_Id)) { for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { @@ -703,7 +707,6 @@ namespace xmlsignature { IMPL_TYPED_CHILDREN(SPKIData,m_children.end()); IMPL_TYPED_CHILDREN(PGPData,m_children.end()); IMPL_XMLOBJECT_CHILDREN(Other,m_children.end()); - IMPL_XMLOBJECT_CONTENT; protected: void marshallAttributes(DOMElement* domElement) const { diff --git a/xmltooling/signature/impl/KeyInfoSchemaValidators.cpp b/xmltooling/signature/impl/KeyInfoSchemaValidators.cpp index 7a22689..44acffd 100644 --- a/xmltooling/signature/impl/KeyInfoSchemaValidators.cpp +++ b/xmltooling/signature/impl/KeyInfoSchemaValidators.cpp @@ -23,6 +23,7 @@ #include "internal.h" #include "exceptions.h" #include "signature/KeyInfo.h" +#include "validation/ValidatorSuite.h" using namespace xmlsignature; using namespace xmltooling; diff --git a/xmltooling/soap/SOAP.h b/xmltooling/soap/SOAP.h index 1c953b1..9f74f4e 100644 --- a/xmltooling/soap/SOAP.h +++ b/xmltooling/soap/SOAP.h @@ -15,7 +15,7 @@ */ /** - * @file SOAP.h + * @file xmltooling/soap/SOAP.h * * XMLObjects representing SOAP content */ @@ -25,10 +25,8 @@ #include #include -#include #include #include -#include #include #define DECL_SOAP11OBJECTBUILDER(cname) \ diff --git a/xmltooling/soap/impl/SOAPImpl.cpp b/xmltooling/soap/impl/SOAPImpl.cpp index 4ac8753..eefa5a6 100644 --- a/xmltooling/soap/impl/SOAPImpl.cpp +++ b/xmltooling/soap/impl/SOAPImpl.cpp @@ -22,7 +22,7 @@ #include "internal.h" #include "AbstractAttributeExtensibleXMLObject.h" -#include "AbstractChildlessElement.h" +#include "AbstractSimpleElement.h" #include "AbstractElementProxy.h" #include "exceptions.h" #include "io/AbstractXMLObjectMarshaller.h" @@ -47,8 +47,7 @@ namespace { DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,Faultactor); class XMLTOOL_DLLLOCAL FaultcodeImpl : public virtual Faultcode, - protected AbstractSimpleElement, - public AbstractChildlessElement, + public AbstractSimpleElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller @@ -83,7 +82,6 @@ namespace { } IMPL_XMLOBJECT_CLONE(Faultcode); - IMPL_XMLOBJECT_CONTENT; }; class XMLTOOL_DLLLOCAL DetailImpl : public virtual Detail, @@ -164,7 +162,8 @@ namespace { init(); } - FaultImpl(const FaultImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + FaultImpl(const FaultImpl& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getFaultcode()) setFaultcode(src.getFaultcode()->cloneFaultcode()); @@ -349,7 +348,8 @@ namespace { } EnvelopeImpl(const EnvelopeImpl& src) - : AbstractXMLObject(src), AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) { + : AbstractXMLObject(src), AbstractComplexElement(src), + AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) { init(); if (src.getHeader()) setHeader(src.getHeader()->cloneHeader()); diff --git a/xmltooling/soap/impl/SOAPSchemaValidators.cpp b/xmltooling/soap/impl/SOAPSchemaValidators.cpp index 88bd5ed..0708fc5 100644 --- a/xmltooling/soap/impl/SOAPSchemaValidators.cpp +++ b/xmltooling/soap/impl/SOAPSchemaValidators.cpp @@ -23,6 +23,7 @@ #include "internal.h" #include "exceptions.h" #include "soap/SOAP.h" +#include "validation/ValidatorSuite.h" using namespace soap11; using namespace xmltooling; diff --git a/xmltooling/util/XMLHelper.h b/xmltooling/util/XMLHelper.h index 777ce13..df33c63 100644 --- a/xmltooling/util/XMLHelper.h +++ b/xmltooling/util/XMLHelper.h @@ -96,10 +96,10 @@ namespace xmltooling { static QName* getNodeQName(const DOMNode* domNode); /** - * Constructs a QName from an attributes value. + * Constructs a QName from an attribute's value. * * @param attribute the attribute with a QName value - * @return a QName from an attributes value, or null if the given attribute is null + * @return a QName from an attribute's value, or null if the given attribute is null */ static QName* getAttributeValueAsQName(const DOMAttr* attribute); diff --git a/xmltooling/xmltooling.vcproj b/xmltooling/xmltooling.vcproj index 3c99092..cd675b6 100644 --- a/xmltooling/xmltooling.vcproj +++ b/xmltooling/xmltooling.vcproj @@ -186,15 +186,15 @@ > - - @@ -464,6 +460,10 @@ > + + diff --git a/xmltoolingtest/ComplexXMLObjectTest.h b/xmltoolingtest/ComplexXMLObjectTest.h index 45af7a9..908e4d4 100644 --- a/xmltoolingtest/ComplexXMLObjectTest.h +++ b/xmltoolingtest/ComplexXMLObjectTest.h @@ -36,12 +36,13 @@ public: ifstream fs(path.c_str()); DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(fs); TS_ASSERT(doc!=NULL); + XercesJanitor janitor(doc); const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement()); TS_ASSERT(b!=NULL); auto_ptr wcObject( - dynamic_cast(b->buildFromDocument(doc)) + dynamic_cast(b->buildFromDocument(doc, false)) ); TS_ASSERT(wcObject.get()!=NULL); @@ -59,6 +60,10 @@ public: ListOf(XMLObject)::const_iterator it=wc2->getXMLObjects().begin(); ++it; ++it; TSM_ASSERT_EQUALS("Element QName unexpected", it->getElementQName(),q); + + DOMElement* rebuilt = wcObject->marshall(XMLToolingConfig::getConfig().getParser().newDocument()); + wcObject->setDocument(rebuilt->getOwnerDocument()); + TS_ASSERT(rebuilt->isEqualNode(doc->getDocumentElement())); } }; diff --git a/xmltoolingtest/KeyInfoTest.h b/xmltoolingtest/KeyInfoTest.h index 5086243..0379cae 100644 --- a/xmltoolingtest/KeyInfoTest.h +++ b/xmltoolingtest/KeyInfoTest.h @@ -18,6 +18,7 @@ #include #include +#include using namespace xmlsignature; diff --git a/xmltoolingtest/XMLObjectBaseTestCase.h b/xmltoolingtest/XMLObjectBaseTestCase.h index a90b1fc..85d42b1 100644 --- a/xmltoolingtest/XMLObjectBaseTestCase.h +++ b/xmltoolingtest/XMLObjectBaseTestCase.h @@ -51,8 +51,9 @@ class SimpleXMLObject public AbstractXMLObjectUnmarshaller { protected: - SimpleXMLObject(const SimpleXMLObject& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), - m_id(XMLString::replicate(src.m_id)), m_value(XMLString::replicate(src.m_value)) { + SimpleXMLObject(const SimpleXMLObject& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src), + m_id(XMLString::replicate(src.m_id)) { #ifndef XMLTOOLING_NO_XMLSEC m_children.push_back(NULL); m_signature=m_children.begin(); @@ -73,7 +74,7 @@ public: SimpleXMLObject( const XMLCh* nsURI=NULL, const XMLCh* localName=NULL, const XMLCh* prefix=NULL, const QName* schemaType=NULL - ) : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_id(NULL), m_value(NULL) { + ) : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_id(NULL) { #ifndef XMLTOOLING_NO_XMLSEC m_children.push_back(NULL); m_signature=m_children.begin(); @@ -82,7 +83,6 @@ public: virtual ~SimpleXMLObject() { XMLString::release(&m_id); - XMLString::release(&m_value); } SimpleXMLObject* clone() const { @@ -100,8 +100,8 @@ public: const XMLCh* getId() const { return m_id; } void setId(const XMLCh* id) { m_id=prepareForAssignment(m_id,id); } - const XMLCh* getValue() const { return m_value; } - void setValue(const XMLCh* value) { m_value=prepareForAssignment(m_value,value); } + const XMLCh* getValue() const { return getTextContent(); } + void setValue(const XMLCh* value) { setTextContent(value); } #ifndef XMLTOOLING_NO_XMLSEC Signature* getSignature() const { @@ -129,12 +129,6 @@ protected: } } - void marshallElementContent(DOMElement* domElement) const { - if(getValue()) { - domElement->setTextContent(getValue()); - } - } - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { SimpleXMLObject* simple=dynamic_cast(childXMLObject); if (simple) { @@ -160,13 +154,8 @@ protected: throw UnmarshallingException("Unknown attribute cannot be processed by parent object."); } - void processElementContent(const XMLCh* elementContent) { - setValue(elementContent); - } - private: XMLCh* m_id; - XMLCh* m_value; vector m_simples; #ifndef XMLTOOLING_NO_XMLSEC list::iterator m_signature; @@ -186,14 +175,14 @@ public: return new SimpleXMLObject(nsURI, localName, prefix, schemaType); } - static SimpleXMLObject* newSimpleXMLObject() { - const SimpleXMLObjectBuilder* b = dynamic_cast( - XMLObjectBuilder::getBuilder(QName(SimpleXMLObject::NAMESPACE,SimpleXMLObject::LOCAL_NAME)) - ); - if (b) - return b->buildObject(); - throw XMLObjectException("Unable to obtain typed builder for SimpleXMLObject."); - } + static SimpleXMLObject* newSimpleXMLObject() { + const SimpleXMLObjectBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(QName(SimpleXMLObject::NAMESPACE,SimpleXMLObject::LOCAL_NAME)) + ); + if (b) + return b->buildObject(); + throw XMLObjectException("Unable to obtain typed builder for SimpleXMLObject."); + } }; #if defined (_MSC_VER) -- 2.1.4