Symptoms: The error
XPDY0002: The context item is undefined at this point
is produced erroneously at compile time (with no line
number) when processing the construct
<xsl:function name="x">
<xsl:sequence select="" for="" $class="" in="" tds:classes()="" return="" (if="" (tds:type($class)="object" )="" then="" $class="" else="" ())"=""/>
</xsl:function>
However, the same error could be triggered by different
constructs, and could produce different symptoms.
What's happening here is the Saxon optimizer is
attempting to rewrite the select expression as
tds:classes()[tds:type(.) = 'object']
The failure occurs because when tds:type($class) is
replaced by tds:type(.), Saxon fails to reset the
static properties of the expression, so it isn't
recognized as being dependent on the context item, and
it's therefore incorrectly pulled out of the predicate
in the next phase of optimization. Outside the
predicate there is no context item defined, hence this
error message.
Source fix: at line 177 in
net.sf.saxon.FunctionCall.java, change the line
argument[i] =
argument[i].promote(offer)
to
Expression e =
argument[i].promote(offer);
if (e != argument[i]) {
adoptChildExpression(e);
argument[i] = e;
resetStaticProperties();
}
Applies to Saxon 8.5 only.
Logged In: YES
user_id=251681
The module name to be patched should be
net.sf.saxon.expr.FunctionCall.java
not
net.sf.saxon.FunctionCall.java