Sorry, my question is a bit confusing. Let me explain:

I have created an Extension Element(extending ExtensionInstruction), in java, which has a "selectStr" attribute that takes an XPath(like xsl:value-of does). I want to know if my Extension Element code needs to take care of evaluating the XPath being passed in or if this evaluation is taken care of by Saxon before I receive attribute value. And if I do need to evaluate it myself, how?

After some look at Doc, I think I may need do this:
prepareAttribute()
{
Expression compiledExpression = makeExpression( getAttributeValue("", "selectStr") );
}

----------------------------------------------------------------------------------------------------------------------------------------------
compile(Executable exec, Declaration decl)
{
return new TextInstruction(compiledExpression);
}

----------------------------------------------------------------------------------------------------------------------------------------------
private class TextInstruction extends SimpleExpression
{
public String call(XPathContext context, Sequence[] arguments)
{
return arguments[compiledExpression].head().evaluateAsString(context);
}
}

is it the right approach?
Thanks in advance

Sky


On Sat, Feb 8, 2014 at 12:38 AM, sky Chen <sky.freeprisoner@gmail.com> wrote:
Hi, I want to evaluate XPath string supplied through element attribute in extension instruction(Java). How can I pass current context(e.g. static|dynamic context, namespace) to XPathEvaluator? I'm new to Saxon and XSLT, probably this is just a silly question. Currently my code looks like:
private static doSelect(
XPathContext context,
String selectStr)
{
String nodeText = "";
XPathEvaluator evaluator = new XPathEvaluator();
nodeText = evaluator.evaluate(selectStr, context.getContextItem);
}