| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.sxpath; |
| 9 | |
| 10 | import net.sf.saxon.expr.StaticContext; |
| 11 | import net.sf.saxon.expr.instruct.SlotManager; |
| 12 | import net.sf.saxon.om.NamespaceResolver; |
| 13 | import net.sf.saxon.value.QNameValue; |
| 14 | |
| 15 | /** |
| 16 | * This interface defines methods that must be provided when Saxon's free-standing XPath API is used. |
| 17 | * The default implementation of this interface is {@link net.sf.saxon.sxpath.IndependentContext}, and |
| 18 | * that implementation should be adequate for most purposes; but for extra customization, a user-written |
| 19 | * implementation of this interface may be used instead. |
| 20 | */ |
| 21 | public interface XPathStaticContext extends StaticContext { |
| 22 | |
| 23 | /** |
| 24 | * Set the default namespace for elements and types |
| 25 | * |
| 26 | * @param uri The namespace to be used to qualify unprefixed element names and type names appearing |
| 27 | * in the XPath expression. |
| 28 | */ |
| 29 | |
| 30 | public void setDefaultElementNamespace(String uri); |
| 31 | |
| 32 | /** |
| 33 | * Set an external namespace resolver. If this is set, then all resolution of namespace |
| 34 | * prefixes is delegated to the external namespace resolver, and namespaces declared |
| 35 | * individually on this IndependentContext object are ignored. |
| 36 | * |
| 37 | * @param resolver the external namespace resolver |
| 38 | */ |
| 39 | |
| 40 | public void setNamespaceResolver(NamespaceResolver resolver); |
| 41 | |
| 42 | /** |
| 43 | * Declare a variable. A variable must be declared before an expression referring |
| 44 | * to it is compiled. The initial value of the variable will be the empty sequence. |
| 45 | * |
| 46 | * @param qname The name of the variable |
| 47 | * @return a Variable object representing information about the variable that has been |
| 48 | * declared. |
| 49 | */ |
| 50 | |
| 51 | public XPathVariable declareVariable(QNameValue qname); |
| 52 | |
| 53 | /** |
| 54 | * Declare a variable. A variable must be declared before an expression referring |
| 55 | * to it is compiled. The initial value of the variable will be the empty sequence. |
| 56 | * |
| 57 | * @param namespaceURI The namespace URI of the name of the variable. Supply "" to represent |
| 58 | * names in no namespace (null is also accepted) |
| 59 | * @param localName The local part of the name of the variable (an NCName) |
| 60 | * @return an XPathVariable object representing information about the variable that has been |
| 61 | * declared. |
| 62 | */ |
| 63 | |
| 64 | public XPathVariable declareVariable(String namespaceURI, String localName); |
| 65 | |
| 66 | /** |
| 67 | * Get a Stack Frame Map containing definitions of all the declared variables. This will return a newly |
| 68 | * created object that the caller is free to modify by adding additional variables, without affecting |
| 69 | * the static context itself. |
| 70 | * |
| 71 | * @return a SlotManager object holding details of the allocation of variables on the stack frame. |
| 72 | */ |
| 73 | |
| 74 | public SlotManager getStackFrameMap(); |
| 75 | |
| 76 | |
| 77 | } |
| 78 |