/usr/include/xalanc/XPath/XPathExecutionContext.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 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 | /*
* 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(XPATHEXECUTIONCONTEXT_HEADER_GUARD_1357924680)
#define XPATHEXECUTIONCONTEXT_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <xalanc/XPath/XPathDefinitions.hpp>
#include <cassert>
#include <xalanc/Include/XalanVector.hpp>
#include <xalanc/XalanDOM/XalanDOMString.hpp>
// Base class header file...
#include <xalanc/PlatformSupport/ExecutionContext.hpp>
#include <xalanc/XPath/MutableNodeRefList.hpp>
XALAN_DECLARE_XERCES_CLASS(ErrorHandler)
XALAN_CPP_NAMESPACE_BEGIN
class XalanDecimalFormatSymbols;
class PrefixResolver;
class XalanQName;
class XObject;
class XObjectPtr;
class XObjectFactory;
class XalanDocument;
class XalanElement;
class XalanNode;
class XalanText;
XALAN_USING_XERCES(ErrorHandler)
//
// An abstract class which provides support for executing XPath functions
// and extension functions.
//
class XALAN_XPATH_EXPORT XPathExecutionContext : public ExecutionContext
{
public:
typedef XalanVector<XObjectPtr> XObjectArgVectorType;
typedef NodeRefListBase::size_type size_type;
explicit
XPathExecutionContext(
MemoryManager& theMemoryManager,
XObjectFactory* theXObjectFactory = 0);
virtual
~XPathExecutionContext();
/**
* Reset the instance. This must be called before another
* execution is attempted.
*/
virtual void
reset() = 0;
/**
* Retrieve the node currently being executed.
*
* @return current node
*/
virtual XalanNode*
getCurrentNode() const = 0;
/**
* Change the node currently being executed.
*
* @param theCurrentNode new current node
*/
virtual void
pushCurrentNode(XalanNode* theCurrentNode) = 0;
/**
* Reset the node currently being executed.
*/
virtual void
popCurrentNode() = 0;
class CurrentNodePushAndPop
{
public:
CurrentNodePushAndPop(
XPathExecutionContext& theExecutionContext,
XalanNode* theNewNode) :
m_executionContext(theExecutionContext)
{
theExecutionContext.pushCurrentNode(theNewNode);
}
~CurrentNodePushAndPop()
{
m_executionContext.popCurrentNode();
}
private:
XPathExecutionContext& m_executionContext;
};
/**
* Retrieve the factory object for creating XObjects.
*
* @return factory object instance
*/
XObjectFactory&
getXObjectFactory() const
{
assert(m_xobjectFactory != 0);
return *m_xobjectFactory;
}
/**
* Determine if a node is after another node, in document order.
*
* @param node1 The first node
* @param node2 The second node
* @return true if node1 one is after node2, or false if it is not.
*/
virtual bool
isNodeAfter(
const XalanNode& node1,
const XalanNode& node2) const = 0;
/**
* Push the node list for current context.
*
* @param theList new node list
*/
virtual void
pushContextNodeList(const NodeRefListBase& theList) = 0;
/**
* Pop the node list for current context.
*/
virtual void
popContextNodeList() = 0;
class ContextNodeListPushAndPop
{
public:
ContextNodeListPushAndPop(
XPathExecutionContext& theExecutionContext,
const NodeRefListBase& theNodeList) :
m_executionContext(theExecutionContext)
{
m_executionContext.pushContextNodeList(theNodeList);
}
~ContextNodeListPushAndPop()
{
m_executionContext.popContextNodeList();
}
private:
XPathExecutionContext& m_executionContext;
};
/**
* Get the node list for current context.
*
* @return node list
*/
virtual const NodeRefListBase&
getContextNodeList() const = 0;
/*
* Get the count of nodes in the current context node list.
*
* @return length of list
*/
virtual size_type
getContextNodeListLength() const = 0;
/*
* Get the position of the node in the current context node list.
* Note that this is 1-based indexing (XPath/XSLT-style), not 0-based.
* Thus, 0 will be returned if the node was not found.
*
* @return position in list
*/
virtual size_type
getContextNodeListPosition(const XalanNode& contextNode) const = 0;
/**
* Determine if an external element is available.
*
* @param theQName The QName of the element
*
* @return whether the given element is available or not
*/
virtual bool
elementAvailable(const XalanQName& theQName) const = 0;
/**
* Determine if an external element is available by resolving
* a string to a QName.
*
* @param theName The name of the element
* @param locator A Locator instance for error reporting
*
* @return whether the given element is available or not
*/
virtual bool
elementAvailable(
const XalanDOMString& theName,
const Locator* locator) const = 0;
/**
* Determine if a function is available.
*
* @param theQName The QName of the function
*
* @return whether the function is available or not
*/
virtual bool
functionAvailable(const XalanQName& theQName) const = 0;
/**
* Determine if a function is available.
*
* @param theName The name of the function
* @param locator A Locator instance for error reporting
*
* @return whether the function is available or not
*/
virtual bool
functionAvailable(
const XalanDOMString& theName,
const Locator* locator) const = 0;
/**
* Handle an extension function.
*
* @param theNamespace namespace of function
* @param functionName extension function name
* @param context The context node
* @param argVec vector of arguments to function
* @param locator A Locator instance for error reporting
* @return pointer to XObject result
*/
virtual const XObjectPtr
extFunction(
const XalanDOMString& theNamespace,
const XalanDOMString& functionName,
XalanNode* context,
const XObjectArgVectorType& argVec,
const Locator* locator) = 0;
/**
* Provides support for XML parsing service.
*
* @param theManager The MemoryManager instance to use.
* @param urlString location of the XML
* @param base base location for URI
* @param theErrorHandler An optional ErrorHandler instance for error reporting.
* @return parsed document
*/
virtual XalanDocument*
parseXML(
MemoryManager& theManager,
const XalanDOMString& urlString,
const XalanDOMString& base,
ErrorHandler* theErrorHandler = 0) const = 0;
/**
* Borrow a cached MutableNodeRefList instance.
*
* @return A pointer to the instance.
*/
virtual MutableNodeRefList*
borrowMutableNodeRefList() = 0;
/**
* Return a previously borrowed MutableNodeRefList instance.
*
* @param theList A pointer the to previously borrowed instance.
* @return true if the list was borrowed (at therefore, destroyed), false if not.
*/
virtual bool
returnMutableNodeRefList(MutableNodeRefList* theList) = 0;
class GetCachedNodeList
{
public:
GetCachedNodeList(XPathExecutionContext& executionContext) :
m_xpathExecutionContext(&executionContext),
m_mutableNodeRefList(executionContext.borrowMutableNodeRefList())
{
assert(m_mutableNodeRefList != 0);
}
// N.B. Non-const copy constructor semantics (like std::auto_ptr)
GetCachedNodeList(const GetCachedNodeList& theSource) :
m_xpathExecutionContext(theSource.m_xpathExecutionContext),
m_mutableNodeRefList(theSource.m_mutableNodeRefList)
{
assert(m_mutableNodeRefList != 0);
((BorrowReturnMutableNodeRefList&)theSource).m_mutableNodeRefList = 0;
}
~GetCachedNodeList()
{
release();
}
MutableNodeRefList&
operator*() const
{
assert(m_mutableNodeRefList != 0);
return *m_mutableNodeRefList;
}
MutableNodeRefList*
get() const
{
return m_mutableNodeRefList;
}
MutableNodeRefList*
operator->() const
{
return get();
}
void
release()
{
assert(m_xpathExecutionContext != 0);
if (m_mutableNodeRefList != 0)
{
m_xpathExecutionContext->returnMutableNodeRefList(m_mutableNodeRefList);
m_mutableNodeRefList = 0;
}
}
GetCachedNodeList
clone() const
{
assert(m_xpathExecutionContext != 0);
GetCachedNodeList theResult(*m_xpathExecutionContext);
*theResult = *m_mutableNodeRefList;
return theResult;
}
// N.B. Non-const assignment operator semantics.
GetCachedNodeList&
operator=(GetCachedNodeList& theRHS)
{
release();
m_xpathExecutionContext = theRHS.m_xpathExecutionContext;
m_mutableNodeRefList = theRHS.m_mutableNodeRefList;
theRHS.m_mutableNodeRefList = 0;
return *this;
}
private:
XPathExecutionContext* m_xpathExecutionContext;
MutableNodeRefList* m_mutableNodeRefList;
};
typedef GetCachedNodeList BorrowReturnMutableNodeRefList;
/**
* Get a cached string for temporary use.
*
* @return A reference to the string
*/
virtual XalanDOMString&
getCachedString() = 0;
/**
* Return a cached string.
*
* @param theString The string to release.
*
* @return true if the string was released successfully.
*/
virtual bool
releaseCachedString(XalanDOMString& theString) = 0;
class GetCachedString
{
public:
GetCachedString(XPathExecutionContext& theExecutionContext) :
m_executionContext(&theExecutionContext),
m_string(&theExecutionContext.getCachedString())
{
}
// Note non-const copy semantics...
GetCachedString(GetCachedString& theSource) :
m_executionContext(theSource.m_executionContext),
m_string(theSource.m_string)
{
theSource.m_string = 0;
}
~GetCachedString()
{
if (m_string != 0)
{
m_executionContext->releaseCachedString(*m_string);
}
}
XalanDOMString&
get() const
{
assert(m_string != 0);
return *m_string;
}
XPathExecutionContext&
getExecutionContext() const
{
return *m_executionContext;
}
private:
// Not implemented...
GetCachedString();
GetCachedString(const GetCachedString&);
GetCachedString&
operator=(const GetCachedString&);
// Data members...
XPathExecutionContext* m_executionContext;
XalanDOMString* m_string;
};
typedef GetCachedString GetAndReleaseCachedString;
/**
* Create a MutableNodeRefList with the appropriate context.
*
* @return pointer to node list created
*/
virtual MutableNodeRefList*
createMutableNodeRefList(MemoryManager& theManager) const = 0;
/**
* Given a valid element key, return the corresponding node list.
*
* @param context context node
* @param name qname of the key, which must match the 'name'
* attribute on xsl:key
* @param ref value that must match the value found by the
* 'match' attribute on xsl:key
* @param locator The Locator to use for error reporting. Can be 0.
* @param nodelist A node list to contain the nodes found
*/
virtual void
getNodeSetByKey(
XalanNode* context,
const XalanQName& qname,
const XalanDOMString& ref,
const Locator* locator,
MutableNodeRefList& nodelist) = 0;
/**
* Given a valid element key, return the corresponding node list.
*
* @param context context node
* @param name name of the key, which must match the 'name'
* attribute on xsl:key. Will be resolved to a
* qname using the provided resolver.
* @param ref value that must match the value found by the
* 'match' attribute on xsl:key
* @param locator The Locator to use for error reporting. Can be 0.
* @param nodelist A node list to contain the nodes found
*/
virtual void
getNodeSetByKey(
XalanNode* context,
const XalanDOMString& name,
const XalanDOMString& ref,
const Locator* locator,
MutableNodeRefList& nodelist) = 0;
/**
* Given a name, locate a variable in the current context, and return
* a pointer to the object.
*
* @param theName name of variable
* @return An XObjectPtr instance. If the variable is not found, an exception
* is thrown, or the routine returns an instance of XUnknown.
*/
virtual const XObjectPtr
getVariable(
const XalanQName& name,
const Locator* locator = 0) = 0;
/**
* Retrieve the resolver for namespaces.
*
* @return object for namespace resolution
*/
virtual const PrefixResolver*
getPrefixResolver() const = 0;
/**
* Change the resolver for namespaces.
*
* @param thePrefixResolver new object for namespace resolution
*/
virtual void
setPrefixResolver(const PrefixResolver* thePrefixResolver) = 0;
class PrefixResolverSetAndRestore
{
public:
PrefixResolverSetAndRestore(
XPathExecutionContext& theExecutionContext,
const PrefixResolver* theResolver) :
m_executionContext(theExecutionContext),
m_savedResolver(theExecutionContext.getPrefixResolver())
{
m_executionContext.setPrefixResolver(theResolver);
}
PrefixResolverSetAndRestore(
XPathExecutionContext& theExecutionContext,
const PrefixResolver* theOldResolver,
const PrefixResolver* theNewResolver) :
m_executionContext(theExecutionContext),
m_savedResolver(theOldResolver)
{
m_executionContext.setPrefixResolver(theNewResolver);
}
~PrefixResolverSetAndRestore()
{
m_executionContext.setPrefixResolver(m_savedResolver);
}
private:
XPathExecutionContext& m_executionContext;
const PrefixResolver* const m_savedResolver;
};
/**
* Retrieve the URI corresponding to a namespace prefix
*
* @param prefix prefix for a namespace
* @return URI corresponding to namespace
*/
virtual const XalanDOMString*
getNamespaceForPrefix(const XalanDOMString& prefix) const = 0;
/**
* Given a DOM Document, tell what URI was used to parse it. Needed for
* relative resolution.
*
* @param owner source document
* @return document URI
*/
virtual const XalanDOMString&
findURIFromDoc(const XalanDocument* owner) const = 0;
/**
* The getUnparsedEntityURI function returns the URI of the unparsed
* entity with the specified name in the same document as the context
* node (see [3.3 Unparsed Entities]). It returns the empty string if
* there is no such entity.
*
* @param theName name of entity
* @param theDocument document containing entity
* @return URI for the entity
*/
virtual const XalanDOMString&
getUnparsedEntityURI(
const XalanDOMString& theName,
const XalanDocument& theDocument) const = 0;
/**
* Get the document associated with the given URI.
*
* @param theURI document URI
* @return a pointer to the document instance, if any.
*/
virtual XalanDocument*
getSourceDocument(const XalanDOMString& theURI) const = 0;
/**
* Associate a document with a given URI.
*
* @param theURI document URI
* @param theDocument source document
*/
virtual void
setSourceDocument(
const XalanDOMString& theURI,
XalanDocument* theDocument) = 0;
/**
* Formats a number according to the specified pattern.
*
* @param number the number to be formatted
* @param pattern the format pattern
* @param theResult the formatted number
* @param context the source node
* @param locator the locator
*/
virtual void formatNumber(
double number,
const XalanDOMString& pattern,
XalanDOMString& theResult,
const XalanNode* context = 0,
const Locator* locator = 0) = 0;
/**
* Formats a number according to the specified pattern.
*
* @param number the number to be formatted
* @param pattern the format pattern
* @param dfsName the name of decimal format to use
* @param theResult the formatted number
* @param context the source node
* @param locator the locator
* @return a pointer to the functor, 0 if none was found
*/
virtual void formatNumber(
double number,
const XalanDOMString& pattern,
const XalanDOMString& dfsName,
XalanDOMString& theResult,
const XalanNode* context = 0,
const Locator* locator = 0) = 0;
// These interfaces are inherited from ExecutionContext...
virtual void
problem(
eSource source,
eClassification classification,
const XalanDOMString& msg,
const Locator* locator,
const XalanNode* sourceNode) = 0;
virtual void
problem(
eSource source,
eClassification classification,
const XalanDOMString& msg,
const XalanNode* sourceNode) = 0;
virtual bool
shouldStripSourceNode(const XalanText& node) = 0;
protected:
XObjectFactory* m_xobjectFactory;
};
XALAN_CPP_NAMESPACE_END
#endif // XPATHEXECUTIONCONTEXT_HEADER_GUARD_1357924680
|