Package net.sf.saxon.style
Class UseWhenStaticContext
- java.lang.Object
-
- net.sf.saxon.sxpath.AbstractStaticContext
-
- net.sf.saxon.style.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.saxon.sxpath.AbstractStaticContext
AbstractStaticContext.WarningHandler
-
-
Constructor Summary
Constructors Constructor Description UseWhenStaticContext(Compilation compilation, NamespaceResolver namespaceContext)
Create a static context for evaluating use-when expressions
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Expression
bindVariable(StructuredQName qName)
Bind a variable used in this element to its declarationint
getColumnNumber()
Compilation
getCompilation()
DecimalFormatManager
getDecimalFormatManager()
Get a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.java.lang.String
getDefaultCollationName()
Get the name of the default collation.NamespaceUri
getDefaultFunctionNamespace()
Get the default function namespaceFunctionLibrary
getFunctionLibrary()
Get the function library containing all the in-scope functions available in this static contextjava.util.Set<NamespaceUri>
getImportedSchemaNamespaces()
Get the set of imported schemasint
getLineNumber()
NamespaceResolver
getNamespaceResolver()
Get a namespace resolver to resolve the namespaces declared in this static context.java.lang.String
getPublicId()
java.lang.String
getSystemId()
Get the System ID of the container of the expression.boolean
isImportedSchema(NamespaceUri namespace)
Determine whether a Schema for a given target namespace has been imported.boolean
isInBackwardsCompatibleMode()
Determine whether Backwards Compatible Mode is usedvoid
issueWarning(java.lang.String s, java.lang.String errorCode, Location locator)
Issue a compile-time warningRetainedStaticContext
makeRetainedStaticContext()
Construct a RetainedStaticContext, which extracts information from this StaticContext to provide the subset of static context information that is potentially needed during expression evaluationItemType
resolveTypeAlias(StructuredQName typeName)
Get type alias.-
Methods inherited from class net.sf.saxon.sxpath.AbstractStaticContext
addFunctionLibrary, getConfiguration, getContainingLocation, getDefaultElementNamespace, getKeyManager, getPackageData, getRequiredContextItemType, getStaticBaseURI, getUnprefixedElementMatchingPolicy, getWarningHandler, getXPathVersion, makeEarlyEvaluationContext, setBackwardsCompatibilityMode, setBaseURI, setConfiguration, setContainingLocation, setDecimalFormatManager, setDefaultCollationName, setDefaultElementNamespace, setDefaultFunctionLibrary, setDefaultFunctionLibrary, setDefaultFunctionNamespace, setFunctionLibrary, setPackageData, setSchemaAware, setTypeAlias, setUnprefixedElementMatchingPolicy, setWarningHandler, setWarningHandler, setXPathLanguageLevel
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.expr.StaticContext
getConfiguration, getContainingLocation, getDefaultElementNamespace, getKeyManager, getOptimizerOptions, getPackageData, getRequiredContextItemType, getStaticBaseURI, getUnprefixedElementMatchingPolicy, getXPathVersion, makeEarlyEvaluationContext
-
-
-
-
Constructor Detail
-
UseWhenStaticContext
public UseWhenStaticContext(Compilation compilation, NamespaceResolver namespaceContext)
Create a static context for evaluating use-when expressions- Parameters:
compilation
- the package compilation episodenamespaceContext
- 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 interfaceStaticContext
- Overrides:
makeRetainedStaticContext
in classAbstractStaticContext
- Returns:
- a RetainedStaticContext object: either a newly created one, or one that is reused from a previous invocation.
-
getCompilation
public Compilation getCompilation()
-
issueWarning
public void issueWarning(java.lang.String s, java.lang.String errorCode, Location locator)
Issue a compile-time warning- Specified by:
issueWarning
in interfaceStaticContext
- Overrides:
issueWarning
in classAbstractStaticContext
- Parameters:
s
- The warning message. This should not contain any prefix such as "Warning".errorCode
- Error code identifying the warning conditionlocator
- 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 interfaceStaticContext
- Overrides:
getSystemId
in classAbstractStaticContext
- Returns:
- "" always
-
bindVariable
public Expression bindVariable(StructuredQName qName) throws XPathException
Bind a variable used in this element to its declaration- Specified by:
bindVariable
in interfaceStaticContext
- 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)
-
getFunctionLibrary
public FunctionLibrary getFunctionLibrary()
Get the function library containing all the in-scope functions available in this static context- Specified by:
getFunctionLibrary
in interfaceStaticContext
- Overrides:
getFunctionLibrary
in classAbstractStaticContext
- Returns:
- the function library
-
getDefaultCollationName
public java.lang.String getDefaultCollationName()
Get the name of the default collation.- Specified by:
getDefaultCollationName
in interfaceStaticContext
- Overrides:
getDefaultCollationName
in classAbstractStaticContext
- Returns:
- the name of the default collation; or the name of the codepoint collation if no default collation has been defined
-
getDefaultFunctionNamespace
public NamespaceUri getDefaultFunctionNamespace()
Get the default function namespace- Specified by:
getDefaultFunctionNamespace
in interfaceStaticContext
- Overrides:
getDefaultFunctionNamespace
in classAbstractStaticContext
- Returns:
- the default namesapce for functions
-
isInBackwardsCompatibleMode
public boolean isInBackwardsCompatibleMode()
Determine whether Backwards Compatible Mode is used- Specified by:
isInBackwardsCompatibleMode
in interfaceStaticContext
- Overrides:
isInBackwardsCompatibleMode
in classAbstractStaticContext
- Returns:
- true if XPath 1.0 compatibility mode is to be set to true; otherwise false
-
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 interfaceStaticContext
- 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 interfaceStaticContext
- 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 interfaceStaticContext
- Returns:
- a namespace resolver.
-
getDecimalFormatManager
public DecimalFormatManager getDecimalFormatManager()
Get a DecimalFormatManager to resolve the names of decimal formats used in calls to the format-number() function.- Specified by:
getDecimalFormatManager
in interfaceStaticContext
- Overrides:
getDecimalFormatManager
in classAbstractStaticContext
- Returns:
- the decimal format manager for this static context, or null if named decimal formats are not supported in this environment.
-
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 interfaceStaticContext
- Overrides:
resolveTypeAlias
in classAbstractStaticContext
- 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).
-
-