com.saxonica.schema
Class UnionSelection

java.lang.Object
  extended by com.saxonica.schema.UnionSelection
All Implemented Interfaces:
Selection

public class UnionSelection
extends Object
implements Selection

A union selection is a selection consisting of several alternatives separated by "|"


Constructor Summary
UnionSelection(Selection p1, Selection p2)
           
 
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 fingerprint)
          Determine whether a given attribute matches the Selection
 boolean 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnionSelection

public UnionSelection(Selection p1,
                      Selection p2)
Method Detail

matchesElement

public boolean 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).

Specified by:
matchesElement in interface Selection
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:
true if the element matches

matchesAttribute

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

Specified by:
matchesAttribute in interface Selection
Parameters:
fingerprint - 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

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

Specified by:
canMatchAttributes in interface Selection
Returns:
true if the selection can match attributes

canMatchElementContent

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

Specified by:
canMatchElementContent in interface Selection
Returns:
true if the selection can match elements

typeCheck

public 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

Specified by:
typeCheck in interface Selection
Parameters:
visitor - the expression visitor
contextItemType - the type of the context item
Returns:
an error messge if the expression is invalid

getItemType

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

Specified by:
getItemType in interface Selection
Parameters:
th - the type hierarchy cache
Returns:
the item type of the selected nodes

displayExpression

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

Specified by:
displayExpression in interface Selection
Parameters:
out - the place where the structure is to be written


Copyright (C) Michael H. Kay. All rights reserved.