Class GlobalContextRequirement

java.lang.Object
net.sf.saxon.expr.instruct.GlobalContextRequirement

public class GlobalContextRequirement extends Object
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 Details

    • GlobalContextRequirement

      public GlobalContextRequirement()
  • Method Details

    • getRequiredItemType

      public ItemType 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

      public SequenceType 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

      public List<SequenceType> 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

      public void addRequiredSequenceType(SequenceType requiredType, boolean isMainModule)
      Specify the required type of the context item / context value
      Parameters:
      requiredType - the required item type
    • getDefaultValue

      public Expression 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

      public void setDefaultValue(Expression defaultValue)
      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

      public void export(ExpressionPresenter out) throws XPathException
      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

      public void setContextValueOptionality(Optionality status)
      Say whether the context item/value is required, optional, or disallowed
      Parameters:
      status - the relevant status
    • getContextValueOptionality

      public Optionality getContextValueOptionality()
      Ask whether the context item/value is required, optional, or disallowed
      Returns:
      the relevant status
    • getOptionality

      public Optionality 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

      public ContextItemStaticInfo makeGlobalContextInfo(Configuration config)
      Make a ContextItemStaticInfo object describing the global context item
      Parameters:
      config - the Configuration
      Returns:
      a suitable ContextItemStaticInfo