Class RetainedStaticContext

  • All Implemented Interfaces:
    NamespaceResolver

    public class RetainedStaticContext
    extends java.lang.Object
    implements NamespaceResolver
    This class contains the part of the static context of expressions that (a) can change from one expression to another within a query or stylesheet, and (b) are potentially needed at run-time.

    From 9.6, the retained static context is available to every expression in the expression tree (previously, expressions only retained that part of the static context needed by the particular expression). For economy, a new RetainedStaticContext object is only created when the context changes: which is fairly rare (for example, it never happens within an XPath expression).

    • Constructor Detail

      • RetainedStaticContext

        public RetainedStaticContext​(Configuration config)
      • RetainedStaticContext

        public RetainedStaticContext​(StaticContext sc)
    • Method Detail

      • getConfiguration

        public Configuration getConfiguration()
        Get the Configuration
        Returns:
        the Saxon Configuration object
      • setPackageData

        public void setPackageData​(PackageData packageData)
        Set information about the package (unit of compilation
        Parameters:
        packageData - the package data
      • getPackageData

        public PackageData getPackageData()
        Get information about the package (unit of compilation)
        Returns:
        the package data
      • setStaticBaseUriString

        public void setStaticBaseUriString​(java.lang.String baseUri)
        Set the static base URI as a string
        Parameters:
        baseUri - the base URI as a string
      • getStaticBaseUri

        public java.net.URI getStaticBaseUri()
                                      throws XPathException
        Get the static base URI as a URI.
        Returns:
        the static base URI as a URI if it is known and valid. Return null if the base URI is unknown.
        Throws:
        XPathException - if the static base URI is not a valid URI.
      • getStaticBaseUriString

        public java.lang.String getStaticBaseUriString()
        Get the static base URI as a string.
        Returns:
        the static base URI as a string, or null if unknown
      • getDefaultCollationName

        public java.lang.String getDefaultCollationName()
        Get the name of the default collation for this static context
        Returns:
        the default collation URI
      • setDefaultCollationName

        public void setDefaultCollationName​(java.lang.String defaultCollationName)
        Set the name of the default collation for this static context
        Parameters:
        defaultCollationName - the default collation URI
      • getDefaultFunctionNamespace

        public NamespaceUri getDefaultFunctionNamespace()
        Get the default namespace for functions
        Returns:
        the default namespace for functions
      • setDefaultFunctionNamespace

        public void setDefaultFunctionNamespace​(NamespaceUri defaultFunctionNamespace)
        Set the default namespace for functions
        Parameters:
        defaultFunctionNamespace - the default namespace for functions
      • getDefaultElementNamespace

        public NamespaceUri getDefaultElementNamespace()
        Get the default namespace for elements and types
        Returns:
        the default namespace for elements and types. Return "" if the default is "no namespace"
      • setDefaultElementNamespace

        public void setDefaultElementNamespace​(NamespaceUri ns)
        Set the default namespace for elements and type
        Parameters:
        ns - the default namespace for elements and types.
      • getDecimalFormatManager

        public DecimalFormatManager getDecimalFormatManager()
        Get the decimal format manager
        Returns:
        the decimal format manager
      • setDecimalFormatManager

        public void setDecimalFormatManager​(DecimalFormatManager decimalFormatManager)
        Set the decimal format manager
        Parameters:
        decimalFormatManager - the decimal format manager
      • isBackwardsCompatibility

        public boolean isBackwardsCompatibility()
      • setBackwardsCompatibility

        public void setBackwardsCompatibility​(boolean backwardsCompatibility)
      • declareNamespace

        public void declareNamespace​(java.lang.String prefix,
                                     NamespaceUri uri)
        Add a namespace binding to the static namespace context ("in-scope namespaces") Not supported when the static context is a JAXP XPath.
        Parameters:
        prefix - the namespace prefix
        uri - the namespace URI
      • getURIForPrefix

        public NamespaceUri 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. May be the zero-length string, indicating that there is no prefix. This indicates either the default namespace or the null namespace, depending on the value of useDefault.
        useDefault - true if the default namespace is to be used when the prefix is "". If set to false, and the prefix is "", then the value "" is returned regardless of the default namespace in force. The "default namespace" here means the one bound to the prefix "".
        Returns:
        the uri for the namespace, or null if the prefix is not in scope. The "null namespace" is represented by the pseudo-URI "".
      • iteratePrefixes

        public java.util.Iterator<java.lang.String> 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
        Returns:
        an iterator over all the prefixes for which a namespace binding exists, including the zero-length string to represent the null/absent prefix if it is bound
      • declaresSameNamespaces

        public boolean declaresSameNamespaces​(RetainedStaticContext other)
        Test whether this static context declares the same namespaces as another static context
        Parameters:
        other - the other static context
        Returns:
        true if the namespace bindings (prefix:uri pairs) are the same
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • setNamespaces

        public void setNamespaces​(NamespaceResolver namespaces)
        Set the in-scope namespaces.
        Parameters:
        namespaces - the in-scope namespaces. The preferred representation is as a NamespaceMap; however this is not possible in the case of the JAXP XPath API, which does not allow the in-scope namespaces to be enumerated.