net.sf.saxon.expr

Class PathExpression

public final class PathExpression extends ComputedExpression implements MappingFunction

An expression that establishes a set of nodes by following relationships between nodes in the document. Specifically, it consists of a start expression which defines a set of nodes, and a Step which defines a relationship to be followed from those nodes to create a new set of nodes.
Constructor Summary
PathExpression(Expression start, Expression step)
Constructor
Method Summary
intcomputeCardinality()
Determine the static cardinality of the expression
intcomputeDependencies()
Determine which aspects of the context the expression depends on.
intcomputeSpecialProperties()
Get the static properties of this expression (other than its type).
voiddisplay(int level, NamePool pool, PrintStream out)
Diagnostic print of expression structure
booleanequals(Object other)
Is this expression the same as another expression?
ExpressiongetFirstStep()
Get the first step in this expression.
ItemTypegetItemType(TypeHierarchy th)
Determine the data type of the items returned by this exprssion
ExpressiongetLastStep()
Get the last step of the path expression
ExpressiongetLeadingSteps()
Get a path expression consisting of all steps except the last
ExpressiongetRemainingSteps()
Get all steps after the first.
ExpressiongetStartExpression()
Get the start expression (the left-hand operand)
ExpressiongetStepExpression()
Get the step expression (the right-hand operand)
inthashCode()
get HashCode for comparing two expressions
booleanisAbsolute(TypeHierarchy th)
Test whether a path expression is an absolute path - that is, a path whose first step selects a document node
SequenceIteratoriterate(XPathContext context)
Iterate the path-expression in a given context
IteratoriterateSubExpressions()
Get the immediate subexpressions of this expression
Objectmap(Item item, XPathContext context)
Mapping function, from a node returned by the start iteration, to a sequence returned by the child.
Expressionoptimize(Optimizer opt, StaticContext env, ItemType contextItemType)
Optimize the expression and perform type analysis
Expressionpromote(PromotionOffer offer)
Promote this expression if possible
Expressionsimplify(StaticContext env)
Simplify an expression
ExpressiontypeCheck(StaticContext env, ItemType contextItemType)
Optimize the expression and perform type analysis

Constructor Detail

PathExpression

public PathExpression(Expression start, Expression step)
Constructor

Parameters: start A node-set expression denoting the absolute or relative set of nodes from which the navigation path should start. step The step to be followed from each node in the start expression to yield a new node-set

Method Detail

computeCardinality

public int computeCardinality()
Determine the static cardinality of the expression

computeDependencies

public int computeDependencies()
Determine which aspects of the context the expression depends on. The result is a bitwise-or'ed value composed from constants such as XPathContext.VARIABLES and XPathContext.CURRENT_NODE

computeSpecialProperties

public int computeSpecialProperties()
Get the static properties of this expression (other than its type). The result is bit-signficant. These properties are used for optimizations. In general, if property bit is set, it is true, but if it is unset, the value is unknown.

display

public void display(int level, NamePool pool, PrintStream out)
Diagnostic print of expression structure

equals

public boolean equals(Object other)
Is this expression the same as another expression?

getFirstStep

public Expression getFirstStep()
Get the first step in this expression. A path expression A/B/C is represented as (A/B)/C, but the first step is A

getItemType

public final ItemType getItemType(TypeHierarchy th)
Determine the data type of the items returned by this exprssion

Parameters: th

Returns: the type of the step

getLastStep

public Expression getLastStep()
Get the last step of the path expression

getLeadingSteps

public Expression getLeadingSteps()
Get a path expression consisting of all steps except the last

getRemainingSteps

public Expression getRemainingSteps()
Get all steps after the first. This is complicated by the fact that A/B/C is represented as ((A/B)/C; we are required to return B/C

getStartExpression

public Expression getStartExpression()
Get the start expression (the left-hand operand)

getStepExpression

public Expression getStepExpression()
Get the step expression (the right-hand operand)

hashCode

public int hashCode()
get HashCode for comparing two expressions

isAbsolute

public boolean isAbsolute(TypeHierarchy th)
Test whether a path expression is an absolute path - that is, a path whose first step selects a document node

iterate

public SequenceIterator iterate(XPathContext context)
Iterate the path-expression in a given context

Parameters: context the evaluation context

iterateSubExpressions

public Iterator iterateSubExpressions()
Get the immediate subexpressions of this expression

map

public Object map(Item item, XPathContext context)
Mapping function, from a node returned by the start iteration, to a sequence returned by the child.

optimize

public Expression optimize(Optimizer opt, StaticContext env, ItemType contextItemType)
Optimize the expression and perform type analysis

promote

public Expression promote(PromotionOffer offer)
Promote this expression if possible

simplify

public Expression simplify(StaticContext env)
Simplify an expression

Returns: the simplified expression

typeCheck

public Expression typeCheck(StaticContext env, ItemType contextItemType)
Optimize the expression and perform type analysis