本文整理汇总了Java中com.sun.org.apache.xpath.internal.XPathContext.getContextNode方法的典型用法代码示例。如果您正苦于以下问题:Java XPathContext.getContextNode方法的具体用法?Java XPathContext.getContextNode怎么用?Java XPathContext.getContextNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.org.apache.xpath.internal.XPathContext
的用法示例。
在下文中一共展示了XPathContext.getContextNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.sun.org.apache.xpath.internal.XPathContext; //导入方法依赖的package包/类
/**
* 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());
}
示例2: getPositionInContextNodeList
import com.sun.org.apache.xpath.internal.XPathContext; //导入方法依赖的package包/类
/**
* 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;
// Then I think we're in a sort. See sort21.xsl. So the iterator has
// already been spent, and is not on the node we're processing.
// It's highly possible that this is an issue for other context-list
// functions. Shouldn't be a problem for last(), and it shouldn't be
// a problem for current().
try
{
cnl = cnl.cloneWithReset();
}
catch(CloneNotSupportedException cnse)
{
throw new com.sun.org.apache.xml.internal.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("n: "+n);
// System.out.println("FuncPosition- cnl.getCurrentPos(): "+cnl.getCurrentPos());
return cnl.getCurrentPos();
}
// System.out.println("FuncPosition - out of guesses: -1");
return -1;
}