xmltooling  1.5.6
xmltooling::AbstractXMLObjectMarshaller Class Reference

A mix-in to implement object marshalling with DOM reuse. More...

#include <xmltooling/io/AbstractXMLObjectMarshaller.h>

Inheritance diagram for xmltooling::AbstractXMLObjectMarshaller:
xmltooling::AbstractXMLObject xmltooling::XMLObject

Public Member Functions

xercesc::DOMElement * marshall (xercesc::DOMDocument *document=0, const std::vector< xmlsignature::Signature * > *sigs=0, const Credential *credential=0) const
 Marshalls the XMLObject, and its children, into a DOM element. More...
 
xercesc::DOMElement * marshall (xercesc::DOMElement *parentElement, const std::vector< xmlsignature::Signature * > *sigs=0, const Credential *credential=0) const
 Marshalls the XMLObject and appends it as a child of the given parent element. More...
 
- Public Member Functions inherited from xmltooling::AbstractXMLObject
void detach ()
 Specialized function for detaching a child object from its parent while disposing of the parent. More...
 
const QNamegetElementQName () const
 Gets the QName for this element. More...
 
const std::set< Namespace > & getNamespaces () const
 Gets the namespaces that are scoped to this element. More...
 
void addNamespace (const Namespace &ns) const
 Adds a namespace to the ones already scoped to this element. More...
 
void removeNamespace (const Namespace &ns)
 Removes a namespace from this element. More...
 
const QNamegetSchemaType () const
 Gets the XML schema type of this element. More...
 
const XMLCh * getXMLID () const
 Gets the value of the ID attribute set on this object, if any. More...
 
xmlconstants::xmltooling_bool_t getNil () const
 Returns the xsi:nil property as an explicit enumerated value. More...
 
void nil (xmlconstants::xmltooling_bool_t value)
 Sets the xsi:nil property using an enumerated value. More...
 
bool hasParent () const
 Checks to see if this object has a parent. More...
 
XMLObjectgetParent () const
 Gets the parent of this element or null if there is no parent. More...
 
void setParent (XMLObject *parent)
 Sets the parent of this element. More...
 
- Public Member Functions inherited from xmltooling::XMLObject
virtual XMLObjectclone () const =0
 Creates a copy of the object, along with all of its children. More...
 
virtual const XMLCh * getLang () const
 Returns the xml:lang property of the object, if any. More...
 
bool nil () const
 Returns the xsi:nil property of the object, or false if not set. More...
 
void nil (bool value)
 Sets the xsi:nil property. More...
 
void setNil (const XMLCh *value)
 Sets the xsi:nil property using a string constant. More...
 
virtual bool hasChildren () const =0
 Checks if this XMLObject has children. More...
 
virtual const std::list< XMLObject * > & getOrderedChildren () const =0
 Returns an unmodifiable list of child objects in the order that they should appear in the serialized representation. More...
 
virtual void removeChild (XMLObject *child)=0
 Used by a child's detach method to isolate the child from this parent object in preparation for destroying the parent (this object). More...
 
virtual const XMLCh * getTextContent (unsigned int position=0) const =0
 Returns the text content at the specified position relative to any child elements. More...
 
virtual void setTextContent (const XMLCh *value, unsigned int position=0)=0
 Sets (or clears) text content relative to a child element's position. More...
 
virtual xercesc::DOMElement * getDOM () const =0
 Gets the DOM representation of this XMLObject, if one exists. More...
 
virtual void setDOM (xercesc::DOMElement *dom, bool bindDocument=false) const =0
 Sets the DOM representation of this XMLObject. More...
 
virtual void setDocument (xercesc::DOMDocument *doc) const =0
 Assigns ownership of a DOM document to the XMLObject. More...
 
virtual void releaseDOM () const =0
 Releases the DOM representation of this XMLObject, if there is one.
 
virtual void releaseParentDOM (bool propagateRelease=true) const =0
 Releases the DOM representation of this XMLObject's parent. More...
 
