Xalan-C++ API Reference 1.12.0
NamespacesHandler.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
19#if !defined(XALAN_NAMESPACESHANDLER_HEADER_GUARD)
20#define XALAN_NAMESPACESHANDLER_HEADER_GUARD
21
22
23
24// Base include file. Must be first.
26
27
28
31
32
33
35
36
37
40
41
42
43namespace XALAN_CPP_NAMESPACE {
44
45
46
47class StylesheetConstructionContext;
48class StylesheetExecutionContext;
49
50
51
53{
54
55public:
56
58 {
59 public:
60
62
63 virtual
65
66 virtual bool
68 };
69
71 {
72 public:
73
75 m_prefix(&s_emptyString),
76 m_uri(&s_emptyString)
77 {
78 }
79
82 const XalanDOMString& uri) :
83 m_prefix(&prefix),
84 m_uri(&uri)
85 {
86 }
87
88 /**
89 * Retrieve the prefix for namespace
90 *
91 * @return prefix string
92 */
93 const XalanDOMString&
94 getPrefix() const
95 {
96 assert(m_prefix != 0);
97
98 return *m_prefix;
99 }
100
101 /**
102 * Set the prefix for namespace
103 *
104 * @param prefix The new prefix value
105 */
106 void
108 {
109 m_prefix = &prefix;
110 }
111
112 /**
113 * Retrieve the URI for namespace
114 *
115 * @return URI string
116 */
117 const XalanDOMString&
118 getURI() const
119 {
120 assert(m_uri != 0);
121
122 return *m_uri;
123 }
124
125 /**
126 * Set the URI for namespace
127 *
128 * @param uri The new uri value
129 */
130 void
132 {
133 m_uri = &uri;
134 }
135
136 protected:
137
139
140 private:
141
142 const XalanDOMString* m_prefix;
143
144 const XalanDOMString* m_uri;
145 };
146
148 {
149 public:
150
152 Namespace(),
153 m_resultAttributeName(&s_emptyString)
154 {
155 }
156
158 const XalanDOMString& prefix,
159 const XalanDOMString& uri) :
161 m_resultAttributeName(&s_emptyString)
162 {
163 }
164
165 /**
166 * Retrieve the name of the result attribute.
167 *
168 * @return name string
169 */
170 const XalanDOMString&
172 {
173 assert(m_resultAttributeName != 0);
174
175 return *m_resultAttributeName;
176 }
177
178 /**
179 * Set the name of the result attribute.
180 *
181 * @param name The new name value
182 */
183 void
185 {
186 m_resultAttributeName = &name;
187 }
188
189 private:
190
191 const XalanDOMString* m_resultAttributeName;
192 };
193
196
200
201 typedef XalanMap<const XalanDOMString*,
203
204
205 /**
206 * Create a default, empty instance.
207 */
208 explicit
210
211 /**
212 * Create an instance namespace handler using the
213 * current namespaces in effect.
214 *
215 * @param theConstructionContext The current construction context.
216 * @param stylesheetNamespacesHandler The stylesheet's handler.
217 * @param theCurrentNamespaces The stack of active namespace declarations.
218 * @param theXSLTNamespaceURI The namespace URI for XSLT.
219 */
225
227
228 /**
229 * Process an exclude-result-prefixes attribute.
230 *
231 * @param theConstructionContext The current construction context.
232 * @param theValue The attribute's value.
233 * @param theCurrentNamespaces The stack of active namespace declarations.
234 */
235 void
238 const XalanDOMChar* theValue,
240
241 /**
242 * Process an extension-element-prefixes attribute.
243 *
244 * @param theConstructionContext The current construction context.
245 * @param theValue The attribute's value.
246 * @param theCurrentNamespaces The stack of active namespace declarations.
247 */
248 void
251 const XalanDOMChar* theValue,
253
254 /**
255 * Notify the instance that the stylesheet is fully constructed.
256 *
257 * @param theConstructionContext The current construction context.
258 * @param fProcessNamespaceAliases If true, process any namespace aliases
259 * @param theElementName The name of the owning element.
260 * @param parentNamespacesHandler The parent handler, if any.
261 * @param prefixChecker A pointer to a PrefixChecker instance to use, if any.
262 */
263 void
266 bool fProcessNamespaceAliases = true,
267 const XalanDOMString& theElementName = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
269 const PrefixChecker* prefixChecker = 0);
270
273
274 /**
275 * Determine of a given namespace should be excluded.
276 *
277 * @param theXSLTNamespaceURI The namespace URI for XSLT.
278 * @param theURI The namespace URI.
279 * @return true of the namespace should be excluded, false if not.
280 */
281 bool
284 const XalanDOMString& theURI) const;
285
286 /**
287 * Add a URI as an extension namespace prefixes.
288 *
289 * @param theConstructionContext The current construction context.
290 * @param theURI The namespace URI.
291 */
292 void
295 const XalanDOMString& theURI);
296
297 /**
298 * Get the namespace URI for the given prefix.
299 *
300 * @param thePrefix The namespace prefix.
301 * @return The namespace URI
302 */
303 const XalanDOMString*
305
306 /**
307 * Get the namespace alias URI for the given namespace.
308 *
309 * @param theStylesheetNamespace The namespace as declared in the stylesheet.
310 * @return The namespace alias URI
311 */
312 const XalanDOMString*
314
315 /**
316 * Set the namespace alias URI for the given namespace.
317 *
318 * @param theConstructionContext The current construction context.
319 * @param theStylesheetNamespace The namespace as declared in the stylesheet.
320 * @param theResultNamespace The namespace as it should appear in the result tree.
321 */
322 void
327
328 /**
329 * Copy the aliases from the given NamespacesHandler.
330 *
331 * @param parentNamespacesHandler The parent handler.
332 */
333 void
335
336 /**
337 * Output the result tree namespace declarations.
338 *
339 * @param theExecutionContext The current execution context.
340 * @param supressDefault If true, any default namespace declaration will not be output.
341 */
342 void
345 bool supressDefault = false) const;
346
347 /**
348 * Clear out the handler.
349 */
350 void
352
353 /**
354 * Swap the contents of this instance with another.
355 *
356 * @param theOther The other instance.
357 */
358 void
360
363 {
364 return m_namespaceDeclarations.size();
365 }
366
367private:
368
369 /**
370 * Create all of the result attribute names.
371 *
372 * @param theConstructionContext The current construction context.
373 */
374 void
375 createResultAttributeNames(StylesheetConstructionContext& theConstructionContext);
376
377 /**
378 * Process the exclude result prefix data.
379 *
380 * @param theConstructionContext The current construction context.
381 * @param theElementPrefix The prefix of the owning element.
382 * @param prefixChecker A pointer to a PrefixChecker instance to use, if any.
383 */
384 void
385 processExcludeResultPrefixes(
388 const PrefixChecker* prefixChecker);
389
390 /**
391 * Process the namespace aliases data.
392 */
393 void
394 processNamespaceAliases();
395
396 /**
397 * Copy the contents of the supplied map
398 *
399 * @param theNamespaceAliases The map to copy.
400 */
401 void
402 copyNamespaceAliases(const NamespaceAliasesMapType& theNamespaceAliases);
403
404 /**
405 * Copy the contents of the supplied vector
406 *
407 * @param theExtensionNamespaceURIs The set to copy.
408 */
409 void
410 copyExtensionNamespaceURIs(const XalanDOMStringPointerVectorType& theExtensionNamespaceURIs);
411
412 /**
413 * Copy the contents of the supplied vector
414 *
415 * @param theExcludeResultPrefixes The vector to copy.
416 */
417 void
418 copyExcludeResultPrefixes(const NamespacesVectorType& theExcludeResultPrefixes);
419
420 /**
421 * Determine if a given namespace should be excluded as a result of
422 * an exclude-result-prefixes declaration.
423 *
424 * @param theNamespaceURI The namespace URI to check.
425 * @return true if the namespace should be excluded, false if not.
426 */
427 bool
428 isExcludedNamespaceURI(const XalanDOMString& theNamespaceURI) const;
429
430 /**
431 * Determine if a given URI is an extension namespace URI
432 *
433 * @param theNamespaceURI The namespace URI to check.
434 * @return true if the namespace uri is an extension namespace URI, false if not.
435 */
436 bool
437 isExtensionNamespaceURI(const XalanDOMString& theNamespaceURI) const
438 {
439 return findString(theNamespaceURI, m_extensionNamespaceURIs);
440 }
441
442 /**
443 * Determine if a given string is present in the vector
444 *
445 * @param theString The string to find.
446 * @return true if the string is present, false if not.
447 */
448 static bool
449 findString(
450 const XalanDOMString& theString,
451 const XalanDOMStringPointerVectorType& theVector);
452
453
454 // Not implemented...
455 bool
456 operator==(const NamespacesHandler&) const;
457
458
459 // Data members...
460 NamespacesVectorType m_excludedResultPrefixes;
461
462 NamespaceExtendedVectorType m_namespaceDeclarations;
463
464 XalanDOMStringPointerVectorType m_extensionNamespaceURIs;
465
466 NamespaceAliasesMapType m_namespaceAliases;
467};
468
469
470
471}
472
473
474
475#endif // XALAN_NAMESPACESHANDLER_HEADER_GUARD
#define XALAN_XSLT_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
NamespaceExtended(const XalanDOMString &prefix, const XalanDOMString &uri)
void setResultAttributeName(const XalanDOMString &name)
Set the name of the result attribute.
const XalanDOMString & getResultAttributeName() const
Retrieve the name of the result attribute.
const XalanDOMString & getURI() const
Retrieve the URI for namespace.
Namespace(const XalanDOMString &prefix, const XalanDOMString &uri)
const XalanDOMString & getPrefix() const
Retrieve the prefix for namespace.
void setPrefix(const XalanDOMString &prefix)
Set the prefix for namespace.
void setURI(const XalanDOMString &uri)
Set the URI for namespace.
static const XalanDOMString s_emptyString
virtual bool isActive(const XalanDOMString &thePrefix) const =0
NamespacesHandler(MemoryManager &theManager)
Create a default, empty instance.
NamespacesHandler & operator=(const NamespacesHandler &theRHS)
void outputResultNamespaces(StylesheetExecutionContext &theExecutionContext, bool supressDefault=false) const
Output the result tree namespace declarations.
void postConstruction(StylesheetConstructionContext &theConstructionContext, bool fProcessNamespaceAliases=true, const XalanDOMString &theElementName=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const NamespacesHandler *parentNamespacesHandler=0, const PrefixChecker *prefixChecker=0)
Notify the instance that the stylesheet is fully constructed.
void swap(NamespacesHandler &theOther)
Swap the contents of this instance with another.
XalanQName::NamespaceVectorType NamespaceVectorType
XalanMap< const XalanDOMString *, const XalanDOMString * > NamespaceAliasesMapType
XalanQName::NamespacesStackType NamespacesStackType
bool shouldExcludeResultNamespaceNode(const XalanDOMString &theXSLTNamespaceURI, const XalanDOMString &theURI) const
Determine of a given namespace should be excluded.
const XalanDOMString * getNamespace(const XalanDOMString &thePrefix) const
Get the namespace URI for the given prefix.
void copyNamespaceAliases(const NamespacesHandler &parentNamespacesHandler)
Copy the aliases from the given NamespacesHandler.
void setNamespaceAlias(StylesheetConstructionContext &theConstructionContext, const XalanDOMString &theStylesheetNamespace, const XalanDOMString &theResultNamespace)
Set the namespace alias URI for the given namespace.
NamespaceExtendedVectorType::size_type getNamespaceDeclarationsCount() const
XalanVector< const XalanDOMString * > XalanDOMStringPointerVectorType
void processExcludeResultPrefixes(StylesheetConstructionContext &theConstructionContext, const XalanDOMChar *theValue, const NamespacesStackType &theCurrentNamespaces)
Process an exclude-result-prefixes attribute.
void addExtensionNamespaceURI(StylesheetConstructionContext &theConstructionContext, const XalanDOMString &theURI)
Add a URI as an extension namespace prefixes.
NamespacesHandler(StylesheetConstructionContext &theConstructionContext, const NamespacesHandler &stylesheetNamespacesHandler, const NamespacesStackType &theCurrentNamespaces, const XalanDOMString &theXSLTNamespaceURI)
Create an instance namespace handler using the current namespaces in effect.
const XalanDOMString * getNamespaceAlias(const XalanDOMString &theStylesheetNamespace) const
Get the namespace alias URI for the given namespace.
void clear()
Clear out the handler.
XalanVector< NamespaceExtended > NamespaceExtendedVectorType
void processExtensionElementPrefixes(StylesheetConstructionContext &theConstructionContext, const XalanDOMChar *theValue, const NamespacesStackType &theCurrentNamespaces)
Process an extension-element-prefixes attribute.
XalanVector< Namespace > NamespacesVectorType
Xalan implementation of deque.
Xalan implementation of a hashtable.
Definition XalanMap.hpp:187