Class UseWhenStaticContext

  • All Implemented Interfaces:
    StaticContext

    public class UseWhenStaticContext
    extends AbstractStaticContext
    implements StaticContext
    This class implements the static context used for evaluating use-when and other static expressions in XSLT 3.0 A new instance of this class is created for each use-when expression encountered; there are therefore no issues with reusability. The class provides a Container for the expression as well as the static context information; the Executable contains the single XPath expression only, and is created for the purpose.
    • Constructor Detail

      • UseWhenStaticContext

        public UseWhenStaticContext​(Compilation compilation,
                                    NamespaceResolver namespaceContext)
        Create a static context for evaluating use-when expressions
        Parameters:
        compilation - the package compilation episode
        namespaceContext - the namespace context in which the static expression appears
    • Method Detail

      • makeRetainedStaticContext

        public RetainedStaticContext makeRetainedStaticContext()
        Construct a RetainedStaticContext, which extracts information from this StaticContext to provide the subset of static context information that is potentially needed during expression evaluation
        Specified by:
        makeRetainedStaticContext in interface StaticContext
        Overrides:
        makeRetainedStaticContext in class AbstractStaticContext
        Returns:
        a RetainedStaticContext object: either a newly created one, or one that is reused from a previous invocation.
      • issueWarning

        public void issueWarning​(java.lang.String s,
                                 java.lang.String errorCode,
                                 Location locator)
        Issue a compile-time warning
        Specified by:
        issueWarning in interface StaticContext
        Overrides:
        issueWarning in class AbstractStaticContext
        Parameters:
        s - The warning message. This should not contain any prefix such as "Warning".
        errorCode - Error code identifying the warning condition
        locator - the location of the construct in question. May be null.
      • getSystemId

        public java.lang.String getSystemId()
        Get the System ID of the container of the expression. This is the containing entity (file) and is therefore useful for diagnostics. Use getBaseURI() to get the base URI, which may be different.
        Specified by:
        getSystemId in interface StaticContext
        Overrides:
        getSystemId in class AbstractStaticContext
        Returns:
        "" always
      • bindVariable

        public Expression bindVariable​(StructuredQName qName)
                                throws XPathException
        Bind a variable used in this element to its declaration
        Specified by:
        bindVariable in interface StaticContext
        Parameters:
        qName - the name of the variable
        Returns:
        an expression representing the variable reference, This will often be a VariableReference, suitably initialized to refer to the corresponding variable declaration, but in general it can be any expression which returns the variable's value when evaluated. In this version of the method, the value of the variable is known statically, so the returned expression is a literal containing the variable's value.
        Throws:
        XPathException - if the variable cannot be bound (has not been declared)
      • isImportedSchema

        public boolean isImportedSchema​(NamespaceUri namespace)
        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
        Parameters:
        namespace - the target namespace in question
        Returns:
        true if the given namespace has been imported
      • getImportedSchemaNamespaces

        public java.util.Set<NamespaceUri> 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
      • getNamespaceResolver

        public NamespaceResolver getNamespaceResolver()
        Get a namespace resolver to resolve the namespaces declared in this static context.
        Specified by:
        getNamespaceResolver in interface StaticContext
        Returns:
        a namespace resolver.
      • getColumnNumber

        public int getColumnNumber()
      • getPublicId

        public java.lang.String getPublicId()
      • getLineNumber

        public int getLineNumber()
      • resolveTypeAlias

        public ItemType resolveTypeAlias​(StructuredQName typeName)
        Get type alias. This is a Saxon extension. A type alias is a QName which can be used as a shorthand for an itemtype, using the syntax ~typename anywhere that an item type is permitted.
        Specified by:
        resolveTypeAlias in interface StaticContext
        Overrides:
        resolveTypeAlias in class AbstractStaticContext
        Parameters:
        typeName - the name of the type alias
        Returns:
        the corresponding item type, if the name is recognised; otherwise null. This implementation always returns null (type aliases cannot be used in XSLT static expressions).