Track DOM text nodes to ensure fidelity.
authorcantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Thu, 12 Oct 2006 20:36:12 +0000 (20:36 +0000)
committercantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Thu, 12 Oct 2006 20:36:12 +0000 (20:36 +0000)
Promoted text node handling to XMLObject, simplified subclasses.

git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/trunk@181 de75baf8-a10c-0410-a50a-987c0e22f00f

35 files changed:
xmltooling/AbstractChildlessElement.h [deleted file]
xmltooling/AbstractComplexElement.cpp
xmltooling/AbstractComplexElement.h
xmltooling/AbstractElementProxy.h
xmltooling/AbstractSimpleElement.cpp [moved from xmltooling/AbstractChildlessElement.cpp with 74% similarity]
xmltooling/AbstractSimpleElement.h
xmltooling/AbstractXMLObject.cpp
xmltooling/ElementProxy.h
xmltooling/Makefile.am
xmltooling/SimpleElement.h [deleted file]
xmltooling/XMLObject.h
xmltooling/XMLToolingConfig.cpp
xmltooling/base.h
xmltooling/encryption/Encryption.h
xmltooling/encryption/impl/EncryptionImpl.cpp
xmltooling/encryption/impl/EncryptionSchemaValidators.cpp
xmltooling/impl/AnyElement.cpp
xmltooling/impl/AnyElement.h
xmltooling/impl/UnknownElement.h
xmltooling/io/AbstractXMLObjectMarshaller.cpp
xmltooling/io/AbstractXMLObjectMarshaller.h
xmltooling/io/AbstractXMLObjectUnmarshaller.cpp
xmltooling/io/AbstractXMLObjectUnmarshaller.h
xmltooling/signature/KeyInfo.h
xmltooling/signature/impl/InlineKeyResolver.cpp
xmltooling/signature/impl/KeyInfoImpl.cpp
xmltooling/signature/impl/KeyInfoSchemaValidators.cpp
xmltooling/soap/SOAP.h
xmltooling/soap/impl/SOAPImpl.cpp
xmltooling/soap/impl/SOAPSchemaValidators.cpp
xmltooling/util/XMLHelper.h
xmltooling/xmltooling.vcproj
xmltoolingtest/ComplexXMLObjectTest.h
xmltoolingtest/KeyInfoTest.h
xmltoolingtest/XMLObjectBaseTestCase.h

diff --git a/xmltooling/AbstractChildlessElement.h b/xmltooling/AbstractChildlessElement.h
deleted file mode 100644 (file)
index bb87812..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*\r
- *  Copyright 2001-2006 Internet2\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-/**\r
- * @file AbstractChildlessElement.h\r
- * \r
- * AbstractXMLObject mixin that blocks children\r
- */\r
-\r
-#ifndef __xmltooling_absnokids_h__\r
-#define __xmltooling_absnokids_h__\r
-\r
-#include <xmltooling/AbstractXMLObject.h>\r
-\r
-#if defined (_MSC_VER)\r
-    #pragma warning( push )\r
-    #pragma warning( disable : 4250 4251 )\r
-#endif\r
-\r
-namespace xmltooling {\r
-\r
-    /**\r
-     * AbstractXMLObject mixin that blocks children.\r
-     * Inherit from this class to implement a childless element.\r
-     */\r
-    class XMLTOOL_API AbstractChildlessElement : public virtual AbstractXMLObject\r
-    {\r
-    public:\r
-        virtual ~AbstractChildlessElement() {}\r
-        \r
-        bool hasChildren() const {\r
-            return false;\r
-        }\r
-\r
-        const std::list<XMLObject*>& getOrderedChildren() const {\r
-            return m_no_children;\r
-        }\r
-\r
-        void removeChild(XMLObject* child);\r
-\r
-    protected:\r
-        AbstractChildlessElement() {}\r
-        \r
-        /** Copy constructor. */\r
-        AbstractChildlessElement(const AbstractChildlessElement& src) {}\r
-\r
-    private:\r
-        static std::list<XMLObject*> m_no_children;\r
-    };\r
-    \r
-};\r
-\r
-#if defined (_MSC_VER)\r
-    #pragma warning( pop )\r
-#endif\r
-\r
-#endif /* __xmltooling_absnokids_h__ */\r
index c3aa5aa..5555971 100644 (file)
 #include <algorithm>
 
 using namespace xmltooling;
