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


Java XPathContext.getCurrentNode方法代码示例

本文整理汇总了Java中com.sun.org.apache.xpath.internal.XPathContext.getCurrentNode方法的典型用法代码示例。如果您正苦于以下问题:Java XPathContext.getCurrentNode方法的具体用法?Java XPathContext.getCurrentNode怎么用?Java XPathContext.getCurrentNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.org.apache.xpath.internal.XPathContext的用法示例。


在下文中一共展示了XPathContext.getCurrentNode方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeCharsToContentHandler

import com.sun.org.apache.xpath.internal.XPathContext; //导入方法依赖的package包/类
/**
 * Execute an expression in the XPath runtime context, and return the
 * result of the expression.
 *
 *
 * @param xctxt The XPath runtime context.
 * @param handler The target content handler.
 *
 * @return The result of the expression in the form of a <code>XObject</code>.
 *
 * @throws javax.xml.transform.TransformerException if a runtime exception
 *         occurs.
 * @throws org.xml.sax.SAXException
 */
public void executeCharsToContentHandler(
        XPathContext xctxt, org.xml.sax.ContentHandler handler)
          throws javax.xml.transform.TransformerException,
                 org.xml.sax.SAXException
{
  LocPathIterator clone = (LocPathIterator)m_clones.getInstance();

  int current = xctxt.getCurrentNode();
  clone.setRoot(current, xctxt);

  int node = clone.nextNode();
  DTM dtm = clone.getDTM(node);
  clone.detach();

  if(node != DTM.NULL)
  {
    dtm.dispatchCharactersEvents(node, handler, false);
  }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:LocPathIterator.java

示例2: getArg0AsString

import com.sun.org.apache.xpath.internal.XPathContext; //导入方法依赖的package包/类
/**
 * Execute the first argument expression that is expected to return a
 * string.  If the argument is null, then get the string value from the
 * current context node.
 *
 * @param xctxt Runtime XPath context.
 *
 * @return The string value of the first argument, or the string value of the
 *         current context node if the first argument is null.
 *
 * @throws javax.xml.transform.TransformerException if an error occurs while
 *                                   executing the argument expression.
 */
protected XMLString getArg0AsString(XPathContext xctxt)
        throws javax.xml.transform.TransformerException
{
  if(null == m_arg0)
  {
    int currentNode = xctxt.getCurrentNode();
    if(DTM.NULL == currentNode)
      return XString.EMPTYSTRING;
    else
    {
      DTM dtm = xctxt.getDTM(currentNode);
      return dtm.getStringValue(currentNode);
    }

  }
  else
    return m_arg0.execute(xctxt).xstr();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:FunctionDef1Arg.java

示例3: getArg0AsNumber

import com.sun.org.apache.xpath.internal.XPathContext; //导入方法依赖的package包/类
/**
 * Execute the first argument expression that is expected to return a
 * number.  If the argument is null, then get the number value from the
 * current context node.
 *
 * @param xctxt Runtime XPath context.
 *
 * @return The number value of the first argument, or the number value of the
 *         current context node if the first argument is null.
 *
 * @throws javax.xml.transform.TransformerException if an error occurs while
 *                                   executing the argument expression.
 */
protected double getArg0AsNumber(XPathContext xctxt)
        throws javax.xml.transform.TransformerException
{

  if(null == m_arg0)
  {
    int currentNode = xctxt.getCurrentNode();
    if(DTM.NULL == currentNode)
      return 0;
    else
    {
      DTM dtm = xctxt.getDTM(currentNode);
      XMLString str = dtm.getStringValue(currentNode);
      return str.toDouble();
    }

  }
  else
    return m_arg0.execute(xctxt).num();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:FunctionDef1Arg.java

示例4: 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
{

  String name = m_arg0.execute(xctxt).str();
  int context = xctxt.getCurrentNode();
  DTM dtm = xctxt.getDTM(context);
  int doc = dtm.getDocument();

  String uri = dtm.getUnparsedEntityURI(name);

  return new XString(uri);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:FuncUnparsedEntityURI.java

示例5: asNode

import com.sun.org.apache.xpath.internal.XPathContext; //导入方法依赖的package包/类
/**
 * Return the first node out of the nodeset, if this expression is
 * a nodeset expression.  This is the default implementation for
 * nodesets.  Derived classes should try and override this and return a
 * value without having to do a clone operation.
 * @param xctxt The XPath runtime context.
 * @return the first node out of the nodeset, or DTM.NULL.
 */
public int asNode(XPathContext xctxt)
  throws javax.xml.transform.TransformerException
{
  DTMIterator iter = (DTMIterator)m_clones.getInstance();

  int current = xctxt.getCurrentNode();

  iter.setRoot(current, xctxt);

  int next = iter.nextNode();
  // m_clones.freeInstance(iter);
  iter.detach();
  return next;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:LocPathIterator.java

示例6: asNode

import com.sun.org.apache.xpath.internal.XPathContext; //导入方法依赖的package包/类
/**
 * Return the first node out of the nodeset, if this expression is
 * a nodeset expression.  This is the default implementation for
 * nodesets.
 * <p>WARNING: Do not mutate this class from this function!</p>
 * @param xctxt The XPath runtime context.
 * @return the first node out of the nodeset, or DTM.NULL.
 */
public int asNode(XPathContext xctxt)
  throws javax.xml.transform.TransformerException
{
  int current = xctxt.getCurrentNode();

  DTM dtm = xctxt.getDTM(current);

  return dtm.getFirstChild(current);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:ChildIterator.java

示例7: asNode

import com.sun.org.apache.xpath.internal.XPathContext; //导入方法依赖的package包/类
/**
 * Return the first node out of the nodeset, if this expression is
 * a nodeset expression.  This is the default implementation for
 * nodesets.
 * <p>WARNING: Do not mutate this class from this function!</p>
 * @param xctxt The XPath runtime context.
 * @return the first node out of the nodeset, or DTM.NULL.
 */
public int asNode(XPathContext xctxt)
  throws javax.xml.transform.TransformerException
{
  if(getPredicateCount() > 0)
    return super.asNode(xctxt);

  int current = xctxt.getCurrentNode();

  DTM dtm = xctxt.getDTM(current);
  DTMAxisTraverser traverser = dtm.getAxisTraverser(m_axis);

  String localName = getLocalName();
  String namespace = getNamespace();
  int what = m_whatToShow;

  // System.out.print(" (DescendantIterator) ");

  // System.out.println("what: ");
  // NodeTest.debugWhatToShow(what);
  if(DTMFilter.SHOW_ALL == what
     || localName == NodeTest.WILD
     || namespace == NodeTest.WILD)
  {
    return traverser.first(current);
  }
  else
  {
    int type = getNodeTypeTest(what);
    int extendedType = dtm.getExpandedTypeID(namespace, localName, type);
    return traverser.first(current, extendedType);
  }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:DescendantIterator.java

示例8: 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
{

  String lang = m_arg0.execute(xctxt).str();
  int parent = xctxt.getCurrentNode();
  boolean isLang = false;
  DTM dtm = xctxt.getDTM(parent);

  while (DTM.NULL != parent)
  {
    if (DTM.ELEMENT_NODE == dtm.getNodeType(parent))
    {
      int langAttr = dtm.getAttributeNode(parent, "http://www.w3.org/XML/1998/namespace", "lang");

      if (DTM.NULL != langAttr)
      {
        String langVal = dtm.getNodeValue(langAttr);
        // %OPT%
        if (langVal.toLowerCase().startsWith(lang.toLowerCase()))
        {
          int valLen = lang.length();

          if ((langVal.length() == valLen)
                  || (langVal.charAt(valLen) == '-'))
          {
            isLang = true;
          }
        }

        break;
      }
    }

    parent = dtm.getParent(parent);
  }

  return isLang ? XBoolean.S_TRUE : XBoolean.S_FALSE;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:47,代码来源:FuncLang.java

示例9: execute

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

示例10: execute

import com.sun.org.apache.xpath.internal.XPathContext; //导入方法依赖的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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:80,代码来源:FuncHere.java

示例11: execute

import com.sun.org.apache.xpath.internal.XPathContext; //导入方法依赖的package包/类
/**
 * Execute this pattern step, including predicates.
 *
 *
 * @param xctxt XPath runtime context.
 *
 * @return {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME}, or
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER}.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt)
        throws javax.xml.transform.TransformerException
{

  if (xctxt.getIteratorRoot() == xctxt.getCurrentNode())
    return getStaticScore();
  else
    return this.SCORE_NONE;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:ContextMatchStepPattern.java

示例12: getArg0AsNode

import com.sun.org.apache.xpath.internal.XPathContext; //导入方法依赖的package包/类
/**
 * Execute the first argument expression that is expected to return a
 * nodeset.  If the argument is null, then return the current context node.
 *
 * @param xctxt Runtime XPath context.
 *
 * @return The first node of the executed nodeset, or the current context
 *         node if the first argument is null.
 *
 * @throws javax.xml.transform.TransformerException if an error occurs while
 *                                   executing the argument expression.
 */
protected int getArg0AsNode(XPathContext xctxt)
        throws javax.xml.transform.TransformerException
{

  return (null == m_arg0)
         ? xctxt.getCurrentNode() : m_arg0.asNode(xctxt);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:FunctionDef1Arg.java

示例13: asNode

import com.sun.org.apache.xpath.internal.XPathContext; //导入方法依赖的package包/类
/**
 * Return the first node out of the nodeset, if this expression is
 * a nodeset expression.  This is the default implementation for
 * nodesets.  Derived classes should try and override this and return a
 * value without having to do a clone operation.
 * @param xctxt The XPath runtime context.
 * @return the first node out of the nodeset, or DTM.NULL.
 */
public int asNode(XPathContext xctxt)
  throws javax.xml.transform.TransformerException
{
  return xctxt.getCurrentNode();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:SelfIteratorNoPredicate.java


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