Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sf.saxon.trans
Class IndependentContext

    java.lang.Object
      net.sf.saxon.trans.IndependentContext

All Implemented Interfaces:
  NamespaceResolver, java.io.Serializable, StaticContext

public class IndependentContext
extends java.lang.Object
implements StaticContext, NamespaceResolver, java.io.Serializable

An IndependentContext provides a context for parsing an expression or pattern appearing in a context other than a stylesheet. This class was formerly named StandaloneContext. It has forked from that class, so that StandaloneContext could be changed to meet the demands of the JAXP 1.3 XPath API.

See Also:
  Serialized Form

Constructor Summary
`IndependentContext()`
`IndependentContext(Configuration config)` Create an IndependentContext using a specific Configuration

Method Summary
`VariableReference` | `bindVariable(int fingerprint)` Bind a variable used in an XPath Expression to the XSLVariable element in which it is declared.
`void` | `clearAllNamespaces()` Clear all the declared namespaces, including the standard ones (xml, xslt, saxon).
`void` | `clearNamespaces()` Clear all the declared namespaces, except for the standard ones (xml, xslt, saxon, xdt)
`IndependentContext` | `copy()` Create a copy of this IndependentContext.
`void` | `declareCollation(java.lang.String name, java.util.Comparator comparator, boolean isDefault)` Declare a named collation
`void` | `declareNamespace(java.lang.String prefix, java.lang.String uri)` Declare a namespace whose prefix can be used in expressions
`Variable` | `declareVariable(QNameValue qname)` Declare a variable.
`Variable` | `declareVariable(java.lang.String qname)` Declare a variable.
`java.lang.String` | `getBaseURI()` Get the Base URI of the stylesheet element, for resolving any relative URI's used in the expression.
`java.util.Comparator` | `getCollation(java.lang.String name)` Get a named collation.
`Configuration` | `getConfiguration()` Get the system configuration
`java.lang.String` | `getDefaultCollationName()` Get the name of the default collation.
`short` | `getDefaultElementNamespace()` Get the default XPath namespace, as a namespace code that can be looked up in the NamePool
`java.lang.String` | `getDefaultFunctionNamespace()` Get the default function namespace
`FunctionLibrary` | `getFunctionLibrary()` Get the function library containing all the in-scope functions available in this static context
`java.util.Set` | `getImportedSchemaNamespaces()` Get the set of imported schemas
`int` | `getLineNumber()` Get the line number of the expression within that container.
`LocationMap` | `getLocationMap()` Get the location map.
`NamePool` | `getNamePool()` Get the NamePool used for compiling expressions
`NamespaceResolver` | `getNamespaceResolver()` Get a namespace resolver to resolve the namespaces declared in this static context.
`int` | `getSlotNumber(QNameValue qname)` Get the slot number allocated to a particular variable
`SlotManager` | `getStackFrameMap()` Get the stack frame map containing the slot number allocations for the variables declared in this static context
`java.lang.String` | `getSystemId()` Get the system ID of the container of the expression.
`java.lang.String` | `getURIForPrefix(java.lang.String prefix)` Get the URI for a prefix, using the declared namespaces as the context for namespace resolution.
`java.lang.String` | `getURIForPrefix(java.lang.String prefix, boolean useDefault)` Get the namespace URI corresponding to a given prefix.
`boolean` | `isAllowedBuiltInType(AtomicType type)` Determine whether a built-in type is available in this context.
`boolean` | `isImportedSchema(java.lang.String namespace)` Determine whether a Schema for a given target namespace has been imported.
`boolean` | `isInBackwardsCompatibleMode()` Determine whether Backwards Compatible Mode is used
`void` | `issueWarning(java.lang.String s, javax.xml.transform.SourceLocator locator)` Issue a compile-time warning.
`java.util.Iterator` | `iteratePrefixes()` Get an iterator over all the prefixes declared in this namespace context.
`XPathContext` | `makeEarlyEvaluationContext()` Construct a dynamic context for early evaluation of constant subexpressions
`void` | `setBaseURI(java.lang.String baseURI)` Set the base URI in the static context
`void` | `setDefaultFunctionNamespace(java.lang.String uri)` Set the default function namespace
`void` | `setFunctionLibrary(FunctionLibrary lib)` Set the function library to be used
`void` | `setImportedSchemaNamespaces(java.util.Set namespaces)`
`void` | `setLocationMap(LocationMap locationMap)`
`void` | `setNamespaceResolver(NamespaceResolver resolver)` Set an external namespace resolver.
`void` | `setNamespaces(NodeInfo node)` Set all the declared namespaces to be the namespaces that are in-scope for a given node.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### IndependentContext

    public IndependentContext()

### IndependentContext

    public IndependentContext(Configuration config)

  Create an IndependentContext using a specific Configuration

Method Detail

### copy

    public IndependentContext copy()

  Create a copy of this IndependentContext. All aspects of the context are copied except for declared variables.

### getConfiguration

    public Configuration getConfiguration()

  Get the system configuration

  Specified by:
    `getConfiguration` in interface `StaticContext`

