00001 /* 00002 * Copyright 2002-2005 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 /* 00018 * XSEC 00019 * 00020 * XSECNameSpaceHolder := Container class for holding and managing the name space stack 00021 * Used when running through a DOM document 00022 * 00023 * $Id: XSECNameSpaceExpander.hpp,v 1.8 2005/02/03 13:53:54 milan Exp $ 00024 * 00025 */ 00026 00027 #ifndef XSECNAMESPACEEXPANDER_HEADER 00028 #define XSECNAMESPACEEXPANDER_HEADER 00029 00030 // XSEC Includes 00031 #include <xsec/framework/XSECDefs.hpp> 00032 #include <xsec/utils/XSECSafeBuffer.hpp> 00033 #include <xsec/utils/XSECSafeBufferFormatter.hpp> 00034 00035 // Xerces Includes 00036 XSEC_DECLARE_XERCES_CLASS(DOMDocument); 00037 XSEC_DECLARE_XERCES_CLASS(DOMNode); 00038 XSEC_DECLARE_XERCES_CLASS(DOMElement); 00039 00040 #include <vector> 00041 00042 // -------------------------------------------------------------------------------- 00043 // Structure Definition for the nodes within the list of nodes 00044 // -------------------------------------------------------------------------------- 00045 00046 struct XSECNameSpaceEntry { 00047 00048 // Variables 00049 safeBuffer m_name; // The name for this name space 00050 XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * mp_node; // The Element Node owner 00051 XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * mp_att; // The added attribute node 00052 00053 }; 00054 00055 // -------------------------------------------------------------------------------- 00056 // Class definition for the list 00057 // -------------------------------------------------------------------------------- 00058 00062 /*\@{*/ 00063 00092 class CANON_EXPORT XSECNameSpaceExpander { 00093 00094 00095 #if defined(XALAN_NO_NAMESPACES) 00096 typedef vector<XSECNameSpaceEntry *> NameSpaceEntryListVectorType; 00097 #else 00098 typedef std::vector<XSECNameSpaceEntry *> NameSpaceEntryListVectorType; 00099 #endif 00100 00101 00102 public: 00103 00106 00115 XSECNameSpaceExpander(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *d); // Constructor 00116 00126 XSECNameSpaceExpander(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *f); // frag Constructor 00127 00128 ~XSECNameSpaceExpander(); // Default destructor 00129 00131 00132 // Operate 00133 00140 void expandNameSpaces(void); 00141 00149 void deleteAddedNamespaces(void); 00150 00151 // Check if a node is an added node 00152 bool nodeWasAdded(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *n); 00153 00154 private: // Functions 00155 00156 XSECNameSpaceExpander(void); // No default constructor 00157 void recurse(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *n); 00158 00159 // data 00160 00161 NameSpaceEntryListVectorType m_lst; // List of added name spaces 00162 XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument 00163 * mp_doc; // The owner document 00164 XERCES_CPP_NAMESPACE_QUALIFIER DOMElement 00165 * mp_fragment; // If we are doing a fragment 00166 bool m_expanded; // Have we expanded already? 00167 XSECSafeBufferFormatter * mp_formatter; 00168 00169 }; 00170 00171 #endif /* XSECNAMESPACEEXPANDER_HEADER */ 00172