X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-xmltooling.git;a=blobdiff_plain;f=xmltoolingtest%2FXMLObjectBaseTestCase.h;h=c51a4ffd4a4ff83cce551ef4f247264da095c09e;hp=3eebe23dd334fdb0d427d703691fafec6d0412f8;hb=HEAD;hpb=5cb314df178f78c6fa7b9826c2c5a5298ec7a473 diff --git a/xmltoolingtest/XMLObjectBaseTestCase.h b/xmltoolingtest/XMLObjectBaseTestCase.h index 3eebe23..c51a4ff 100644 --- a/xmltoolingtest/XMLObjectBaseTestCase.h +++ b/xmltoolingtest/XMLObjectBaseTestCase.h @@ -1,20 +1,25 @@ -/* - * Copyright 2001-2007 Internet2 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at +/** + * Licensed to the University Corporation for Advanced Internet + * Development, Inc. (UCAID) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. * - * http://www.apache.org/licenses/LICENSE-2.0 + * UCAID licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the + * License at * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. */ #include +#include #include #include #include @@ -35,6 +40,7 @@ #endif using namespace xmltooling; +using namespace xercesc; using namespace std; extern string data_path; @@ -45,17 +51,18 @@ extern string data_path; #endif class SimpleXMLObject - : public AbstractComplexElement, + : public AbstractAttributeExtensibleXMLObject, + public AbstractComplexElement, public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller { protected: SimpleXMLObject(const SimpleXMLObject& src) - : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src), + : AbstractXMLObject(src), AbstractAttributeExtensibleXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src), m_id(XMLString::replicate(src.m_id)) { #ifndef XMLTOOLING_NO_XMLSEC - m_children.push_back(NULL); + m_children.push_back(nullptr); m_signature=m_children.begin(); #endif VectorOf(SimpleXMLObject) mine=getSimpleXMLObjects(); @@ -73,10 +80,10 @@ public: static const XMLCh ID_ATTRIB_NAME[]; SimpleXMLObject( - const XMLCh* nsURI=NULL, const XMLCh* localName=NULL, const XMLCh* prefix=NULL, const QName* schemaType=NULL - ) : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_id(NULL) { + const XMLCh* nsURI=nullptr, const XMLCh* localName=nullptr, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr + ) : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_id(nullptr) { #ifndef XMLTOOLING_NO_XMLSEC - m_children.push_back(NULL); + m_children.push_back(nullptr); m_signature=m_children.begin(); #endif } @@ -122,14 +129,19 @@ public: } protected: - void marshallAttributes(DOMElement* domElement) const { + void marshallAttributes(xercesc::DOMElement* domElement) const { if(getId()) { - domElement->setAttributeNS(NULL, SimpleXMLObject::ID_ATTRIB_NAME, getId()); - domElement->setIdAttributeNS(NULL, SimpleXMLObject::ID_ATTRIB_NAME); + domElement->setAttributeNS(nullptr, SimpleXMLObject::ID_ATTRIB_NAME, getId()); +#ifdef XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE + domElement->setIdAttributeNS(nullptr, SimpleXMLObject::ID_ATTRIB_NAME, true); +#else + domElement->setIdAttributeNS(nullptr, SimpleXMLObject::ID_ATTRIB_NAME); +#endif } + marshallExtensionAttributes(domElement); } - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + void processChildElement(XMLObject* childXMLObject, const xercesc::DOMElement* root) { SimpleXMLObject* simple=dynamic_cast(childXMLObject); if (simple) { getSimpleXMLObjects().push_back(simple); @@ -147,11 +159,12 @@ protected: throw UnmarshallingException("Unknown child element cannot be added to parent object."); } - void processAttribute(const DOMAttr* attribute) { - if (XMLHelper::isNodeNamed(attribute, NULL, SimpleXMLObject::ID_ATTRIB_NAME)) + void processAttribute(const xercesc::DOMAttr* attribute) { + if (XMLHelper::isNodeNamed(attribute, nullptr, SimpleXMLObject::ID_ATTRIB_NAME)) { setId(attribute->getValue()); - else - throw UnmarshallingException("Unknown attribute cannot be processed by parent object."); + return; + } + unmarshallExtensionAttribute(attribute); } private: @@ -170,14 +183,14 @@ public: } XMLObject* buildObject( - const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL + const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=nullptr, const xmltooling::QName* schemaType=nullptr ) const { return new SimpleXMLObject(nsURI, localName, prefix, schemaType); } static SimpleXMLObject* buildSimpleXMLObject() { const SimpleXMLObjectBuilder* b = dynamic_cast( - XMLObjectBuilder::getBuilder(QName(SimpleXMLObject::NAMESPACE,SimpleXMLObject::LOCAL_NAME)) + XMLObjectBuilder::getBuilder(xmltooling::QName(SimpleXMLObject::NAMESPACE,SimpleXMLObject::LOCAL_NAME)) ); if (b) return dynamic_cast(b->buildObject());