com.saxonica.stream
Interface Selection

All Superinterfaces:
Serializable
All Known Implementing Classes:
PathSelection, UnionSelection

public interface Selection
extends Serializable

A selection represents the restricted form of path expression permitted in XML Schema (both the selector and field variants)


Field Summary
static int MATCHES_AS_PARENT
           
static int MATCHES_AS_SELF
           
 
Method Summary
 boolean canMatchAttributes()
          Determine whether the selection can match attribute nodes
 boolean canMatchElementContent()
          Determine whether the selection can match element content
 void displayExpression(ExpressionPresenter out)
          Diagnostic print of expression structure.
 ItemType getItemType(TypeHierarchy th)
          Return the type of the nodes selected by this selection
 boolean matchesAttribute(int nameCode)
          Determine whether a given attribute matches the Selection
 int matchesElement(int[] stack, int length, int contextPosition)
          Determine whether the selector matches a given element.
 String typeCheck(ExpressionVisitor visitor, ItemType contextItemType)
          Check that the selection makes sense in the context of a given ItemType.
 

Field Detail

MATCHES_AS_SELF

static final int MATCHES_AS_SELF
See Also:
Constant Field Values

MATCHES_AS_PARENT

static final int MATCHES_AS_PARENT
See Also:
Constant Field Values
Method Detail

matchesElement

int matchesElement(int[] stack,
                   int length,
                   int contextPosition)
Determine whether the selector matches a given element. The element is identified by an array of integers representing the fingerprints of the names of this element and each of its ancestors, in document order (i.e., root element first, matched element last).

Parameters:
stack - the array of name fingerprints
length - the effective length of the array; any items beyond this position are ignored
contextPosition - the position in this array of the context element for the selection.
Returns:
a bit-significant integer. {#MATCHES_AS_SELF} is set if the element matches the selector in its own right. {#MATCHES_AS_PARENT} is set if the element is a potential parent of an attribute that matches the selector. In the case of a union selection, it is possible for both bits to be set.

matchesAttribute

boolean matchesAttribute(int nameCode)
                         throws ValidationException
Determine whether a given attribute matches the Selection

Parameters:
nameCode - the integer nameCode of an attribute
Returns:
true if it matches, false if it does not match
Throws:
ValidationException - if there is more than one attribute that matches

canMatchAttributes

boolean canMatchAttributes()
Determine whether the selection can match attribute nodes

Returns:
true if the selection can match attributes

canMatchElementContent

boolean canMatchElementContent()
Determine whether the selection can match element content

Returns:
true if the selection can match elements

typeCheck

String typeCheck(ExpressionVisitor visitor,
                 ItemType contextItemType)
Check that the selection makes sense in the context of a given ItemType. Return null if the selection is OK, otherwise an error message

Parameters:
visitor - the expression visitor
contextItemType - the type of the context item
Returns:
an error messge if the expression is invalid

getItemType

ItemType getItemType(TypeHierarchy th)
Return the type of the nodes selected by this selection

Parameters:
th - the type hierarchy cache
Returns:
the item type of the selected nodes

displayExpression

void displayExpression(ExpressionPresenter out)
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.

Parameters:
out - the place where the structure is to be written


Copyright (c) Saxonica Limited. All rights reserved.