Package net.sf.saxon.expr.instruct
Class GlobalContextRequirement
java.lang.Object
net.sf.saxon.expr.instruct.GlobalContextRequirement
Information about the requirements placed by a query or stylesheet on the global
context item (or value): whether it is mandatory or optional, what its type must be, and
whether it has a default value.
In XSLT, if more than one module specifies a global context item type, they must be the same. In XQuery, several modules can specify different required types, and the actual context item must satisfy them all.
In XQuery 4.0, the global context value can be any sequence, not just a singleton item.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRequiredSequenceType(SequenceType requiredType, boolean isMainModule) Specify the required type of the context item / context valuevoidExport the global context item declaration to an SEF export file.Ask whether the context item/value is required, optional, or disallowedGet the expression that supplies the default value of the context item, if any.Get the required item type of the context item.Get the required item type of the context item.Get all the required sequence types.booleanAsk whether (in XQuery) the global context item is declared as externalmakeGlobalContextInfo(Configuration config) Make a ContextItemStaticInfo object describing the global context itemvoidSay whether the context item/value is required, optional, or disallowedvoidsetDefaultValue(Expression defaultValue) Set the expression used to compute the default value of the global context itemvoidsetExternal(boolean external) Say whether (in XQuery) the global context item is declared as external
-
Constructor Details
-
GlobalContextRequirement
public GlobalContextRequirement()
-
-
Method Details
-
getRequiredItemType
Get the required item type of the context item. If several required item types have been registered (which only happens in XQuery with multiple modules) then this returns the first.- Returns:
- The first registered required item type
-
getRequiredSequenceType
Get the required item type of the context item. If several required item types have been registered (which only happens in XQuery with multiple modules) then this returns the first.- Returns:
- The first registered required item type
-
getRequiredTypes
Get all the required sequence types. In XSLT there can only be one, but in XQuery there can be several, one for each module (the actual context item must satisfy them all)- Returns:
- the list of required item types
-
addRequiredSequenceType
Specify the required type of the context item / context value- Parameters:
requiredType- the required item type
-
getDefaultValue
Get the expression that supplies the default value of the context item, if any. This is used only in XQuery.- Returns:
- the expression used to compute the value of the context item, in the absence of an externally-supplied value
-
setDefaultValue
Set the expression used to compute the default value of the global context item- Parameters:
defaultValue- the expression used to compute the default value.
-
export
Export the global context item declaration to an SEF export file. Note this only needs to handle the situations that arise in XSLT.- Parameters:
out- the export destination- Throws:
XPathException- if things go wrong
-
setContextValueOptionality
Say whether the context item/value is required, optional, or disallowed- Parameters:
status- the relevant status
-
getContextValueOptionality
Ask whether the context item/value is required, optional, or disallowed- Returns:
- the relevant status
-
getOptionality
-
setExternal
public void setExternal(boolean external) Say whether (in XQuery) the global context item is declared as external- Parameters:
external- true if the global context item is declared as external
-
isExternal
public boolean isExternal()Ask whether (in XQuery) the global context item is declared as external- Returns:
- true if the global context item is declared as external
-
makeGlobalContextInfo
Make a ContextItemStaticInfo object describing the global context item- Parameters:
config- the Configuration- Returns:
- a suitable ContextItemStaticInfo
-