2 * Copyright 2001-2007 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file xmltooling/impl/UnknownElement.h
20 * Basic implementation suitable for use as default for unrecognized content
23 #ifndef __xmltooling_unkelement_h__
24 #define __xmltooling_unkelement_h__
26 #include <xmltooling/AbstractSimpleElement.h>
27 #include <xmltooling/exceptions.h>
28 #include <xmltooling/XMLObjectBuilder.h>
29 #include <xmltooling/io/AbstractXMLObjectMarshaller.h>
30 #include <xmltooling/io/AbstractXMLObjectUnmarshaller.h>
34 #if defined (_MSC_VER)
35 #pragma warning( push )
36 #pragma warning( disable : 4250 4251 )
39 namespace xmltooling {
42 class XMLTOOL_DLLLOCAL UnknownElementImpl : public AbstractSimpleElement, public AbstractDOMCachingXMLObject
45 UnknownElementImpl(const XMLCh* namespaceURI=NULL, const XMLCh* elementLocalName=NULL, const XMLCh* namespacePrefix=NULL)
46 : AbstractXMLObject(namespaceURI, elementLocalName, namespacePrefix) {}
48 void releaseDOM() const;
50 XMLObject* clone() const;
52 const XMLCh* getTextContent(unsigned int position=0) const {
53 throw XMLObjectException("Direct access to content is not permitted.");
56 void setTextContent(const XMLCh*, unsigned int position=0) {
57 throw XMLObjectException("Direct access to content is not permitted.");
61 DOMDocument* document=NULL
62 #ifndef XMLTOOLING_NO_XMLSEC
63 ,const std::vector<xmlsignature::Signature*>* sigs=NULL
68 DOMElement* parentElement
69 #ifndef XMLTOOLING_NO_XMLSEC
70 ,const std::vector<xmlsignature::Signature*>* sigs=NULL
73 XMLObject* unmarshall(DOMElement* element, bool bindDocument=false);
76 void setDocumentElement(DOMDocument* document, DOMElement* element) const {
77 DOMElement* documentRoot = document->getDocumentElement();
79 document->replaceChild(element, documentRoot);
81 document->appendChild(element);
84 mutable std::string m_xml;
86 void serialize(std::string& s) const;
91 * Builder for UnknownElementImpl objects.
92 * Use as the default builder when you want unknown DOM content treated as raw/ignored XML.
94 class XMLTOOL_API UnknownElementBuilder : public XMLObjectBuilder
97 XMLObject* buildObject(
98 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL
104 #if defined (_MSC_VER)
105 #pragma warning( pop )
108 #endif /* __xmltooling_unkelement_h__ */