use of org.apache.xpath.objects.XObject in project j2objc by google.
the class UnionPattern method execute.
/**
* Test a node to see if it matches any of the patterns in the union.
*
* @param xctxt XPath runtime context.
*
* @return {@link org.apache.xpath.patterns.NodeTest#SCORE_NODETEST},
* {@link org.apache.xpath.patterns.NodeTest#SCORE_NONE},
* {@link org.apache.xpath.patterns.NodeTest#SCORE_NSWILD},
* {@link org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or
* {@link org.apache.xpath.patterns.NodeTest#SCORE_OTHER}.
*
* @throws javax.xml.transform.TransformerException
*/
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException {
XObject bestScore = null;
int n = m_patterns.length;
for (int i = 0; i < n; i++) {
XObject score = m_patterns[i].execute(xctxt);
if (score != NodeTest.SCORE_NONE) {
if (null == bestScore)
bestScore = score;
else if (score.num() > bestScore.num())
bestScore = score;
}
}
if (null == bestScore) {
bestScore = NodeTest.SCORE_NONE;
}
return bestScore;
}
use of org.apache.xpath.objects.XObject in project j2objc by google.
the class VariableStack method getLocalVariable.
/**
* Get a local variable or parameter in the current stack frame.
*
*
* @param xctxt The XPath context, which must be passed in order to
* lazy evaluate variables.
*
* @param index Local variable index relative to the current stack
* frame bottom.
*
* @return The value of the variable.
*
* @throws TransformerException
*/
public XObject getLocalVariable(XPathContext xctxt, int index, boolean destructiveOK) throws TransformerException {
index += _currentFrameBottom;
XObject val = _stackFrames[index];
if (null == val)
throw new TransformerException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_VARIABLE_ACCESSED_BEFORE_BIND, null), xctxt.getSAXLocator());
// Lazy execution of variables.
if (val.getType() == XObject.CLASS_UNRESOLVEDVARIABLE)
return (_stackFrames[index] = val.execute(xctxt));
return destructiveOK ? val : val.getFresh();
}
use of org.apache.xpath.objects.XObject in project j2objc by google.
the class VariableStack method getLocalVariable.
/**
* Get a local variable or parameter in the current stack frame.
*
*
* @param xctxt The XPath context, which must be passed in order to
* lazy evaluate variables.
*
* @param index Local variable index relative to the current stack
* frame bottom.
*
* @return The value of the variable.
*
* @throws TransformerException
*/
public XObject getLocalVariable(XPathContext xctxt, int index) throws TransformerException {
index += _currentFrameBottom;
XObject val = _stackFrames[index];
if (null == val)
throw new TransformerException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_VARIABLE_ACCESSED_BEFORE_BIND, null), xctxt.getSAXLocator());
// Lazy execution of variables.
if (val.getType() == XObject.CLASS_UNRESOLVEDVARIABLE)
return (_stackFrames[index] = val.execute(xctxt));
return val;
}
use of org.apache.xpath.objects.XObject in project j2objc by google.
the class XPath method getMatchScore.
/**
* Get the match score of the given node.
*
* @param xctxt XPath runtime context.
* @param context The current source tree context node.
*
* @return score, one of {@link #MATCH_SCORE_NODETEST},
* {@link #MATCH_SCORE_NONE}, {@link #MATCH_SCORE_OTHER},
* or {@link #MATCH_SCORE_QNAME}.
*
* @throws javax.xml.transform.TransformerException
*/
public double getMatchScore(XPathContext xctxt, int context) throws javax.xml.transform.TransformerException {
xctxt.pushCurrentNode(context);
xctxt.pushCurrentExpressionNode(context);
try {
XObject score = m_mainExp.execute(xctxt);
if (DEBUG_MATCHES) {
DTM dtm = xctxt.getDTM(context);
System.out.println("score: " + score.num() + " for " + dtm.getNodeName(context) + " for xpath " + this.getPatternString());
}
return score.num();
} finally {
xctxt.popCurrentNode();
xctxt.popCurrentExpressionNode();
}
// return XPath.MATCH_SCORE_NONE;
}
use of org.apache.xpath.objects.XObject in project j2objc by google.
the class ElemVariable method execute.
/**
* Execute a variable declaration and push it onto the variable stack.
* @see <a href="http://www.w3.org/TR/xslt#variables">variables in XSLT Specification</a>
*
* @param transformer non-null reference to the the current transform-time state.
*
* @throws TransformerException
*/
public void execute(TransformerImpl transformer) throws TransformerException {
int sourceNode = transformer.getXPathContext().getCurrentNode();
XObject var = getValue(transformer, sourceNode);
// transformer.getXPathContext().getVarStack().pushVariable(m_qname, var);
transformer.getXPathContext().getVarStack().setLocalVariable(m_index, var);
}
Aggregations