virtual void releaseChildrenDOM (bool propagateRelease=true) const =0
 Releases the DOM representation of this XMLObject's children. More...
 
void releaseThisandParentDOM () const
 A convenience method that is equal to calling releaseDOM() then releaseParentDOM(true).
 
void releaseThisAndChildrenDOM () const
 A convenience method that is equal to calling releaseChildrenDOM(true) then releaseDOM().
 
virtual XMLObjectunmarshall (xercesc::DOMElement *element, bool bindDocument=false)=0
 Unmarshalls the given W3C DOM element into the XMLObject. More...
 

Protected Member Functions

void setDocumentElement (xercesc::DOMDocument *document, xercesc::DOMElement *element) const
 Sets the given element as the Document Element of the given Document. More...
 
void marshallInto (xercesc::DOMElement *targetElement, const std::vector< xmlsignature::Signature * > *sigs, const Credential *credential=0) const
 Marshalls the XMLObject into the given DOM Element. More...
 
void marshallElementType (xercesc::DOMElement *domElement) const
 Creates an xsi:type attribute, corresponding to the given type of the XMLObject, on the DOM element. More...
 
void marshallNamespaces (xercesc::DOMElement *domElement) const
 Creates the xmlns attributes for any namespaces set on the XMLObject. More...
 
void marshallContent (xercesc::DOMElement *domElement, const Credential *credential) const
 Marshalls the text content and/or child elements of the XMLObject. More...
 
virtual void marshallAttributes (xercesc::DOMElement *domElement) const
 Marshalls the attributes from the XMLObject into the given DOM element. More...
 
virtual void prepareForMarshalling () const
 Called before marshalling in the event that a new DOM is being generated. More...
 
- Protected Member Functions inherited from xmltooling::AbstractXMLObject
 AbstractXMLObject (const XMLCh *nsURI=0, const XMLCh *localName=0, const XMLCh *prefix=0, const QName *schemaType=0)
 Constructor. More...
 
 AbstractXMLObject (const AbstractXMLObject &src)
 Copy constructor. More...
 
XMLCh * prepareForAssignment (XMLCh *oldValue, const XMLCh *newValue)
 A helper function for derived classes, for assignment of strings. More...
 
DateTimeprepareForAssignment (DateTime *oldValue, const DateTime *newValue)
 A helper function for derived classes, for assignment of date/time data. More...
 
DateTimeprepareForAssignment (DateTime *oldValue, time_t newValue, bool duration=false)
 A helper function for derived classes, for assignment of date/time data. More...
 
DateTimeprepareForAssignment (DateTime *oldValue, const XMLCh *newValue, bool duration=false)
 A helper function for derived classes, for assignment of date/time data. More...
 
QNameprepareForAssignment (QName *oldValue, const QName *newValue)
 A helper function for derived classes, for assignment of QName data. More...
 
XMLObjectprepareForAssignment (XMLObject *oldValue, XMLObject *newValue)
 A helper function for derived classes, for assignment of (singleton) XML objects. More...
 

Additional Inherited Members

- Protected Attributes inherited from xmltooling::AbstractXMLObject
std::set< Namespacem_namespaces
 Set of namespaces associated with the object.
 
logging::Category & m_log
 Logging object.
 
XMLCh * m_schemaLocation
 Stores off xsi:schemaLocation attribute.
 
XMLCh * m_noNamespaceSchemaLocation
 Stores off xsi:noNamespaceSchemaLocation attribute.
 
xmlconstants::xmltooling_bool_t m_nil
 Stores off xsi:nil attribute.
 

Detailed Description

A mix-in to implement object marshalling with DOM reuse.

Member Function Documentation

xercesc::DOMElement* xmltooling::AbstractXMLObjectMarshaller::marshall ( xercesc::DOMDocument *  document = 0,
const std::vector< xmlsignature::Signature * > *  sigs = 0,
const Credential credential = 0 
) const
virtual

Marshalls the XMLObject, and its children, into a DOM element.

