I have a case of evaluation like :
$asset eq 100 and $asset/name() eq 'p0:current_asset'
which should return true(), variable $asset need to be resolved as primitive and node value in same evaluation, I'm using XPathVariableResolver interface to resolve variable when evaluation is running.
Returning TinyElementImpl when resolving variable with
public Object resolveVariable(QName variableName)
Doesn't solve the problem, I'm using JAXP implementation of SAXON-HE.
Is it possible to do that ?
We (Saxonica) haven't documented very clearly exactly what kinds of
Objectour implementation accepts as the result of the JAXPresolveVariable()method, and I'm in the process of fixing that. Returning anyNodeInfo(including, therefore, an instance ofTinyElementImpl) should work fine.If you're using Saxon-HE, then it's not schema-aware, so the typed value of an element will always be
untypedAtomic, therefore comparison with an integer isn't going to work. The simplest fix, though some readers might find it confusing, is to change the condition to+$asset eq 100- the unary plus operator forces a type conversion.I wouldn't write
$asset/name() eq 'p0:current_asset'either, because it's dependent on the namespace prefix. Better is to write$asset[self::p0:current-asset].