+++ /dev/null
-/*\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
#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);
}
*/\r
\r
/**\r
- * @file AbstractComplexElement.h\r
+ * @file xmltooling/AbstractComplexElement.h\r
* \r
* AbstractXMLObject mixin that implements children\r
*/\r
\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
\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
*/\r
\r
/**\r
- * @file AbstractElementProxy.h\r
+ * @file xmltooling/AbstractElementProxy.h\r
* \r
* AbstractXMLObject mixin that implements an open content model \r
*/\r
#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
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
*/\r
\r
/**\r
- * AbstractChildlessElement.cpp\r
+ * AbstractSimpleElement.cpp\r
* \r
- * Extension of AbstractXMLObject that implements childlessness \r
+ * Extension of AbstractXMLObject that implements simple elements \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
*/\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
#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
* 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
\r
private:\r
XMLCh* m_value;\r
+\r
+ static std::list<XMLObject*> m_no_children;\r
};\r
\r
};\r
\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
*/\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
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
libxmltoolinginclude_HEADERS = \
AbstractAttributeExtensibleXMLObject.h \
- AbstractChildlessElement.h \
AbstractComplexElement.h \
AbstractDOMCachingXMLObject.h \
AbstractElementProxy.h \
Namespace.h \
PluginManager.h \
QName.h \
- SimpleElement.h \
unicode.h \
version.h \
XMLObject.h \
libxmltooling_la_SOURCES = \
AbstractAttributeExtensibleXMLObject.cpp \
- AbstractChildlessElement.cpp \
AbstractComplexElement.cpp \
AbstractDOMCachingXMLObject.cpp \
+ AbstractSimpleElement.cpp \
AbstractXMLObject.cpp \
exceptions.cpp \
Namespace.cpp \
+++ /dev/null
-/*\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
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
#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>
}
/**
- * 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 \
}
/**
*/
/**
- * @file Encryption.h
+ * @file xmltooling/encryption/Encryption.h
*
* XMLObjects representing XML Encryption content
*/
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;
#include "internal.h"
#include "AbstractAttributeExtensibleXMLObject.h"
-#include "AbstractChildlessElement.h"
+#include "AbstractSimpleElement.h"
#include "AbstractElementProxy.h"
#include "exceptions.h"
#include "encryption/Encryption.h"
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())
: 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) {
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())
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());
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();
: 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);
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());
#include "internal.h"
#include "exceptions.h"
#include "encryption/Encryption.h"
+#include "validation/ValidatorSuite.h"
using namespace xmlencryption;
using namespace xmltooling;
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);
}
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 {
*/
/**
- * @file AnyElement.h
+ * @file xmltooling/impl/AnyElement.h
*
* Advanced anyType implementation suitable for deep processing of unknown content.
*/
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);
};
/**
*/\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
#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
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
\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
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
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
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
* @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
unmarshallAttributes(element);
}
- unmarshallChildElements(element);
+ unmarshallContent(element);
setDOM(element,bindDocument);
return this;
}
}
-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) {
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();
}
}
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.");
-}
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
* @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
*/
/**
- * @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)
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);
#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
*/
#include "internal.h"
-#include "AbstractChildlessElement.h"
+#include "AbstractSimpleElement.h"
#include "AbstractComplexElement.h"
#include "AbstractElementProxy.h"
#include "AbstractSimpleElement.h"
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());
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());
};
class XMLTOOL_DLLLOCAL KeyValueImpl : public virtual KeyValue,
- public AbstractSimpleElement,
public AbstractComplexElement,
public AbstractDOMCachingXMLObject,
public AbstractXMLObjectMarshaller,
}
KeyValueImpl(const KeyValueImpl& src)
- : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
+ : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
init();
if (src.getDSAKeyValue())
setDSAKeyValue(src.getDSAKeyValue()->cloneDSAKeyValue());
IMPL_TYPED_CHILD(DSAKeyValue);
IMPL_TYPED_CHILD(RSAKeyValue);
IMPL_XMLOBJECT_CHILD(OtherKeyValue);
- IMPL_XMLOBJECT_CONTENT;
protected:
void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
IMPL_XMLOBJECT_CLONE(Transform);
IMPL_STRING_ATTRIB(Algorithm);
IMPL_TYPED_CHILDREN(XPath,m_children.end());
- IMPL_XMLOBJECT_CONTENT;
protected:
void marshallAttributes(DOMElement* domElement) const {
: 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) {
init();
}
- RetrievalMethodImpl(const RetrievalMethodImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+ RetrievalMethodImpl(const RetrievalMethodImpl& src)
+ : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
init();
setURI(getURI());
setType(getType());
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());
: 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);
: 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) {
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());
class XMLTOOL_DLLLOCAL KeyInfoImpl : public virtual KeyInfo,
public AbstractComplexElement,
- public AbstractSimpleElement,
public AbstractDOMCachingXMLObject,
public AbstractXMLObjectMarshaller,
public AbstractXMLObjectUnmarshaller
}
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++) {
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 {
#include "internal.h"
#include "exceptions.h"
#include "signature/KeyInfo.h"
+#include "validation/ValidatorSuite.h"
using namespace xmlsignature;
using namespace xmltooling;
*/
/**
- * @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) \
#include "internal.h"
#include "AbstractAttributeExtensibleXMLObject.h"
-#include "AbstractChildlessElement.h"
+#include "AbstractSimpleElement.h"
#include "AbstractElementProxy.h"
#include "exceptions.h"
#include "io/AbstractXMLObjectMarshaller.h"
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
}
IMPL_XMLOBJECT_CLONE(Faultcode);
- IMPL_XMLOBJECT_CONTENT;
};
class XMLTOOL_DLLLOCAL DetailImpl : public virtual Detail,
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());
}
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());
#include "internal.h"
#include "exceptions.h"
#include "soap/SOAP.h"
+#include "validation/ValidatorSuite.h"
using namespace soap11;
using 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
>\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
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
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
\r
#include <fstream>\r
#include <xmltooling/signature/KeyInfo.h>\r
+#include <xmltooling/validation/ValidatorSuite.h>\r
\r
using namespace xmlsignature;\r
\r
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();
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();
virtual ~SimpleXMLObject() {
XMLString::release(&m_id);
- XMLString::release(&m_value);
}
SimpleXMLObject* clone() const {
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 {
}
}
- 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) {
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;
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)