use of org.apache.xpath.objects.XNodeSet in project robovm by robovm.
the class FilterExprIteratorSimple method executeFilterExpr.
/**
* Execute the expression. Meant for reuse by other FilterExpr iterators
* that are not derived from this object.
*/
public static XNodeSet executeFilterExpr(int context, XPathContext xctxt, PrefixResolver prefixResolver, boolean isTopLevel, int stackFrame, Expression expr) throws org.apache.xml.utils.WrappedRuntimeException {
PrefixResolver savedResolver = xctxt.getNamespaceContext();
XNodeSet result = null;
try {
xctxt.pushCurrentNode(context);
xctxt.setNamespaceContext(prefixResolver);
if (isTopLevel) {
// System.out.println("calling m_expr.execute(getXPathContext())");
VariableStack vars = xctxt.getVarStack();
// These three statements need to be combined into one operation.
int savedStart = vars.getStackFrame();
vars.setStackFrame(stackFrame);
result = (org.apache.xpath.objects.XNodeSet) expr.execute(xctxt);
result.setShouldCacheNodes(true);
// These two statements need to be combined into one operation.
vars.setStackFrame(savedStart);
} else
result = (org.apache.xpath.objects.XNodeSet) expr.execute(xctxt);
} catch (javax.xml.transform.TransformerException se) {
// TODO: Fix...
throw new org.apache.xml.utils.WrappedRuntimeException(se);
} finally {
xctxt.popCurrentNode();
xctxt.setNamespaceContext(savedResolver);
}
return result;
}
use of org.apache.xpath.objects.XNodeSet in project robovm by robovm.
the class FuncCurrent method execute.
/**
* Execute the function. The function must return
* a valid object.
* @param xctxt The current execution context.
* @return A valid XObject.
*
* @throws javax.xml.transform.TransformerException
*/
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException {
SubContextList subContextList = xctxt.getCurrentNodeList();
int currentNode = DTM.NULL;
if (null != subContextList) {
if (subContextList instanceof PredicatedNodeTest) {
LocPathIterator iter = ((PredicatedNodeTest) subContextList).getLocPathIterator();
currentNode = iter.getCurrentContextNode();
} else if (subContextList instanceof StepPattern) {
throw new RuntimeException(XSLMessages.createMessage(XSLTErrorResources.ER_PROCESSOR_ERROR, null));
}
} else {
// not predicate => ContextNode == CurrentNode
currentNode = xctxt.getContextNode();
}
return new XNodeSet(currentNode, xctxt.getDTMManager());
}
use of org.apache.xpath.objects.XNodeSet in project robovm by robovm.
the class Expression method asIteratorRaw.
/**
* Given an select expression and a context, evaluate the XPath
* and return the resulting iterator, but do not clone.
*
* @param xctxt The execution context.
* @param contextNode The node that "." expresses.
*
*
* @return A valid DTMIterator.
* @throws TransformerException thrown if the active ProblemListener decides
* the error condition is severe enough to halt processing.
*
* @throws javax.xml.transform.TransformerException
* @xsl.usage experimental
*/
public DTMIterator asIteratorRaw(XPathContext xctxt, int contextNode) throws javax.xml.transform.TransformerException {
try {
xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
XNodeSet nodeset = (XNodeSet) execute(xctxt);
return nodeset.iterRaw();
} finally {
xctxt.popCurrentNodeAndExpression();
}
}
use of org.apache.xpath.objects.XNodeSet in project robovm by robovm.
the class FuncId method execute.
/**
* Execute the function. The function must return
* a valid object.
* @param xctxt The current execution context.
* @return A valid XObject.
*
* @throws javax.xml.transform.TransformerException
*/
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException {
int context = xctxt.getCurrentNode();
DTM dtm = xctxt.getDTM(context);
int docContext = dtm.getDocument();
if (DTM.NULL == docContext)
error(xctxt, XPATHErrorResources.ER_CONTEXT_HAS_NO_OWNERDOC, null);
XObject arg = m_arg0.execute(xctxt);
int argType = arg.getType();
XNodeSet nodes = new XNodeSet(xctxt.getDTMManager());
NodeSetDTM nodeSet = nodes.mutableNodeset();
if (XObject.CLASS_NODESET == argType) {
DTMIterator ni = arg.iter();
StringVector usedrefs = null;
int pos = ni.nextNode();
while (DTM.NULL != pos) {
DTM ndtm = ni.getDTM(pos);
String refval = ndtm.getStringValue(pos).toString();
pos = ni.nextNode();
usedrefs = getNodesByID(xctxt, docContext, refval, usedrefs, nodeSet, DTM.NULL != pos);
}
// ni.detach();
} else if (XObject.CLASS_NULL == argType) {
return nodes;
} else {
String refval = arg.str();
getNodesByID(xctxt, docContext, refval, null, nodeSet, false);
}
return nodes;
}
use of org.apache.xpath.objects.XNodeSet in project robovm by robovm.
the class LocPathIterator method asIterator.
/**
* Given an select expression and a context, evaluate the XPath
* and return the resulting iterator.
*
* @param xctxt The execution context.
* @param contextNode The node that "." expresses.
* @throws TransformerException thrown if the active ProblemListener decides
* the error condition is severe enough to halt processing.
*
* @throws javax.xml.transform.TransformerException
* @xsl.usage experimental
*/
public DTMIterator asIterator(XPathContext xctxt, int contextNode) throws javax.xml.transform.TransformerException {
XNodeSet iter = new XNodeSet((LocPathIterator) m_clones.getInstance());
iter.setRoot(contextNode, xctxt);
return iter;
}
Aggregations