### makeEarlyEvaluationContext

    public XPathContext makeEarlyEvaluationContext()

  Construct a dynamic context for early evaluation of constant subexpressions

  Specified by:
    `makeEarlyEvaluationContext` in interface `StaticContext`

### getLocationMap

    public LocationMap getLocationMap()

  Description copied from interface: `StaticContext`
  Get the location map. This is a mapping from short location ids held with each expression or subexpression, to a fully-resolved location in a source stylesheet or query.

  Specified by:
    `getLocationMap` in interface `StaticContext`

### setLocationMap

    public void setLocationMap(LocationMap locationMap)

### declareNamespace

    public void declareNamespace(java.lang.String prefix,
                                 java.lang.String uri)

  Declare a namespace whose prefix can be used in expressions

  Parameters:
    `prefix` - The namespace prefix. Must not be null. Must not be the empty string ("") - unqualified names in an XPath expression always refer to the null namespace.
    `uri` - The namespace URI. Must not be null.

### clearNamespaces

    public void clearNamespaces()

  Clear all the declared namespaces, except for the standard ones (xml, xslt, saxon, xdt)

### clearAllNamespaces

    public void clearAllNamespaces()

  Clear all the declared namespaces, including the standard ones (xml, xslt, saxon). Leave only the XML namespace and the default namespace (xmlns="")

### setNamespaces

    public void setNamespaces(NodeInfo node)

  Set all the declared namespaces to be the namespaces that are in-scope for a given node. In addition, the standard namespaces (xml, xslt, saxon) are declared.

  Parameters:
    `node` - The node whose in-scope namespaces are to be used as the context namespaces. If the node is an attribute, text node, etc, then the namespaces of its parent element are used.

### setNamespaceResolver

    public void setNamespaceResolver(NamespaceResolver resolver)

  Set an external namespace resolver. If this is set, then all resolution of namespace prefixes is delegated to the external namespace resolver, and namespaces declared individually on this IndependentContext object are ignored.

### setBaseURI

    public void setBaseURI(java.lang.String baseURI)

  Set the base URI in the static context

### declareCollation

    public void declareCollation(java.lang.String name,
                                 java.util.Comparator comparator,
                                 boolean isDefault)

  Declare a named collation

  Parameters:
    `name` - The name of the collation (technically, a URI)
    `comparator` - The Java Comparator used to implement the collating sequence
    `isDefault` - True if this is to be used as the default collation

### getStackFrameMap

    public SlotManager getStackFrameMap()

  Get the stack frame map containing the slot number allocations for the variables declared in this static context

### declareVariable

    public Variable declareVariable(QNameValue qname)

  Declare a variable. A variable must be declared before an expression referring to it is compiled. The initial value of the variable will be the empty sequence

  Parameters:
    `qname` - The name of the variable

### declareVariable

    public Variable declareVariable(java.lang.String qname)
                             throws XPathException

  Declare a variable. A variable may be declared before an expression referring to it is compiled. Alternatively, a JAXP XPathVariableResolver may be supplied to perform the resolution. A variable that has been explicitly declared is used in preference.

  Parameters:
    `qname` - Lexical QName identifying the variable. The namespace prefix, if any, must have been declared before this method is called, or must be resolvable using the namespace context.
  Throws:
    `XPathException`

### getSlotNumber

    public int getSlotNumber(QNameValue qname)

  Get the slot number allocated to a particular variable

  Returns:
    the slot number, or -1 if the variable has not been declared

### getNamePool

    public NamePool getNamePool()

  Get the NamePool used for compiling expressions

  Specified by:
    `getNamePool` in interface `StaticContext`

### issueWarning

    public void issueWarning(java.lang.String s,
                             javax.xml.transform.SourceLocator locator)

  Issue a compile-time warning. This method is used during XPath expression compilation to output warning conditions. The default implementation writes the message to System.err. To change the destination of messages, create a subclass of StandaloneContext that overrides this method.

  Specified by:
    `issueWarning` in interface `StaticContext`

### getSystemId

    public java.lang.String getSystemId()

  Get the system ID of the container of the expression. Used to construct error messages.

  Specified by:
    `getSystemId` in interface `StaticContext`
  Returns:
    "" always

### getBaseURI

    public java.lang.String getBaseURI()

  Get the Base URI of the stylesheet element, for resolving any relative URI's used in the expression. Used by the document() function, resolve-uri(), etc.

  Specified by:
    `getBaseURI` in interface `StaticContext`
  Returns:
    "" if no base URI has been set

### getLineNumber

    public int getLineNumber()

  Get the line number of the expression within that container. Used to construct error messages.

  Specified by:
    `getLineNumber` in interface `StaticContext`
  Returns:
    -1 always

### getURIForPrefix

    public java.lang.String getURIForPrefix(java.lang.String prefix)
                                     throws XPathException

  Get the URI for a prefix, using the declared namespaces as the context for namespace resolution. The default namespace is NOT used when the prefix is empty. This method is provided for use by the XPath parser.

  Specified by:
    `getURIForPrefix` in interface `StaticContext`
  Parameters:
    `prefix` - The prefix
  Throws:
    `XPathException` - if the prefix is not declared

