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 UnknownElement.h
\r
20 * Basic implementations suitable for use as defaults for unrecognized content
\r
23 #if !defined(__xmltooling_unkelement_h__)
\r
24 #define __xmltooling_unkelement_h__
\r
26 #include "internal.h"
\r
27 #include "AbstractDOMCachingXMLObject.h"
\r
28 #include "XMLObjectBuilder.h"
\r
29 #include "io/Marshaller.h"
\r
30 #include "io/Unmarshaller.h"
\r
34 #if defined (_MSC_VER)
\r
35 #pragma warning( push )
\r
36 #pragma warning( disable : 4250 4251 )
\r
39 namespace xmltooling {
\r
42 * Implementation class for unrecognized DOM elements.
\r
43 * Purpose is to wrap the DOM and do any necessary caching/reconstruction
\r
44 * when a DOM has to cross into a new document.
\r
46 class XMLTOOL_DLLLOCAL UnknownElementImpl : public AbstractDOMCachingXMLObject
\r
49 UnknownElementImpl(const XMLCh* namespaceURI=NULL, const XMLCh* elementLocalName=NULL, const XMLCh* namespacePrefix=NULL)
\r
50 : AbstractDOMCachingXMLObject(namespaceURI, elementLocalName, namespacePrefix) {}
\r
53 * Overridden to ensure XML content of DOM isn't lost.
\r
55 * @see DOMCachingXMLObject::releaseDOM()
\r
60 * @see XMLObject::clone()
\r
62 XMLObject* clone() const;
\r
66 * When needed, we can serialize the DOM into XML form and preserve it here.
\r
70 void serialize(std::string& s) const;
\r
72 friend class XMLTOOL_DLLLOCAL UnknownElementMarshaller;
\r
76 * Factory for UnknownElementImpl objects
\r
78 class XMLTOOL_DLLLOCAL UnknownElementBuilder : public virtual XMLObjectBuilder
\r
82 * @see XMLObjectBuilder::buildObject()
\r
84 XMLObject* buildObject() const {
\r
85 return new UnknownElementImpl();
\r
90 * Marshaller for UnknownElementImpl objects
\r
92 class XMLTOOL_DLLLOCAL UnknownElementMarshaller : public virtual Marshaller
\r
96 * @see Marshaller::marshall(XMLObject*,DOMDocument*, const MarshallingContext*)
\r
98 DOMElement* marshall(XMLObject* xmlObject, DOMDocument* document=NULL, MarshallingContext* ctx=NULL) const;
\r
101 * @see Marshaller::marshall(XMLObject*,DOMElement*, const MarshallingContext* ctx)
\r
103 DOMElement* marshall(XMLObject* xmlObject, DOMElement* parentElement, MarshallingContext* ctx=NULL) const;
\r
106 void setDocumentElement(DOMDocument* document, DOMElement* element) const {
\r
107 DOMElement* documentRoot = document->getDocumentElement();
\r
109 document->replaceChild(documentRoot, element);
\r
111 document->appendChild(element);
\r
116 * Unmarshaller for UnknownElementImpl objects
\r
118 class XMLTOOL_DLLLOCAL UnknownElementUnmarshaller : public virtual Unmarshaller
\r
122 * @see Unmarshaller::unmarshall()
\r
124 XMLObject* unmarshall(DOMElement* element, bool bindDocument=false) const;
\r
128 #if defined (_MSC_VER)
\r
129 #pragma warning( pop )
\r
132 #endif /* __xmltooling_unkelement_h__ */
\r