/usr/include/xalanc/XSLT/NamespacesHandler.hpp is in libxalan-c-dev 1.11-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if !defined(XALAN_NAMESPACESHANDLER_HEADER_GUARD)
#define XALAN_NAMESPACESHANDLER_HEADER_GUARD
// Base include file. Must be first.
#include <xalanc/XSLT/XSLTDefinitions.hpp>
#include <xalanc/Include/XalanVector.hpp>
#include <xalanc/Include/XalanMap.hpp>
#include <xalanc/PlatformSupport/DOMStringHelper.hpp>
#include <xalanc/XPath/NameSpace.hpp>
#include <xalanc/XPath/XalanQName.hpp>
XALAN_CPP_NAMESPACE_BEGIN
class StylesheetConstructionContext;
class StylesheetExecutionContext;
class XALAN_XSLT_EXPORT NamespacesHandler
{
public:
class PrefixChecker
{
public:
PrefixChecker();
virtual
~PrefixChecker();
virtual bool
isActive(const XalanDOMString& thePrefix) const = 0;
};
class XALAN_XSLT_EXPORT Namespace
{
public:
Namespace() :
m_prefix(&s_emptyString),
m_uri(&s_emptyString)
{
}
Namespace(
const XalanDOMString& prefix,
const XalanDOMString& uri) :
m_prefix(&prefix),
m_uri(&uri)
{
}
/**
* Retrieve the prefix for namespace
*
* @return prefix string
*/
const XalanDOMString&
getPrefix() const
{
assert(m_prefix != 0);
return *m_prefix;
}
/**
* Set the prefix for namespace
*
* @param prefix The new prefix value
*/
void
setPrefix(const XalanDOMString& prefix)
{
m_prefix = &prefix;
}
/**
* Retrieve the URI for namespace
*
* @return URI string
*/
const XalanDOMString&
getURI() const
{
assert(m_uri != 0);
return *m_uri;
}
/**
* Set the URI for namespace
*
* @param uri The new uri value
*/
void
setURI(const XalanDOMString& uri)
{
m_uri = &uri;
}
protected:
static const XalanDOMString s_emptyString;
private:
const XalanDOMString* m_prefix;
const XalanDOMString* m_uri;
};
class XALAN_XSLT_EXPORT NamespaceExtended : public Namespace
{
public:
NamespaceExtended() :
Namespace(),
m_resultAttributeName(&s_emptyString)
{
}
NamespaceExtended(
const XalanDOMString& prefix,
const XalanDOMString& uri) :
Namespace(prefix, uri),
m_resultAttributeName(&s_emptyString)
{
}
/**
* Retrieve the name of the result attribute.
*
* @return name string
*/
const XalanDOMString&
getResultAttributeName() const
{
assert(m_resultAttributeName != 0);
return *m_resultAttributeName;
}
/**
* Set the name of the result attribute.
*
* @param name The new name value
*/
void
setResultAttributeName(const XalanDOMString& name)
{
m_resultAttributeName = &name;
}
private:
const XalanDOMString* m_resultAttributeName;
};
typedef XalanQName::NamespaceVectorType NamespaceVectorType;
typedef XalanQName::NamespacesStackType NamespacesStackType;
typedef XalanVector<Namespace> NamespacesVectorType;
typedef XalanVector<NamespaceExtended> NamespaceExtendedVectorType;
typedef XalanVector<const XalanDOMString*> XalanDOMStringPointerVectorType;
typedef XalanMap<const XalanDOMString*,
const XalanDOMString*> NamespaceAliasesMapType;
/**
* Create a default, empty instance.
*/
explicit
NamespacesHandler(MemoryManager& theManager);
/**
* Create an instance namespace handler using the
* current namespaces in effect.
*
* @param theConstructionContext The current construction context.
* @param stylesheetNamespacesHandler The stylesheet's handler.
* @param theCurrentNamespaces The stack of active namespace declarations.
* @param theXSLTNamespaceURI The namespace URI for XSLT.
*/
NamespacesHandler(
StylesheetConstructionContext& theConstructionContext,
const NamespacesHandler& stylesheetNamespacesHandler,
const NamespacesStackType& theCurrentNamespaces,
const XalanDOMString& theXSLTNamespaceURI);
~NamespacesHandler();
/**
* Process an exclude-result-prefixes attribute.
*
* @param theConstructionContext The current construction context.
* @param theValue The attribute's value.
* @param theCurrentNamespaces The stack of active namespace declarations.
*/
void
processExcludeResultPrefixes(
StylesheetConstructionContext& theConstructionContext,
const XalanDOMChar* theValue,
const NamespacesStackType& theCurrentNamespaces);
/**
* Process an extension-element-prefixes attribute.
*
* @param theConstructionContext The current construction context.
* @param theValue The attribute's value.
* @param theCurrentNamespaces The stack of active namespace declarations.
*/
void
processExtensionElementPrefixes(
StylesheetConstructionContext& theConstructionContext,
const XalanDOMChar* theValue,
const NamespacesStackType& theCurrentNamespaces);
/**
* Notify the instance that the stylesheet is fully constructed.
*
* @param theConstructionContext The current construction context.
* @param fProcessNamespaceAliases If true, process any namespace aliases
* @param theElementName The name of the owning element.
* @param parentNamespacesHandler The parent handler, if any.
* @param prefixChecker A pointer to a PrefixChecker instance to use, if any.
*/
void
postConstruction(
StylesheetConstructionContext& theConstructionContext,
bool fProcessNamespaceAliases = true,
const XalanDOMString& theElementName = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
const NamespacesHandler* parentNamespacesHandler = 0,
const PrefixChecker* prefixChecker = 0);
NamespacesHandler&
operator=(const NamespacesHandler& theRHS);
/**
* Determine of a given namespace should be excluded.
*
* @param theXSLTNamespaceURI The namespace URI for XSLT.
* @param theURI The namespace URI.
* @return true of the namespace should be excluded, false if not.
*/
bool
shouldExcludeResultNamespaceNode(
const XalanDOMString& theXSLTNamespaceURI,
const XalanDOMString& theURI) const;
/**
* Add a URI as an extension namespace prefixes.
*
* @param theConstructionContext The current construction context.
* @param theURI The namespace URI.
*/
void
addExtensionNamespaceURI(
StylesheetConstructionContext& theConstructionContext,
const XalanDOMString& theURI);
/**
* Get the namespace URI for the given prefix.
*
* @param thePrefix The namespace prefix.
* @return The namespace URI
*/
const XalanDOMString*
getNamespace(const XalanDOMString& thePrefix) const;
/**
* Get the namespace alias URI for the given namespace.
*
* @param theStylesheetNamespace The namespace as declared in the stylesheet.
* @return The namespace alias URI
*/
const XalanDOMString*
getNamespaceAlias(const XalanDOMString& theStylesheetNamespace) const;
/**
* Set the namespace alias URI for the given namespace.
*
* @param theConstructionContext The current construction context.
* @param theStylesheetNamespace The namespace as declared in the stylesheet.
* @param theResultNamespace The namespace as it should appear in the result tree.
*/
void
setNamespaceAlias(
StylesheetConstructionContext& theConstructionContext,
const XalanDOMString& theStylesheetNamespace,
const XalanDOMString& theResultNamespace);
/**
* Copy the aliases from the given NamespacesHandler.
*
* @param parentNamespacesHandler The parent handler.
*/
void
copyNamespaceAliases(const NamespacesHandler& parentNamespacesHandler);
/**
* Output the result tree namespace declarations.
*
* @param theExecutionContext The current execution context.
* @param supressDefault If true, any default namespace declaration will not be output.
*/
void
outputResultNamespaces(
StylesheetExecutionContext& theExecutionContext,
bool supressDefault = false) const;
/**
* Clear out the handler.
*/
void
clear();
/**
* Swap the contents of this instance with another.
*
* @param theOther The other instance.
*/
void
swap(NamespacesHandler& theOther);
NamespaceExtendedVectorType::size_type
getNamespaceDeclarationsCount() const
{
return m_namespaceDeclarations.size();
}
private:
/**
* Create all of the result attribute names.
*
* @param theConstructionContext The current construction context.
*/
void
createResultAttributeNames(StylesheetConstructionContext& theConstructionContext);
/**
* Process the exclude result prefix data.
*
* @param theConstructionContext The current construction context.
* @param theElementPrefix The prefix of the owning element.
* @param prefixChecker A pointer to a PrefixChecker instance to use, if any.
*/
void
processExcludeResultPrefixes(
StylesheetConstructionContext& theConstructionContext,
const XalanDOMString& theElementPrefix,
const PrefixChecker* prefixChecker);
/**
* Process the namespace aliases data.
*/
void
processNamespaceAliases();
/**
* Copy the contents of the supplied map
*
* @param theNamespaceAliases The map to copy.
*/
void
copyNamespaceAliases(const NamespaceAliasesMapType& theNamespaceAliases);
/**
* Copy the contents of the supplied vector
*
* @param theExtensionNamespaceURIs The set to copy.
*/
void
copyExtensionNamespaceURIs(const XalanDOMStringPointerVectorType& theExtensionNamespaceURIs);
/**
* Copy the contents of the supplied vector
*
* @param theExcludeResultPrefixes The vector to copy.
*/
void
copyExcludeResultPrefixes(const NamespacesVectorType& theExcludeResultPrefixes);
/**
* Determine if a given namespace should be excluded as a result of
* an exclude-result-prefixes declaration.
*
* @param theNamespaceURI The namespace URI to check.
* @return true if the namespace should be excluded, false if not.
*/
bool
isExcludedNamespaceURI(const XalanDOMString& theNamespaceURI) const;
/**
* Determine if a given URI is an extension namespace URI
*
* @param theNamespaceURI The namespace URI to check.
* @return true if the namespace uri is an extension namespace URI, false if not.
*/
bool
isExtensionNamespaceURI(const XalanDOMString& theNamespaceURI) const
{
return findString(theNamespaceURI, m_extensionNamespaceURIs);
}
/**
* Determine if a given string is present in the vector
*
* @param theString The string to find.
* @return true if the string is present, false if not.
*/
static bool
findString(
const XalanDOMString& theString,
const XalanDOMStringPointerVectorType& theVector);
// Not implemented...
bool
operator==(const NamespacesHandler&) const;
// Data members...
NamespacesVectorType m_excludedResultPrefixes;
NamespaceExtendedVectorType m_namespaceDeclarations;
XalanDOMStringPointerVectorType m_extensionNamespaceURIs;
NamespaceAliasesMapType m_namespaceAliases;
};
XALAN_CPP_NAMESPACE_END
#endif // XALAN_NAMESPACESHANDLER_HEADER_GUARD
|