00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(XALAN_KEYTABLE_HEADER_GUARD) 00019 #define XALAN_KEYTABLE_HEADER_GUARD 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include "XSLTDefinitions.hpp" 00025 00026 00027 00028 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00029 00030 00031 00032 #include <xalanc/Include/XalanVector.hpp> 00033 #include <xalanc/Include/XalanMap.hpp> 00034 00035 00036 00037 #include <xalanc/PlatformSupport/DOMStringHelper.hpp> 00038 00039 00040 00041 #include <xalanc/XPath/MutableNodeRefList.hpp> 00042 #include <xalanc/XPath/XalanQNameByReference.hpp> 00043 00044 00045 00046 XALAN_CPP_NAMESPACE_BEGIN 00047 00048 00049 00050 class KeyDeclaration; 00051 class NodeRefListBase; 00052 class PrefixResolver; 00053 class StylesheetExecutionContext; 00054 class XalanElement; 00055 class XalanDocument; 00056 class XalanNode; 00057 00058 00059 00060 00061 /** 00062 * Table of element keys, keyed by document node. An instance of this 00063 * class is keyed by a Document node that should be matched with the 00064 * root of the current context. It contains a table of name mappings 00065 * to tables that contain mappings of identifier values to nodes. 00066 */ 00067 00068 typedef XalanMap<XalanDOMString, MutableNodeRefList> NodeListMapTypeDefinitions; 00069 XALAN_USES_MEMORY_MANAGER(NodeListMapTypeDefinitions) 00070 00071 00072 class KeyTable 00073 { 00074 public: 00075 00076 typedef XalanVector<KeyDeclaration> KeyDeclarationVectorType; 00077 00078 typedef NodeListMapTypeDefinitions NodeListMapType; 00079 00080 typedef XalanMap<XalanQNameByReference, NodeListMapType> KeysMapType; 00081 00082 /** 00083 * Build a keys table. 00084 * 00085 * @param startNode node to start iterating from to build the keys 00086 * index 00087 * @param nscontext stylesheet's namespace context 00088 * @param keyDeclarations stylesheet's xsl:key declarations 00089 * @param executionContext current execution context 00090 */ 00091 KeyTable( 00092 XalanNode* startNode, 00093 const PrefixResolver& resolver, 00094 const KeyDeclarationVectorType& keyDeclarations, 00095 StylesheetExecutionContext& executionContext); 00096 00097 static KeyTable* 00098 create(MemoryManager& theManager, 00099 XalanNode* startNode, 00100 const PrefixResolver& resolver, 00101 const KeyDeclarationVectorType& keyDeclarations, 00102 StylesheetExecutionContext& executionContext); 00103 00104 virtual 00105 ~KeyTable(); 00106 00107 /** 00108 * Given a valid element key, return the corresponding node list. If the 00109 * name was not declared with xsl:key, this will return null, the 00110 * identifier is not found, it will return an empty node set, otherwise it 00111 * will return a nodeset of nodes. 00112 * 00113 * @param name name of the key, which must match the 'name' attribute on 00114 * xsl:key 00115 * @param ref value that must match the value found by the 'match' 00116 * attribute on xsl:key 00117 * @return pointer to nodeset for key 00118 */ 00119 const MutableNodeRefList* 00120 getNodeSetByKey( 00121 const XalanQName& qname, 00122 const XalanDOMString& ref) const; 00123 00124 private: 00125 00126 static void 00127 processKeyDeclaration( 00128 KeysMapType& theKeys, 00129 const KeyDeclaration& kd, 00130 XalanNode* testNode, 00131 const PrefixResolver& resolver, 00132 StylesheetExecutionContext& executionContext); 00133 00134 /** 00135 * The document key. This table should only be used with contexts 00136 * whose Document roots match this key. 00137 */ 00138 const XalanDocument* m_docKey; 00139 00140 /** 00141 * Table of element keys. The table will be built on demand, 00142 * when a key is requested, or set by the XMLParserLiaison or 00143 * the caller. The table is: 00144 * a) keyed by name, 00145 * b) each with a value of a hashtable, keyed by the value returned by 00146 * the use attribute, 00147 * c) each with a value that is a nodelist. 00148 * Thus, for a given key or keyref, look up hashtable by name, 00149 * look up the nodelist by the given reference. 00150 */ 00151 00152 KeysMapType m_keys; 00153 00154 static const MutableNodeRefList s_dummyList; 00155 00156 KeyDeclarationVectorType m_allKeys; 00157 }; 00158 00159 00160 00161 XALAN_CPP_NAMESPACE_END 00162 00163 00164 00165 #endif // XALAN_KEYTABLE_HEADER_GUARD
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|