If a document is supplied, then it will be used to create the resulting elements. If the document does not have a Document Element set, then the resulting element will be set as the Document Element. If no document is supplied, then a new document will be created and bound to the lifetime of the root object being marshalled, unless an existing DOM can be reused without creating a new document.

Parameters
documentthe DOM document the marshalled element will be placed in, or nullptr
sigsordered array of signatures to create after marshalling is complete
credentialoptional credential to supply signing key and related info
Returns
the DOM element representing this XMLObject
Exceptions
MarshallingExceptionthrown if there is a problem marshalling the given object
SignatureExceptionthrown if a problem occurs during signature creation

Implements xmltooling::XMLObject.

xercesc::DOMElement* xmltooling::AbstractXMLObjectMarshaller::marshall ( xercesc::DOMElement *  parentElement,
const std::vector< xmlsignature::Signature * > *  sigs = 0,
const Credential credential = 0 
) const
virtual

Marshalls the XMLObject and appends it as a child of the given parent element.

NOTE: The given Element must be within a DOM tree rooted in the Document owning the given Element.

Parameters
parentElementthe parent element to append the resulting DOM tree
sigsordered array of signatures to create after marshalling is complete
credentialoptional credential to supply signing key and related info
Returns
the marshalled element tree
Exceptions
MarshallingExceptionthrown if the given XMLObject can not be marshalled.
SignatureExceptionthrown if a problem occurs during signature creation

Implements xmltooling::XMLObject.

virtual void xmltooling::AbstractXMLObjectMarshaller::marshallAttributes ( xercesc::DOMElement *  domElement) const
protectedvirtual

Marshalls the attributes from the XMLObject into the given DOM element.

Parameters
domElementthe DOM Element into which attributes will be marshalled
Exceptions
MarshallingExceptionthrown if there is a problem marshalling an attribute
void xmltooling::AbstractXMLObjectMarshaller::marshallContent ( xercesc::DOMElement *  domElement,
const Credential credential 
) const
protected

Marshalls the text content and/or child elements of the XMLObject.

Parameters
domElementthe DOM element that will recieved the marshalled children
credentialoptional credential to supply signing key and related info
Exceptions
MarshallingExceptionthrown if there is a problem marshalling a child element
void xmltooling::AbstractXMLObjectMarshaller::marshallElementType ( xercesc::DOMElement *  domElement) const
protected

Creates an xsi:type attribute, corresponding to the given type of the XMLObject, on the DOM element.

Parameters
domElementthe DOM element
Exceptions
MarshallingExceptionthrown if the type on the XMLObject is doesn't contain a local name, prefix, and namespace URI
void xmltooling::AbstractXMLObjectMarshaller::marshallInto ( xercesc::DOMElement *  targetElement,
const std::vector< xmlsignature::Signature * > *  sigs,
const Credential credential = 0 
) const
protected

Marshalls the XMLObject into the given DOM Element.

The DOM Element must be within a DOM tree rooted in the owning Document.

Parameters
targetElementthe Element into which the XMLObject is marshalled into
sigsoptional array of signatures to create after marshalling
credentialoptional credential to supply signing key and related info
Exceptions
MarshallingExceptionthrown if there is a problem marshalling the object
SignatureExceptionthrown if a problem occurs during signature creation
void xmltooling::AbstractXMLObjectMarshaller::marshallNamespaces ( xercesc::DOMElement *  domElement) const
protected

Creates the xmlns attributes for any namespaces set on the XMLObject.

Parameters
domElementthe DOM element the namespaces will be added to
virtual void xmltooling::AbstractXMLObjectMarshaller::prepareForMarshalling ( ) const
protectedvirtual

Called before marshalling in the event that a new DOM is being generated.

Allows objects to adjust internal state prior to the marshalling step.

void xmltooling::AbstractXMLObjectMarshaller::setDocumentElement ( xercesc::DOMDocument *  document,
xercesc::DOMElement *  element 
) const
protected

Sets the given element as the Document Element of the given Document.

If the document already has a Document Element it is replaced by the given element.

Parameters
documentthe document
elementthe Element that will serve as the Document Element

The documentation for this class was generated from the following file: