michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef __TX_I_XPATH_CONTEXT michael@0: #define __TX_I_XPATH_CONTEXT michael@0: michael@0: #include "txCore.h" michael@0: michael@0: class FunctionCall; michael@0: class nsIAtom; michael@0: class txAExprResult; michael@0: class txResultRecycler; michael@0: class txXPathNode; michael@0: michael@0: /* michael@0: * txIParseContext michael@0: * michael@0: * This interface describes the context needed to create michael@0: * XPath Expressions and XSLT Patters. michael@0: * (not completely though. key() requires the ProcessorState, which is michael@0: * not part of this interface.) michael@0: */ michael@0: michael@0: class txIParseContext michael@0: { michael@0: public: michael@0: virtual ~txIParseContext() michael@0: { michael@0: } michael@0: michael@0: /* michael@0: * Return a namespaceID for a given prefix. michael@0: */ michael@0: virtual nsresult resolveNamespacePrefix(nsIAtom* aPrefix, int32_t& aID) = 0; michael@0: michael@0: /* michael@0: * Create a FunctionCall, needed for extension function calls and michael@0: * XSLT. XPath function calls are resolved by the Parser. michael@0: */ michael@0: virtual nsresult resolveFunctionCall(nsIAtom* aName, int32_t aID, michael@0: FunctionCall** aFunction) = 0; michael@0: michael@0: /** michael@0: * Should nametests parsed in this context be case-sensitive michael@0: */ michael@0: virtual bool caseInsensitiveNameTests() = 0; michael@0: michael@0: /* michael@0: * Callback to be used by the Parser if errors are detected. michael@0: */ michael@0: virtual void SetErrorOffset(uint32_t aOffset) = 0; michael@0: }; michael@0: michael@0: /* michael@0: * txIMatchContext michael@0: * michael@0: * Interface used for matching XSLT Patters. michael@0: * This is the part of txIEvalContext (see below), that is independent michael@0: * of the context node when evaluating a XPath expression, too. michael@0: * When evaluating a XPath expression, |txIMatchContext|s are used michael@0: * to transport the information from Step to Step. michael@0: */ michael@0: class txIMatchContext michael@0: { michael@0: public: michael@0: virtual ~txIMatchContext() michael@0: { michael@0: } michael@0: michael@0: /* michael@0: * Return the ExprResult associated with the variable with the michael@0: * given namespace and local name. michael@0: */ michael@0: virtual nsresult getVariable(int32_t aNamespace, nsIAtom* aLName, michael@0: txAExprResult*& aResult) = 0; michael@0: michael@0: /* michael@0: * Is whitespace stripping allowed for the given node? michael@0: * See http://www.w3.org/TR/xslt#strip michael@0: */ michael@0: virtual bool isStripSpaceAllowed(const txXPathNode& aNode) = 0; michael@0: michael@0: /** michael@0: * Returns a pointer to the private context michael@0: */ michael@0: virtual void* getPrivateContext() = 0; michael@0: michael@0: virtual txResultRecycler* recycler() = 0; michael@0: michael@0: /* michael@0: * Callback to be used by the expression/pattern if errors are detected. michael@0: */ michael@0: virtual void receiveError(const nsAString& aMsg, nsresult aRes) = 0; michael@0: }; michael@0: michael@0: #define TX_DECL_MATCH_CONTEXT \ michael@0: nsresult getVariable(int32_t aNamespace, nsIAtom* aLName, \ michael@0: txAExprResult*& aResult); \ michael@0: bool isStripSpaceAllowed(const txXPathNode& aNode); \ michael@0: void* getPrivateContext(); \ michael@0: txResultRecycler* recycler(); \ michael@0: void receiveError(const nsAString& aMsg, nsresult aRes) michael@0: michael@0: class txIEvalContext : public txIMatchContext michael@0: { michael@0: public: michael@0: /* michael@0: * Get the context node. michael@0: */ michael@0: virtual const txXPathNode& getContextNode() = 0; michael@0: michael@0: /* michael@0: * Get the size of the context node set. michael@0: */ michael@0: virtual uint32_t size() = 0; michael@0: michael@0: /* michael@0: * Get the position of the context node in the context node set, michael@0: * starting with 1. michael@0: */ michael@0: virtual uint32_t position() = 0; michael@0: }; michael@0: michael@0: #define TX_DECL_EVAL_CONTEXT \ michael@0: TX_DECL_MATCH_CONTEXT; \ michael@0: const txXPathNode& getContextNode(); \ michael@0: uint32_t size(); \ michael@0: uint32_t position() michael@0: michael@0: #endif // __TX_I_XPATH_CONTEXT