+using namespace std;
 
 AbstractComplexElement::~AbstractComplexElement() {
-    std::for_each(m_children.begin(), m_children.end(), cleanup<XMLObject>());
+    for_each(m_children.begin(), m_children.end(), cleanup<XMLObject>());
+    for (vector<XMLCh*>::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<XMLCh*>::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<XMLCh*>::size_type size = m_text.size();
+    while (position >= size) {
+        m_text.push_back(NULL);
+        ++size;
+    }
+    m_text[position]=prepareForAssignment(m_text[position],value);
 }
index 9f71657..ba8b862 100644 (file)
@@ -15,7 +15,7 @@
  */\r
 \r
 /**\r
- * @file AbstractComplexElement.h\r
+ * @file xmltooling/AbstractComplexElement.h\r
  * \r
  * AbstractXMLObject mixin that implements children\r
  */\r
@@ -34,8 +34,7 @@ namespace xmltooling {
 \r
     /**\r
      * AbstractXMLObject mixin that implements children.\r
-     * Inherit from this class to implement an element with child objects.\r
-     * No unprotected access to them is supplied here.\r
+     * Inherit from this class to implement an element with child objects and mixed content.\r
      */\r
     class XMLTOOL_API AbstractComplexElement : public virtual AbstractXMLObject\r
     {\r
@@ -52,17 +51,29 @@ namespace xmltooling {
 \r
         void removeChild(XMLObject* child);\r
 \r
+        const XMLCh* getTextContent(unsigned int position=0) const {\r
+            return (m_text.size() > position) ? m_text[position] : NULL; \r
+        }\r
+        \r
+        void setTextContent(const XMLCh* value, unsigned int position=0);\r
+\r
     protected:\r
         AbstractComplexElement() {}\r
         \r
         /** Copy constructor. */\r
-        AbstractComplexElement(const AbstractComplexElement& src) {}\r
+        AbstractComplexElement(const AbstractComplexElement& src);\r
 \r
         /**\r
          * Underlying list of child objects.\r
          * Manages the lifetime of the children.\r
          */\r
         std::list<XMLObject*> m_children;\r
+        \r
+        /**\r
+         * Interstitial text nodes.\r
+         * Needed to support mixed content, and preserve DOM whitespace across rebuilds.\r
+         */\r
+        std::vector<XMLCh*> m_text;\r
     };\r
     \r
 };\r
index b8bd05f..ed95e53 100644 (file)
@@ -15,7 +15,7 @@
  */\r
 \r
 /**\r
- * @file AbstractElementProxy.h\r
+ * @file xmltooling/AbstractElementProxy.h\r
  * \r
  * AbstractXMLObject mixin that implements an open content model \r
  */\r
@@ -24,7 +24,6 @@
 #define __xmltooling_abseleproxy_h__\r
 \r
 #include <xmltooling/AbstractComplexElement.h>\r
-#include <xmltooling/AbstractSimpleElement.h>\r
 #include <xmltooling/ElementProxy.h>\r
 \r
 #if defined (_MSC_VER)\r
 namespace xmltooling {\r
 \r
     /**\r
-     * AbstractXMLObject mixin that implements an open content model.\r
-     * Inherit from this class to merge both simple and complex content\r
+     * AbstractXMLObject mixin that layers ElementProxy on top of a complex element.\r
+     * Inherit from this class to implement complex content\r
      * and expose the underlying child collection in read/write mode.\r
      */\r
-    class XMLTOOL_API AbstractElementProxy\r
-        : public virtual ElementProxy, public AbstractSimpleElement, public AbstractComplexElement\r
+    class XMLTOOL_API AbstractElementProxy : public virtual ElementProxy, public AbstractComplexElement\r
     {\r
     public:\r
         virtual ~AbstractElementProxy() {}\r
@@ -57,8 +55,7 @@ namespace xmltooling {
         AbstractElementProxy() {}\r
         \r
         /** Copy constructor. */\r
-        AbstractElementProxy(const AbstractElementProxy& src)\r
-            : AbstractXMLObject(src), AbstractSimpleElement(src) {}\r
+        AbstractElementProxy(const AbstractElementProxy& src) : AbstractXMLObject(src), AbstractComplexElement(src) {}\r
     };\r
     \r
 };\r
similarity index 74%
rename from xmltooling/AbstractChildlessElement.cpp
rename to xmltooling/AbstractSimpleElement.cpp
index 1a37855..920aa3b 100644 (file)
  */\r
 \r
 /**\r
- * AbstractChildlessElement.cpp\r
+ * AbstractSimpleElement.cpp\r
  * \r
- * Extension of AbstractXMLObject that implements childlessnes\r
+ * Extension of AbstractXMLObject that implements simple element\r
  */\r
 \r
 #include "internal.h"\r
-#include "AbstractChildlessElement.h"\r
+#include "AbstractSimpleElement.h"\r
 \r
 using namespace xmltooling;\r
 using namespace std;\r
 \r
 // shared "empty" list of children for childless objects\r
 \r
-list<XMLObject*> AbstractChildlessElement::m_no_children;\r
+list<XMLObject*> AbstractSimpleElement::m_no_children;\r
 \r
-void AbstractChildlessElement::removeChild(XMLObject* child)\r
+void AbstractSimpleElement::removeChild(XMLObject* child)\r
 {\r
     throw XMLObjectException("Cannot remove child from a childless object.");\r
 }\r
index 853da26..86e0e80 100644 (file)
@@ -15,7 +15,7 @@
  */\r
 \r
 /**\r
- * @file AbstractSimpleElement.h\r
+ * @file xmltooling/AbstractSimpleElement.h\r
  * \r
  * AbstractXMLObject mixin that implements a simple string-based content model \r
  */\r
@@ -24,7 +24,6 @@
 #define __xmltooling_abssimpleel_h__\r
 \r
 #include <xmltooling/AbstractXMLObject.h>\r
-#include <xmltooling/SimpleElement.h>\r
 \r
 #if defined (_MSC_VER)\r
     #pragma warning( push )\r
@@ -37,18 +36,30 @@ namespace xmltooling {
      * AbstractXMLObject mixin that implements a simple string-based content model.\r
      * Inherit from this class to support string-based element content.\r
      */\r
-    class XMLTOOL_API AbstractSimpleElement : public virtual SimpleElement, public virtual AbstractXMLObject\r
+    class XMLTOOL_API AbstractSimpleElement : public virtual AbstractXMLObject\r
     {\r
     public:\r
         virtual ~AbstractSimpleElement() {\r
             XMLString::release(&m_value);\r
         }\r
         \r
-        virtual const XMLCh* getTextContent() const {\r
-            return m_value;\r
+        bool hasChildren() const {\r
+            return false;\r
+        }\r
+\r
+        const std::list<XMLObject*>& getOrderedChildren() const {\r
+            return m_no_children;\r
+        }\r
+\r
+        void removeChild(XMLObject* child);\r
+\r
+        virtual const XMLCh* getTextContent(unsigned int position=0) const {\r
+            return (position==0) ? m_value : NULL;\r
         }\r
         \r
-        virtual void setTextContent(const XMLCh* value) {\r
+        virtual void setTextContent(const XMLCh* value, unsigned int position=0) {\r
+            if (position > 0)\r
+                throw XMLObjectException("Cannot set text content in simple element at position > 0.");\r
             m_value=prepareForAssignment(m_value,value);\r
         }\r
         \r
@@ -61,6 +72,8 @@ namespace xmltooling {
 \r
     private:\r
         XMLCh* m_value;\r
+\r
+        static std::list<XMLObject*> m_no_children;\r
     };\r
     \r
 };\r
index 13a7e5c..e019f4e 100644 (file)
@@ -50,15 +50,13 @@ AbstractXMLObject::AbstractXMLObject(const AbstractXMLObject& src)
 \r
 XMLCh* AbstractXMLObject::prepareForAssignment(XMLCh* oldValue, const XMLCh* newValue)\r
 {\r
-    XMLCh* newString = XMLString::replicate(newValue);\r
-    XMLString::trim(newString);\r
     if (!XMLString::equals(oldValue,newValue)) {\r
         releaseThisandParentDOM();\r
+        XMLCh* newString = XMLString::replicate(newValue);\r
         XMLString::release(&oldValue);\r
         return newString;\r
     }\r
-    XMLString::release(&newString);\r
-    return oldValue;            \r
+    return oldValue;\r
 }\r
 \r
 QName* AbstractXMLObject::prepareForAssignment(QName* oldValue, const QName* newValue)\r
index b62d7ab..a10d873 100644 (file)
  */\r
 \r
 /**\r
- * @file ElementProxy.h\r
+ * @file xmltooling/ElementProxy.h\r
  * \r
  * An XMLObject with an open content model \r
  */\r
 \r
-#if !defined(__xmltooling_eleproxy_h__)\r
+#ifndef __xmltooling_eleproxy_h__\r
 #define __xmltooling_eleproxy_h__\r
 \r
-#include <xmltooling/SimpleElement.h>\r
 #include <xmltooling/XMLObject.h>\r
 #include <xmltooling/util/XMLObjectChildrenList.h>\r
 \r
@@ -32,9 +31,9 @@ using namespace xercesc;
 namespace xmltooling {\r
 \r
     /**\r
-     * An XMLObject with an open content model.\r
+     * An XMLObject that exposes its children via mutable list.\r
      */\r
-    class XMLTOOL_API ElementProxy : public virtual SimpleElement\r
+    class XMLTOOL_API ElementProxy : public virtual XMLObject\r
     {\r
     public:\r
         ElementProxy() {}\r
index 8099251..94062fe 100644 (file)
@@ -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 (file)
index 6386f4a..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*\r
- *  Copyright 2001-2006 Internet2\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-/**\r
- * @file SimpleElement.h\r
- * \r
- * An XMLObject with a simple content model. \r
- */\r
-\r
-#ifndef __xmltooling_simpleel_h__\r
-#define __xmltooling_simpleel_h__\r
-\r
-#include <xmltooling/XMLObject.h>\r
-#include <xmltooling/util/XMLObjectChildrenList.h>\r
-\r
-using namespace xercesc;\r
-\r
-namespace xmltooling {\r
-\r
-    /**\r
-     * An XMLObject with a simple content model.\r
-     */\r
-    class XMLTOOL_API SimpleElement : public virtual XMLObject\r
-    {\r
-    public:\r
-        SimpleElement() {}\r
-        virtual ~SimpleElement() {}\r
-        \r
-        /**\r
-         * Gets the text content of the object\r
-         * \r
-         * @return the text content, or NULL\r
-         */\r
-        virtual const XMLCh* getTextContent() const=0;\r
-        \r
-        /**\r
-         * Sets (or clears) the text content of the object \r
-         * \r
-         * @param value         value to set, or NULL to clear\r
-         */\r
-        virtual void setTextContent(const XMLCh* value)=0;\r
-    };\r
-    \r
-};\r
-\r
-#endif /* __xmltooling_simpleel_h__ */\r
index cc8e54b..1fb26d6 100644 (file)
@@ -171,6 +171,24 @@ namespace xmltooling {
         virtual void removeChild(XMLObject* child)=0;\r
 \r
         /**\r
+         * Returns the text content at the specified position relative to\r
+         * any child elements. A zero represents leading text, 1 comes after\r
+         * the first child, and so forth.\r
+         *\r
+         * @param position  the relative child element position of the text  \r
+         * @return the designated text value\r
+         */\r
+        virtual const XMLCh* getTextContent(unsigned int position=0) const=0;\r
+\r
+        /**\r
+         * Sets (or clears) text content relative to a child element's position. \r
+         * \r
+         * @param value         value to set, or NULL to clear\r
+         * @param position      position relative to child element \r
+         */\r
+        virtual void setTextContent(const XMLCh* value, unsigned int position=0)=0;\r
+\r
+        /**\r
          * Gets the DOM representation of this XMLObject, if one exists.\r
          * \r
          * @return the DOM representation of this XMLObject\r
index e9bfc5e..c2a0749 100644 (file)
@@ -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 <dlfcn.h>
index 228640d..106816f 100644 (file)
     }
 
 /**
- * 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(); \
     }
 
 /**
- * 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
  * @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
 
 /**
     class linkage cname##Impl \
         : public virtual cname, \
             public xmltooling::AbstractSimpleElement, \
-            public xmltooling::AbstractChildlessElement, \
             public xmltooling::AbstractDOMCachingXMLObject, \
             public xmltooling::AbstractXMLObjectMarshaller, \
             public xmltooling::AbstractXMLObjectUnmarshaller \
                 xmltooling::AbstractSimpleElement(src), \
                 xmltooling::AbstractDOMCachingXMLObject(src) {} \
         IMPL_XMLOBJECT_CLONE(cname) \
-        IMPL_XMLOBJECT_CONTENT \
     }
     
 /**
index b6d5fc6..2bb3d58 100644 (file)
@@ -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;
 
index cc9a9ab..1b29a62 100644 (file)
@@ -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<xmlsignature::Transform*>::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<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
                 if (*i) {
                     DataReference* data=dynamic_cast<DataReference*>(*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());
index 0ee9467..1efc93b 100644 (file)
@@ -23,6 +23,7 @@
 #include "internal.h"
 #include "exceptions.h"
 #include "encryption/Encryption.h"
+#include "validation/ValidatorSuite.h"
 
 using namespace xmlencryption;
 using namespace xmltooling;
index a19060d..bdb3ccc 100644 (file)
@@ -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 {
index 0418beb..4e668c8 100644 (file)
@@ -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);
     };
 
     /**
index ded9183..ce23b31 100644 (file)
@@ -15,7 +15,7 @@
  */\r
 \r
 /**\r
- * @file UnknownElement.h\r
+ * @file xmltooling/impl/UnknownElement.h\r
  * \r
  * Basic implementation suitable for use as default for unrecognized content\r
  */\r
@@ -23,7 +23,7 @@
 #ifndef __xmltooling_unkelement_h__\r
 #define __xmltooling_unkelement_h__\r
 \r
-#include <xmltooling/AbstractChildlessElement.h>\r
+#include <xmltooling/AbstractSimpleElement.h>\r
 #include <xmltooling/exceptions.h>\r
 #include <xmltooling/XMLObjectBuilder.h>\r
 #include <xmltooling/io/AbstractXMLObjectMarshaller.h>\r
@@ -39,7 +39,7 @@
 namespace xmltooling {\r
 \r
     /// @cond off\r
-    class XMLTOOL_DLLLOCAL UnknownElementImpl : public AbstractChildlessElement, public AbstractDOMCachingXMLObject\r
+    class XMLTOOL_DLLLOCAL UnknownElementImpl : public AbstractSimpleElement, public AbstractDOMCachingXMLObject\r
     {\r
     public:\r
         UnknownElementImpl(const XMLCh* namespaceURI=NULL, const XMLCh* elementLocalName=NULL, const XMLCh* namespacePrefix=NULL)\r
@@ -49,6 +49,14 @@ namespace xmltooling {
 \r
         XMLObject* clone() const;\r
 \r
+        const XMLCh* getTextContent(unsigned int position=0) const {\r
+            throw XMLObjectException("Direct access to content is not permitted.");\r
+        }\r
+\r
+        void setTextContent(const XMLCh*, unsigned int position=0) {\r
+            throw XMLObjectException("Direct access to content is not permitted.");\r
+        }\r
+\r
         DOMElement* marshall(\r
             DOMDocument* document=NULL\r
 #ifndef XMLTOOLING_NO_XMLSEC\r
index e6a10f4..a33016c 100644 (file)
@@ -181,8 +181,7 @@ void AbstractXMLObjectMarshaller::marshallInto(
     marshallElementType(targetElement);\r
     marshallNamespaces(targetElement);\r
     marshallAttributes(targetElement);\r
-    marshallChildElements(targetElement);\r
-    marshallElementContent(targetElement);\r
+    marshallContent(targetElement);\r
     \r
 #ifndef XMLTOOLING_NO_XMLSEC\r
     if (sigs) {\r
@@ -290,17 +289,21 @@ void AbstractXMLObjectMarshaller::marshallNamespaces(DOMElement* domElement) con
     for_each(namespaces.begin(),namespaces.end(),bind1st(_addns(),domElement));\r
 }\r
 \r
-class _marshallit : public binary_function<const XMLObject*,DOMElement*,void> {\r
-public:\r
-    void operator()(const XMLObject* xo, DOMElement* e) const {\r
-        if (xo) xo->marshall(e);\r
-    }\r
-};\r
-\r
-void AbstractXMLObjectMarshaller::marshallChildElements(DOMElement* domElement) const\r
+void AbstractXMLObjectMarshaller::marshallContent(DOMElement* domElement) const\r
 {\r
-    XT_log.debug("marshalling child elements for XMLObject");\r
-\r
+    XT_log.debug("marshalling text and child elements for XMLObject");\r
+    \r
+    const XMLCh* val;\r
+    unsigned int pos=0;\r
     const list<XMLObject*>& children=getOrderedChildren();\r
-    for_each(children.begin(),children.end(),bind2nd(_marshallit(),domElement));\r
+    for (list<XMLObject*>::const_iterator i=children.begin(); i!=children.end(); ++i, ++pos) {\r
+        val = getTextContent(pos);\r
+        if (val && *val)\r
+            domElement->appendChild(domElement->getOwnerDocument()->createTextNode(val));\r
+        if (*i)\r
+            (*i)->marshall(domElement);\r
+    }\r
+    val = getTextContent(pos);\r
+    if (val && *val)\r
+        domElement->appendChild(domElement->getOwnerDocument()->createTextNode(val));\r
 }\r
index 18d9056..cbab2fe 100644 (file)
@@ -107,13 +107,13 @@ namespace xmltooling {
         void marshallNamespaces(DOMElement* domElement) const;\r
     \r
         /**\r
-         * Marshalls the child elements of the XMLObject.\r
+         * Marshalls the text content and/or child elements of the XMLObject.\r
          * \r
          * @param domElement the DOM element that will recieved the marshalled children\r
          * \r
          * @throws MarshallingException thrown if there is a problem marshalling a child element\r
          */\r
-        void marshallChildElements(DOMElement* domElement) const;\r
+        void marshallContent(DOMElement* domElement) const;\r
 \r
         /**\r
          * Marshalls the attributes from the XMLObject into the given DOM element.\r
@@ -123,13 +123,6 @@ namespace xmltooling {
          * @throws MarshallingException thrown if there is a problem marshalling an attribute\r
          */\r
         virtual void marshallAttributes(DOMElement* domElement) const {}\r
-\r
-        /**\r
-         * Marshalls data from the XMLObject into content of the DOM Element.\r
-         * \r
-         * @param domElement the DOM element recieving the content\r
-         */\r
-        virtual void marshallElementContent(DOMElement* domElement) const {}\r
     };\r
     \r
 };\r
index 6532d53..0ba988a 100644 (file)
@@ -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<DOMElement*>(childNode));
             if (!builder) {
@@ -171,11 +170,16 @@ void AbstractXMLObjectUnmarshaller::unmarshallChildElements(const DOMElement* do
             auto_ptr<XMLObject> childObject(builder->buildFromElement(static_cast<DOMElement*>(childNode)));
             processChildElement(childObject.get(), static_cast<DOMElement*>(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<QName> 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."); 
-}
index 9ed78bd..80d0909 100644 (file)
@@ -58,14 +58,14 @@ namespace xmltooling {
         virtual void unmarshallAttributes(const DOMElement* domElement);\r
 \r
         /**\r
-         * Unmarshalls a given Element's children. The resulting XMLObject child is passed to\r
-         * processChildElement() for further processing.\r
+         * Unmarshalls a given Element's child nodes. The resulting XMLObject children and content\r
+         * are passed to processChildElement() or processText() for further processing.\r
          * \r
          * @param domElement the DOM Element whose children will be unmarshalled\r
          * \r
          * @throws UnmarshallingException thrown if an error occurs unmarshalling the child elements\r
          */\r
-        virtual void unmarshallChildElements(const DOMElement* domElement);\r
+        virtual void unmarshallContent(const DOMElement* domElement);\r
 \r
         /**\r
          * Called after a child element has been unmarshalled so that it can be added to the parent XMLObject.\r
@@ -85,13 +85,6 @@ namespace xmltooling {
          * @throws UnmarshallingException thrown if there is a problem adding the attribute to the XMLObject\r
          */\r
         virtual void processAttribute(const DOMAttr* attribute);\r
-    \r
-        /**\r
-         * Called if the element being unmarshalled contained textual content so that it can be added to the XMLObject.\r
-         * \r
-         * @param elementContent the Element's text content\r
-         */\r
-        virtual void processElementContent(const XMLCh* elementContent);\r
     };\r
     \r
 };\r
index e5ffe32..eee9920 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 /**
- * @file KeyInfo.h
+ * @file xmltooling/signature/KeyInfo.h
  * 
  * XMLObjects representing XML Digital Signature, version 20020212, KeyInfo element
  * and related content.
 #define __xmltooling_keyinfo_h__
 
 #include <xmltooling/ElementProxy.h>
-#include <xmltooling/SimpleElement.h>
 #include <xmltooling/XMLObjectBuilder.h>
 #include <xmltooling/util/XMLConstants.h>
-#include <xmltooling/validation/ValidatorSuite.h>
 
 #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);
index a31908e..9ad79df 100644 (file)
@@ -26,6 +26,7 @@
 #include "util/NDC.h"\r
 #include "util/Threads.h"\r
 #include "util/XMLConstants.h"\r
+#include "validation/ValidatorSuite.h"\r
 \r
 #include <log4cpp/Category.hh>\r
 #include <xercesc/util/XMLUniDefs.hpp>\r
index 922d583..885af02 100644 (file)
@@ -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<Transform*>::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<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
                 if (*i) {
                     X509Certificate* xcert=dynamic_cast<X509Certificate*>(*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<SPKISexp*,XMLObject*> >::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<XMLObject*>::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 {
index 7a22689..44acffd 100644 (file)
@@ -23,6 +23,7 @@
 #include "internal.h"
 #include "exceptions.h"
 #include "signature/KeyInfo.h"
+#include "validation/ValidatorSuite.h"
 
 using namespace xmlsignature;
 using namespace xmltooling;
index 1c953b1..9f74f4e 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 /**
- * @file SOAP.h
+ * @file xmltooling/soap/SOAP.h
  * 
  * XMLObjects representing SOAP content
  */
 
 #include <xmltooling/AttributeExtensibleXMLObject.h>
 #include <xmltooling/ElementProxy.h>
-#include <xmltooling/SimpleElement.h>
 #include <xmltooling/XMLObjectBuilder.h>
 #include <xmltooling/util/XMLConstants.h>
-#include <xmltooling/validation/ValidatorSuite.h>
 #include <xercesc/util/XMLUniDefs.hpp>
 
 #define DECL_SOAP11OBJECTBUILDER(cname) \
index 4ac8753..eefa5a6 100644 (file)
@@ -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());
index 88bd5ed..0708fc5 100644 (file)
@@ -23,6 +23,7 @@
 #include "internal.h"
 #include "exceptions.h"
 #include "soap/SOAP.h"
+#include "validation/ValidatorSuite.h"
 
 using namespace soap11;
 using namespace xmltooling;
index 777ce13..df33c63 100644 (file)
@@ -96,10 +96,10 @@ namespace xmltooling {
         static QName* getNodeQName(const DOMNode* domNode);\r
 \r
         /**\r
-         * Constructs a QName from an attributes value.\r
+         * Constructs a QName from an attribute's value.\r
          * \r
          * @param attribute the attribute with a QName value\r
-         * @return a QName from an attributes value, or null if the given attribute is null\r
+         * @return a QName from an attribute's value, or null if the given attribute is null\r
          */\r
         static QName* getAttributeValueAsQName(const DOMAttr* attribute);\r
 \r
index 3c99092..cd675b6 100644 (file)
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\AbstractChildlessElement.cpp"\r
+                               RelativePath=".\AbstractComplexElement.cpp"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\AbstractComplexElement.cpp"\r
+                               RelativePath=".\AbstractDOMCachingXMLObject.cpp"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\AbstractDOMCachingXMLObject.cpp"\r
+                               RelativePath=".\AbstractSimpleElement.cpp"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\AbstractChildlessElement.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
                                RelativePath=".\AbstractComplexElement.h"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath=".\MixedElement.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath=".\Namespace.h"\r
                                >\r
                        </File>\r
index 45af7a9..908e4d4 100644 (file)
@@ -36,12 +36,13 @@ public:
         ifstream fs(path.c_str());\r
         DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(fs);\r
         TS_ASSERT(doc!=NULL);\r
+        XercesJanitor<DOMDocument> janitor(doc);\r
 \r
         const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());\r
         TS_ASSERT(b!=NULL);\r
 \r
         auto_ptr<ElementProxy> wcObject(\r
-            dynamic_cast<ElementProxy*>(b->buildFromDocument(doc))\r
+            dynamic_cast<ElementProxy*>(b->buildFromDocument(doc, false))\r
             );\r
         TS_ASSERT(wcObject.get()!=NULL);\r
         \r
@@ -59,6 +60,10 @@ public:
         ListOf(XMLObject)::const_iterator it=wc2->getXMLObjects().begin();\r
         ++it; ++it;\r
         TSM_ASSERT_EQUALS("Element QName unexpected", it->getElementQName(),q);\r
+\r
+        DOMElement* rebuilt = wcObject->marshall(XMLToolingConfig::getConfig().getParser().newDocument());\r
+        wcObject->setDocument(rebuilt->getOwnerDocument());\r
+        TS_ASSERT(rebuilt->isEqualNode(doc->getDocumentElement()));\r
     }\r
 \r
 };\r
index 5086243..0379cae 100644 (file)
@@ -18,6 +18,7 @@
 \r
 #include <fstream>\r
 #include <xmltooling/signature/KeyInfo.h>\r
+#include <xmltooling/validation/ValidatorSuite.h>\r
 \r
 using namespace xmlsignature;\r
 \r
index a90b1fc..85d42b1 100644 (file)
@@ -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<SimpleXMLObject*>(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<SimpleXMLObject*> m_simples;
 #ifndef XMLTOOLING_NO_XMLSEC
     list<XMLObject*>::iterator m_signature;
@@ -186,14 +175,14 @@ public:
         return new SimpleXMLObject(nsURI, localName, prefix, schemaType);
     }
 
-    static SimpleXMLObject* newSimpleXMLObject() {\r
-        const SimpleXMLObjectBuilder* b = dynamic_cast<const SimpleXMLObjectBuilder*>(\r
-            XMLObjectBuilder::getBuilder(QName(SimpleXMLObject::NAMESPACE,SimpleXMLObject::LOCAL_NAME))\r
-            );\r
-        if (b)\r
-            return b->buildObject();\r
-        throw XMLObjectException("Unable to obtain typed builder for SimpleXMLObject.");\r
-    }\r
+    static SimpleXMLObject* newSimpleXMLObject() {
+        const SimpleXMLObjectBuilder* b = dynamic_cast<const SimpleXMLObjectBuilder*>(
+            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)