2 * Copyright 2001-2006 Internet2
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
18 * @file AbstractXMLObjectMarshaller.h
\r
20 * A thread-safe abstract marshaller.
\r
23 #if !defined(__xmltooling_xmlmarshaller_h__)
\r
24 #define __xmltooling_xmlmarshaller_h__
\r
26 #include <xmltooling/io/Marshaller.h>
\r
28 namespace xmltooling {
\r
31 * A thread-safe abstract marshaller.
\r
33 class XMLTOOL_API AbstractXMLObjectMarshaller : public virtual Marshaller
\r
36 virtual ~AbstractXMLObjectMarshaller() {}
\r
39 * @see Marshaller::marshall()
\r
41 DOMElement* marshall(XMLObject* xmlObject, DOMDocument* document=NULL) const;
\r
48 * @param targetNamespaceURI the namespace URI of either the schema type QName or element QName of the elements this
\r
49 * marshaller operates on
\r
50 * @param targetLocalName the local name of either the schema type QName or element QName of the elements this
\r
51 * marshaller operates on
\r
53 AbstractXMLObjectMarshaller(const XMLCh* targetNamespaceURI, const XMLCh* targetLocalName);
\r
56 * Creates an xsi:type attribute, corresponding to the given type of the XMLObject, on the DOM element.
\r
58 * @param xmlObject the XMLObject
\r
59 * @param domElement the DOM element
\r
61 * @throws MarshallingException thrown if the type on the XMLObject is doesn't contain
\r
62 * a local name, prefix, and namespace URI
\r
64 void marshallElementType(XMLObject* xmlObject, DOMElement* domElement) const;
\r
67 * Creates the xmlns attributes for any namespaces set on the given XMLObject.
\r
69 * @param xmlObject the XMLObject
\r
70 * @param domElement the DOM element the namespaces will be added to
\r
72 void marshallNamespaces(const XMLObject* xmlObject, DOMElement* domElement) const;
\r
75 * Marshalls the child elements of the given XMLObject.
\r
77 * @param xmlObject the XMLObject whose children will be marshalled
\r
78 * @param domElement the DOM element that will recieved the marshalled children
\r
80 * @throws MarshallingException thrown if there is a problem marshalling a child element
\r
82 void marshallChildElements(const XMLObject* xmlObject, DOMElement* domElement) const;
\r
85 * Marshalls the attributes from the given XMLObject into the given DOM element.
\r
86 * The XMLObject passed to this method is guaranteed to be of the target name
\r
87 * specified during this marshaller's construction.
\r
89 * @param xmlObject the XMLObject being marshalled
\r
90 * @param domElement the DOM Element into which attributes will be marshalled
\r
92 * @throws UnmarshallingException thrown if there is a problem unmarshalling an attribute
\r
94 virtual void marshallAttributes(const XMLObject* xmlObject, DOMElement* domElement) const=0;
\r
97 * Marshalls data from the XMLObject into content of the DOM Element.
\r
99 * @param xmlObject the XMLObject
\r
100 * @param domElement the DOM element recieving the content
\r
102 virtual void marshallElementContent(const XMLObject* xmlObject, DOMElement* domElement) const=0;
\r
106 QName m_targetQName;
\r
111 #endif /* __xmltooling_xmlmarshaller_h__ */
\r