Xerces 3 revisions.
[shibboleth/cpp-xmltooling.git] / xmltooling / impl / AnyElement.cpp
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * AnyElement.cpp
19  * 
20  * Advanced anyType implementation suitable for deep processing of unknown content.
21  */
22
23 #include "internal.h"
24 #include "exceptions.h"
25 #include "impl/AnyElement.h"
26 #include "util/NDC.h"
27 #include "util/XMLHelper.h"
28
29 #include <xercesc/util/XMLUniDefs.hpp>
30
31 using namespace xmltooling;
32 using namespace xercesc;
33 using namespace std;
34
35 XMLObject* AnyElementImpl::clone() const {
36     auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone());
37     AnyElementImpl* ret=dynamic_cast<AnyElementImpl*>(domClone.get());
38     if (ret) {
39         domClone.release();
40         return ret;
41     }
42
43     return new AnyElementImpl(*this);
44 }
45
46 AnyElementImpl::AnyElementImpl(const AnyElementImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src),
47         AbstractComplexElement(src), AbstractAttributeExtensibleXMLObject(src) {
48     const vector<XMLObject*>& children = src.getUnknownXMLObjects();
49     for (vector<XMLObject*>::const_iterator i=children.begin(); i!=children.end(); ++i)
50         getUnknownXMLObjects().push_back((*i)->clone());
51 }       
52
53 void AnyElementImpl::marshallAttributes(DOMElement* domElement) const {
54     marshallExtensionAttributes(domElement);
55 }
56
57 void AnyElementImpl::processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
58     getUnknownXMLObjects().push_back(childXMLObject);
59 }
60
61 void AnyElementImpl::processAttribute(const DOMAttr* attribute) {
62     unmarshallExtensionAttribute(attribute);
63 }
64
65 XMLObject* AnyElementBuilder::buildObject(
66     const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType
67     ) const {
68     return new AnyElementImpl(nsURI, localName, prefix, schemaType);
69 }