Xalan-C++ API Reference  1.12.0
KeyTable.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #if !defined(XALAN_KEYTABLE_HEADER_GUARD)
19 #define XALAN_KEYTABLE_HEADER_GUARD
20 
21 
22 
23 // Base include file. Must be first.
24 #include "XSLTDefinitions.hpp"
25 
26 
27 
29 
30 
31 
34 
35 
36 
38 
39 
40 
43 
44 
45 
46 namespace XALAN_CPP_NAMESPACE {
47 
48 
49 
50 class KeyDeclaration;
51 class NodeRefListBase;
52 class PrefixResolver;
53 class StylesheetExecutionContext;
54 class XalanElement;
55 class XalanDocument;
56 class XalanNode;
57 
58 
59 
60 
61 /**
62  * Table of element keys, keyed by document node. An instance of this
63  * class is keyed by a Document node that should be matched with the
64  * root of the current context. It contains a table of name mappings
65  * to tables that contain mappings of identifier values to nodes.
66  */
67 
70 
71 
72 class KeyTable
73 {
74 public:
75 
77 
79 
81 
82  /**
83  * Build a keys table.
84  *
85  * @param startNode node to start iterating from to build the keys
86  * index
87  * @param nscontext stylesheet's namespace context
88  * @param keyDeclarations stylesheet's xsl:key declarations
89  * @param executionContext current execution context
90  */
91  KeyTable(
92  XalanNode* startNode,
93  const PrefixResolver& resolver,
94  const KeyDeclarationVectorType& keyDeclarations,
95  StylesheetExecutionContext& executionContext);
96 
97  static KeyTable*
98  create(MemoryManager& theManager,
99  XalanNode* startNode,
100  const PrefixResolver& resolver,
101  const KeyDeclarationVectorType& keyDeclarations,
102  StylesheetExecutionContext& executionContext);
103 
104  virtual
105  ~KeyTable();
106 
107  /**
108  * Given a valid element key, return the corresponding node list. If the
109  * name was not declared with xsl:key, this will return null, the
110  * identifier is not found, it will return an empty node set, otherwise it
111  * will return a nodeset of nodes.
112  *
113  * @param name name of the key, which must match the 'name' attribute on
114  * xsl:key
115  * @param ref value that must match the value found by the 'match'
116  * attribute on xsl:key
117  * @return pointer to nodeset for key
118  */
119  const MutableNodeRefList*
120  getNodeSetByKey(
121  const XalanQName& qname,
122  const XalanDOMString& ref) const;
123 
124 private:
125 
126  static void
127  processKeyDeclaration(
128  KeysMapType& theKeys,
129  const KeyDeclaration& kd,
130  XalanNode* testNode,
131  const PrefixResolver& resolver,
132  StylesheetExecutionContext& executionContext);
133 
134  /**
135  * The document key. This table should only be used with contexts
136  * whose Document roots match this key.
137  */
138  const XalanDocument* m_docKey;
139 
140  /**
141  * Table of element keys. The table will be built on demand,
142  * when a key is requested, or set by the XMLParserLiaison or
143  * the caller. The table is:
144  * a) keyed by name,
145  * b) each with a value of a hashtable, keyed by the value returned by
146  * the use attribute,
147  * c) each with a value that is a nodelist.
148  * Thus, for a given key or keyref, look up hashtable by name,
149  * look up the nodelist by the given reference.
150  */
151 
152  KeysMapType m_keys;
153 
154  static const MutableNodeRefList s_dummyList;
155 
156  KeyDeclarationVectorType m_allKeys;
157 };
158 
159 
160 
161 }
162 
163 
164 
165 #endif // XALAN_KEYTABLE_HEADER_GUARD
xalanc::KeyTable::KeyDeclarationVectorType
XalanVector< KeyDeclaration > KeyDeclarationVectorType
Definition: KeyTable.hpp:76
MutableNodeRefList.hpp
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::StylesheetExecutionContext
Definition: StylesheetExecutionContext.hpp:106
xalanc::XalanNode
Definition: XalanNode.hpp:38
XalanDOMString.hpp
xalanc::XalanVector< KeyDeclaration >
XALAN_USES_MEMORY_MANAGER
#define XALAN_USES_MEMORY_MANAGER(Type)
Definition: XalanMemoryManagement.hpp:589
xalanc::MutableNodeRefList
Local implementation of MutableNodeRefList.
Definition: MutableNodeRefList.hpp:46
xalanc::XalanDocument
Definition: XalanDocument.hpp:36
XalanVector.hpp
xalanc::KeyDeclaration
Holds the attribute declarations for the "xsl:key" element.
Definition: KeyDeclaration.hpp:43
DOMStringHelper.hpp
XalanQNameByReference.hpp
xalanc::KeyTable
Definition: KeyTable.hpp:72
xalanc::PrefixResolver
This class defines an interface for classes that resolve namespace prefixes to their URIs.
Definition: PrefixResolver.hpp:39
xalanc::XalanMap
Xalan implementation of a hashtable.
Definition: XalanMap.hpp:186
xalanc::KeyTable::NodeListMapType
NodeListMapTypeDefinitions NodeListMapType
Definition: KeyTable.hpp:78
XalanMap.hpp
XSLTDefinitions.hpp
xalanc::XalanQName
Class to represent a qualified name.
Definition: XalanQName.hpp:70
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::NodeListMapTypeDefinitions
XalanMap< XalanDOMString, MutableNodeRefList > NodeListMapTypeDefinitions
Table of element keys, keyed by document node.
Definition: KeyTable.hpp:56
xalanc::KeyTable::KeysMapType
XalanMap< XalanQNameByReference, NodeListMapType > KeysMapType
Definition: KeyTable.hpp:80