当前位置: 首页>>代码示例>>Java>>正文


Java XPathContext.getContextNode方法代码示例

本文整理汇总了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());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:FuncCurrent.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:63,代码来源:FuncPosition.java


注:本文中的com.sun.org.apache.xpath.internal.XPathContext.getContextNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。