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
46namespace XALAN_CPP_NAMESPACE {
47
48
49
50class KeyDeclaration;
51class NodeRefListBase;
52class PrefixResolver;
53class StylesheetExecutionContext;
54class XalanElement;
55class XalanDocument;
56class 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
73{
74public:
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 */
92 XalanNode* startNode,
96
97 static KeyTable*
98 create(MemoryManager& theManager,
99 XalanNode* startNode,
103
104 virtual
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*
121 const XalanQName& qname,
122 const XalanDOMString& ref) const;
123
124private:
125
126 static void
127 processKeyDeclaration(
129 const KeyDeclaration& kd,
130 XalanNode* testNode,
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
#define XALAN_USES_MEMORY_MANAGER(Type)
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Holds the attribute declarations for the "xsl:key" element.
XalanMap< XalanQNameByReference, NodeListMapType > KeysMapType
Definition KeyTable.hpp:80
virtual ~KeyTable()
const MutableNodeRefList * getNodeSetByKey(const XalanQName &qname, const XalanDOMString &ref) const
Given a valid element key, return the corresponding node list.
NodeListMapTypeDefinitions NodeListMapType
Definition KeyTable.hpp:78
static KeyTable * create(MemoryManager &theManager, XalanNode *startNode, const PrefixResolver &resolver, const KeyDeclarationVectorType &keyDeclarations, StylesheetExecutionContext &executionContext)
XalanVector< KeyDeclaration > KeyDeclarationVectorType
Definition KeyTable.hpp:76
KeyTable(XalanNode *startNode, const PrefixResolver &resolver, const KeyDeclarationVectorType &keyDeclarations, StylesheetExecutionContext &executionContext)
Build a keys table.
Local implementation of MutableNodeRefList.
This class defines an interface for classes that resolve namespace prefixes to their URIs.
Class to represent a qualified name.