net.sf.saxon.functions

Class NormalizeSpace

public class NormalizeSpace extends SystemFunction

Implement the XPath normalize-space() function
Method Summary
booleaneffectiveBooleanValue(XPathContext c)
Get the effective boolean value of the expression.
ItemevaluateItem(XPathContext c)
Evaluate in a general context
intgetIntrinsicDependencies()
Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.
ExpressionpreEvaluate(ExpressionVisitor visitor)
Pre-evaluate a function at compile time.
ExpressiontypeCheck(ExpressionVisitor visitor, ItemType contextItemType)

Method Detail

effectiveBooleanValue

public boolean effectiveBooleanValue(XPathContext c)
Get the effective boolean value of the expression. This returns false if the value is the empty sequence, a zero-length string, a number equal to zero, or the boolean false. Otherwise it returns true.

This method is implemented for normalize-space() because it is quite often used in a boolean context to test whether a value exists and is non-white, and because testing for the presence of non-white characters is a lot more efficient than constructing the normalized string, especially because of early-exit.

Parameters: c The context in which the expression is to be evaluated

Returns: the effective boolean value

Throws: net.sf.saxon.trans.XPathException if any dynamic error occurs evaluating the expression

evaluateItem

public Item evaluateItem(XPathContext c)
Evaluate in a general context

getIntrinsicDependencies

public int getIntrinsicDependencies()
Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions. For example, position() has an intrinsic dependency on the context position, while (position()+1) does not. The default implementation of the method returns 0, indicating "no dependencies".

Returns: a set of bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty

preEvaluate

public Expression preEvaluate(ExpressionVisitor visitor)
Pre-evaluate a function at compile time. Functions that do not allow pre-evaluation, or that need access to context information, can override this method.

Parameters: visitor an expression visitor

typeCheck

public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType)