• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java XNodeSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.org.apache.xpath.internal.objects.XNodeSet的典型用法代码示例。如果您正苦于以下问题:Java XNodeSet类的具体用法?Java XNodeSet怎么用?Java XNodeSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



XNodeSet类属于com.sun.org.apache.xpath.internal.objects包,在下文中一共展示了XNodeSet类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: evaluate

import com.sun.org.apache.xpath.internal.objects.XNodeSet; //导入依赖的package包/类
/**
 * The dyn:evaluate function evaluates a string as an XPath expression and returns
 * the resulting value, which might be a boolean, number, string, node set, result
 * tree fragment or external object. The sole argument is the string to be evaluated.
 * <p>
 * If the expression string passed as the second argument is an invalid XPath
 * expression (including an empty string), this function returns an empty node set.
 * <p>
 * You should only use this function if the expression must be constructed dynamically,
 * otherwise it is much more efficient to use the expression literally.
 *
 * @param myContext The ExpressionContext passed by the extension processor
 * @param xpathExpr The XPath expression string
 *
 * @return The evaluation result
 */
public static XObject evaluate(ExpressionContext myContext, String xpathExpr)
  throws SAXNotSupportedException
{
  if (myContext instanceof XPathContext.XPathExpressionContext)
  {
    XPathContext xctxt = null;
    try
    {
      xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext();
      XPath dynamicXPath = new XPath(xpathExpr, xctxt.getSAXLocator(),
                                     xctxt.getNamespaceContext(),
                                     XPath.SELECT);

      return dynamicXPath.execute(xctxt, myContext.getContextNode(),
                                  xctxt.getNamespaceContext());
    }
    catch (TransformerException e)
    {
      return new XNodeSet(xctxt.getDTMManager());
    }
  }
  else
    throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext })); //"Invalid context passed to evaluate "
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:ExsltDynamic.java


示例2: asIteratorRaw

import com.sun.org.apache.xpath.internal.objects.XNodeSet; //导入依赖的package包/类
/**
 * 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();
  }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:Expression.java


示例3: execute

import com.sun.org.apache.xpath.internal.objects.XNodeSet; //导入依赖的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


示例4: execute

import com.sun.org.apache.xpath.internal.objects.XNodeSet; //导入依赖的package包/类
/**
 * The here function returns a node-set containing the attribute or
 * processing instruction node or the parent element of the text node
 * that directly bears the XPath expression.  This expression results
 * in an error if the containing XPath expression does not appear in the
 * same XML document against which the XPath expression is being evaluated.
 *
 * @param xctxt
 * @return the xobject
 * @throws javax.xml.transform.TransformerException
 */
