use of org.apache.xpath.axes.SubContextList 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.axes.SubContextList in project robovm by robovm.
the class FuncPosition method getPositionInContextNodeList.
/**
* Get the position in the current context node list.
*
* @param xctxt Runtime XPath context.
*
* @return The current position of the itteration in the context node list,
* or -1 if there is no active context node list.
*/
public int getPositionInContextNodeList(XPathContext xctxt) {
// System.out.println("FuncPosition- entry");
// If we're in a predicate, then this will return non-null.
SubContextList iter = m_isTopLevel ? null : xctxt.getSubContextList();
if (null != iter) {
int prox = iter.getProximityPosition(xctxt);
// System.out.println("FuncPosition- prox: "+prox);
return prox;
}
DTMIterator cnl = xctxt.getContextNodeList();
if (null != cnl) {
int n = cnl.getCurrentNode();
if (n == DTM.NULL) {
if (cnl.getCurrentPos() == 0)
return 0;
// a problem for current().
try {
cnl = cnl.cloneWithReset();
} catch (CloneNotSupportedException cnse) {
throw new org.apache.xml.utils.WrappedRuntimeException(cnse);
}
int currentNode = xctxt.getContextNode();
// System.out.println("currentNode: "+currentNode);
while (DTM.NULL != (n = cnl.nextNode())) {
if (n == currentNode)
break;
}
}
// System.out.println("FuncPosition- cnl.getCurrentPos(): "+cnl.getCurrentPos());
return cnl.getCurrentPos();
}
// System.out.println("FuncPosition - out of guesses: -1");
return -1;
}
use of org.apache.xpath.axes.SubContextList in project j2objc by google.
the class FuncLast method getCountOfContextNodeList.
/**
* Get the position in the current context node list.
*
* @param xctxt non-null reference to XPath runtime context.
*
* @return The number of nodes in the list.
*
* @throws javax.xml.transform.TransformerException
*/
public int getCountOfContextNodeList(XPathContext xctxt) throws javax.xml.transform.TransformerException {
// assert(null != m_contextNodeList, "m_contextNodeList must be non-null");
// If we're in a predicate, then this will return non-null.
SubContextList iter = m_isTopLevel ? null : xctxt.getSubContextList();
// System.out.println("iter: "+iter);
if (null != iter)
return iter.getLastPos(xctxt);
DTMIterator cnl = xctxt.getContextNodeList();
int count;
if (null != cnl) {
count = cnl.getLength();
// System.out.println("count: "+count);
} else
count = 0;
return count;
}
use of org.apache.xpath.axes.SubContextList in project j2objc by google.
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.axes.SubContextList in project j2objc by google.
the class FuncPosition method getPositionInContextNodeList.
/**
* Get the position in the current context node list.
*
* @param xctxt Runtime XPath context.
*
* @return The current position of the itteration in the context node list,
* or -1 if there is no active context node list.
*/
public int getPositionInContextNodeList(XPathContext xctxt) {
// System.out.println("FuncPosition- entry");
// If we're in a predicate, then this will return non-null.
SubContextList iter = m_isTopLevel ? null : xctxt.getSubContextList();
if (null != iter) {
int prox = iter.getProximityPosition(xctxt);
// System.out.println("FuncPosition- prox: "+prox);
return prox;
}
DTMIterator cnl = xctxt.getContextNodeList();
if (null != cnl) {
int n = cnl.getCurrentNode();
if (n == DTM.NULL) {
if (cnl.getCurrentPos() == 0)
return 0;
// a problem for current().
try {
cnl = cnl.cloneWithReset();
} catch (CloneNotSupportedException cnse) {
throw new org.apache.xml.utils.WrappedRuntimeException(cnse);
}
int currentNode = xctxt.getContextNode();
// System.out.println("currentNode: "+currentNode);
while (DTM.NULL != (n = cnl.nextNode())) {
if (n == currentNode)
break;
}
}
// System.out.println("FuncPosition- cnl.getCurrentPos(): "+cnl.getCurrentPos());
return cnl.getCurrentPos();
}
// System.out.println("FuncPosition - out of guesses: -1");
return -1;
}
Aggregations