### getNamespaceResolver

    public NamespaceResolver getNamespaceResolver()

  Description copied from interface: `StaticContext`
  Get a namespace resolver to resolve the namespaces declared in this static context.

  Specified by:
    `getNamespaceResolver` in interface `StaticContext`
  Returns:
    a namespace resolver.

### getURIForPrefix

    public java.lang.String getURIForPrefix(java.lang.String prefix,
                                            boolean useDefault)

  Get the namespace URI corresponding to a given prefix. Return null if the prefix is not in scope.

  Specified by:
    `getURIForPrefix` in interface `NamespaceResolver`
  Parameters:
    `prefix` - the namespace prefix
    `useDefault` - true if the default namespace is to be used when the prefix is ""
  Returns:
    the uri for the namespace, or null if the prefix is not in scope. Return "" if the prefix maps to the null namespace.

### iteratePrefixes

    public java.util.Iterator iteratePrefixes()

  Get an iterator over all the prefixes declared in this namespace context. This will include the default namespace (prefix="") and the XML namespace where appropriate

  Specified by:
    `iteratePrefixes` in interface `NamespaceResolver`

### bindVariable

    public VariableReference bindVariable(int fingerprint)
                                   throws StaticError

  Bind a variable used in an XPath Expression to the XSLVariable element in which it is declared. This method is provided for use by the XPath parser, and it should not be called by the user of the API, or overridden, unless variables are to be declared using a mechanism other than the declareVariable method of this class.

  Specified by:
    `bindVariable` in interface `StaticContext`
  Parameters:
    `fingerprint` - the name of the variable
  Returns:
    a VariableReference representing the variable reference, suitably initialized to refer to the corresponding variable declaration
  Throws:
    `StaticError`

### getFunctionLibrary

    public FunctionLibrary getFunctionLibrary()

  Get the function library containing all the in-scope functions available in this static context

  Specified by:
    `getFunctionLibrary` in interface `StaticContext`

### setFunctionLibrary

    public void setFunctionLibrary(FunctionLibrary lib)

  Set the function library to be used

### getCollation

    public java.util.Comparator getCollation(java.lang.String name)

  Get a named collation.

  Specified by:
    `getCollation` in interface `StaticContext`
  Parameters:
    `name` - The name of the required collation. Supply null to get the default collation.
  Returns:
    the collation identified by the given name, as set previously using declareCollation. Return null if no collation with this name is found.

### getDefaultCollationName

    public java.lang.String getDefaultCollationName()

  Get the name of the default collation.

  Specified by:
    `getDefaultCollationName` in interface `StaticContext`
  Returns:
    the name of the default collation; or the name of the codepoint collation if no default collation has been defined

### getDefaultElementNamespace

    public short getDefaultElementNamespace()

  Get the default XPath namespace, as a namespace code that can be looked up in the NamePool

  Specified by:
    `getDefaultElementNamespace` in interface `StaticContext`

### setDefaultFunctionNamespace

    public void setDefaultFunctionNamespace(java.lang.String uri)

  Set the default function namespace

### getDefaultFunctionNamespace

    public java.lang.String getDefaultFunctionNamespace()

  Get the default function namespace

  Specified by:
    `getDefaultFunctionNamespace` in interface `StaticContext`

### isInBackwardsCompatibleMode

    public boolean isInBackwardsCompatibleMode()

  Determine whether Backwards Compatible Mode is used

  Specified by:
    `isInBackwardsCompatibleMode` in interface `StaticContext`
  Returns:
    false; XPath 1.0 compatibility mode is not supported in the standalone XPath API

### isImportedSchema

    public boolean isImportedSchema(java.lang.String namespace)

  Description copied from interface: `StaticContext`
  Determine whether a Schema for a given target namespace has been imported. Note that the in-scope element declarations, attribute declarations and schema types are the types registered with the (schema-aware) configuration, provided that their namespace URI is registered in the static context as being an imported schema namespace. (A consequence of this is that within a Configuration, there can only be one schema for any given namespace, including the null namespace).

  Specified by:
    `isImportedSchema` in interface `StaticContext`

### isAllowedBuiltInType

    public boolean isAllowedBuiltInType(AtomicType type)

  Determine whether a built-in type is available in this context. This method caters for differences between host languages as to which set of types are built in.

  Specified by:
    `isAllowedBuiltInType` in interface `StaticContext`
  Parameters:
    `type` - the supposedly built-in type. This will always be a type in the XS or XDT namespace.
  Returns:
    true if this type can be used in this static context

### getImportedSchemaNamespaces

    public java.util.Set getImportedSchemaNamespaces()

  Get the set of imported schemas

  Specified by:
    `getImportedSchemaNamespaces` in interface `StaticContext`
  Returns:
    a Set, the set of URIs representing the names of imported schemas

### setImportedSchemaNamespaces

    public void setImportedSchemaNamespaces(java.util.Set namespaces)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD