> I need to know how to
> define XPath variables outside a XSLT, that means :
> - within the XPath expression itself (I think there's finally no way)
There's no way in XPath 1.0. I haven't checked whether Xpath 2.0 adds
anything along those lines.
> - through the Xalan API (I found a VariableStack class, but I don't
> understand how to use it, or if I should use it in my purpose anyway).
It can be done -- our XSLT engine does it, obviously, both from within XSLT
and via the setParameter() call -- but we don't seem to have a stand-alone
example on our website. We probably should...
If you look at the source code for the XPathAPI convenience wrapper, you'll
see that it basically creates a parsed XPath object and an XPathContext
object, sets the source document into the XPathContext, and runs the
XPath's execute() method over that. To set variables, I believe you'd
retrieve the XPathContext's variable stack (via getVarStack()) and use it
to assert them before executing the XPath.