@Override
public XObject execute(XPathContext xctxt)
    throws javax.xml.transform.TransformerException {

    Node xpathOwnerNode = (Node) xctxt.getOwnerObject();

    if (xpathOwnerNode == null) {
        return null;
    }

    int xpathOwnerNodeDTM = xctxt.getDTMHandleFromNode(xpathOwnerNode);

    int currentNode = xctxt.getCurrentNode();
    DTM dtm = xctxt.getDTM(currentNode);
    int docContext = dtm.getDocument();

    if (DTM.NULL == docContext) {
        error(xctxt, XPATHErrorResources.ER_CONTEXT_HAS_NO_OWNERDOC, null);
    }

    {
        // check whether currentNode and the node containing the XPath expression
        // are in the same document
        Document currentDoc =
            XMLUtils.getOwnerDocument(dtm.getNode(currentNode));
        Document xpathOwnerDoc = XMLUtils.getOwnerDocument(xpathOwnerNode);

        if (currentDoc != xpathOwnerDoc) {
            throw new TransformerException(I18n.translate("xpath.funcHere.documentsDiffer"));
        }
    }

    XNodeSet nodes = new XNodeSet(xctxt.getDTMManager());
    NodeSetDTM nodeSet = nodes.mutableNodeset();

    {
        int hereNode = DTM.NULL;

        switch (dtm.getNodeType(xpathOwnerNodeDTM)) {

        case Node.ATTRIBUTE_NODE :
        case Node.PROCESSING_INSTRUCTION_NODE : {
            // returns a node-set containing the attribute /  processing instruction node
            hereNode = xpathOwnerNodeDTM;

            nodeSet.addNode(hereNode);

            break;
        }
        case Node.TEXT_NODE : {
            // returns a node-set containing the parent element of the
            // text node that directly bears the XPath expression
            hereNode = dtm.getParent(xpathOwnerNodeDTM);

            nodeSet.addNode(hereNode);

            break;
        }
        default :
            break;
        }
    }

    /** $todo$ Do I have to do this detach() call? */
    nodeSet.detach();

    return nodes;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:80,代码来源:FuncHere.java


示例5: executeFilterExpr

import com.sun.org.apache.xpath.internal.objects.XNodeSet; //导入依赖的package包/类
/**
 * 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 com.sun.org.apache.xml.internal.utils.WrappedRuntimeException
{
  PrefixResolver savedResolver = xctxt.getNamespaceContext();
  XNodeSet result = null;

  try
  {
    xctxt.pushCurrentNode(context);
    xctxt.setNamespaceContext(prefixResolver);

    // The setRoot operation can take place with a reset operation,
    // and so we may not be in the context of LocPathIterator#nextNode,
    // so we have to set up the variable context, execute the expression,
    // and then restore the variable context.

    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 = (com.sun.org.apache.xpath.internal.objects.XNodeSet) expr.execute(xctxt);
      result.setShouldCacheNodes(true);

      // These two statements need to be combined into one operation.
      vars.setStackFrame(savedStart);
    }
    else
        result = (com.sun.org.apache.xpath.internal.objects.XNodeSet) expr.execute(xctxt);

  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: Fix...
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(se);
  }
  finally
  {
    xctxt.popCurrentNode();
    xctxt.setNamespaceContext(savedResolver);
  }
  return result;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:57,代码来源:FilterExprIteratorSimple.java


示例6: execute

import com.sun.org.apache.xpath.internal.objects.XNodeSet; //导入依赖的package包/类
@Override
public XObject execute(XPathContext xctxt) throws TransformerException {
    Node xpathOwnerNode = (Node)xctxt.getOwnerObject();
    if (xpathOwnerNode == null) {
        return null;
    }

    int xpathOwnerNodeDTM = xctxt.getDTMHandleFromNode(xpathOwnerNode);
    int currentNode = xctxt.getCurrentNode();
    DTM dtm = xctxt.getDTM(currentNode);
    int docContext = dtm.getDocument();

    if (docContext == DTM.NULL) {
        error(xctxt, XPATHErrorResources.ER_CONTEXT_HAS_NO_OWNERDOC, null);
    }

    // check whether currentNode and the node containing the XPath
    // expression are in the same document
    Document currentDoc = getOwnerDocument(dtm.getNode(currentNode));
    Document xpathOwnerDoc = getOwnerDocument(xpathOwnerNode);

    if (currentDoc != xpathOwnerDoc) {
        throw new TransformerException("Owner documents differ");
    }

    XNodeSet nodes = new XNodeSet(xctxt.getDTMManager());
    NodeSetDTM nodeSet = nodes.mutableNodeset();

    int hereNode = DTM.NULL;

    switch (dtm.getNodeType(xpathOwnerNodeDTM)) {

        case Node.ATTRIBUTE_NODE:
        case Node.PROCESSING_INSTRUCTION_NODE: {
            // returns a node-set containing the attribute /  processing
            // instruction node
            hereNode = xpathOwnerNodeDTM;
            nodeSet.addNode(hereNode);
            break;
        }
        case Node.TEXT_NODE : {
            // returns a node-set containing the parent element of the
            // text node that directly bears the XPath expression
            hereNode = dtm.getParent(xpathOwnerNodeDTM);
            nodeSet.addNode(hereNode);
            break;
        }
        default :
            break;
    }

    /** $todo$ Do I have to do this detach() call? */
    nodeSet.detach();

    return nodes;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:57,代码来源:FuncHere.java


示例7: execute

import com.sun.org.apache.xpath.internal.objects.XNodeSet; //导入依赖的package包/类
/**
 * Execute this iterator, meaning create a clone that can
 * store state, and initialize it for fast execution from
 * the current runtime state.  When this is called, no actual
 * query from the current context node is performed.
 *
 * @param xctxt The XPath execution context.
 *
 * @return An XNodeSet reference that holds this iterator.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt)
        throws javax.xml.transform.TransformerException
{

  XNodeSet iter = new XNodeSet((LocPathIterator)m_clones.getInstance());

  iter.setRoot(xctxt.getCurrentNode(), xctxt);

  return iter;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:LocPathIterator.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PeerListListener类代码示例发布时间:2022-05-21
下一篇:
Java ResourceCalculatorProcessTree类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap