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


Java DTM.NULL属性代码示例

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


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

示例1: executeCharsToContentHandler

/**
 * Execute an expression in the XPath runtime context, and return the 
 * result of the expression.
 *
 *
 * @param xctxt The XPath runtime context.
 *
 * @return The result of the expression in the form of a <code>XObject</code>.
 *
 * @throws javax.xml.transform.TransformerException if a runtime exception 
 *         occurs.
 */
public void executeCharsToContentHandler(XPathContext xctxt, 
                                            ContentHandler handler)
  throws javax.xml.transform.TransformerException,
         org.xml.sax.SAXException
{
  if(Arg0IsNodesetExpr())
  {
    int node = getArg0AsNode(xctxt);
    if(DTM.NULL != node)
    {
      DTM dtm = xctxt.getDTM(node);
      dtm.dispatchCharactersEvents(node, handler, true);
    }
  }
  else
  {
    XObject obj = execute(xctxt);
    obj.dispatchCharactersEvents(handler);
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:32,代码来源:FuncNormalizeSpace.java

示例2: setRoot

/**
 * Set the root node of the TreeWalker.
 * (Not part of the DOM2 TreeWalker interface).
 *
 * @param root The context node of this step.
 */
public void setRoot(int root)
{
  // %OPT% Get this directly from the lpi.
  XPathContext xctxt = wi().getXPathContext();
  m_dtm = xctxt.getDTM(root);
  m_traverser = m_dtm.getAxisTraverser(m_axis);
  m_isFresh = true;
  m_foundLast = false;
  m_root = root;
  m_currentNode = root;

  if (DTM.NULL == root)
  {
    throw new RuntimeException(
      XSLMessages.createXPATHMessage(XPATHErrorResources.ER_SETTING_WALKER_ROOT_TO_NULL, null)); //"\n !!!! Error! Setting the root of a walker to null!!!");
  }

  resetProximityPositions();
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:25,代码来源:AxesWalker.java

示例3: getHandleFromNode

/**
 * Get the handle from a Node.
 * <p>%OPT% This will be pretty slow.</p>
 *
 * <p>%OPT% An XPath-like search (walk up DOM to root, tracking path;
 * walk down DTM reconstructing path) might be considerably faster
 * on later nodes in large documents. That might also imply improving
 * this call to handle nodes which would be in this DTM but
 * have not yet been built, which might or might not be a Good Thing.</p>
 * 
 * %REVIEW% This relies on being able to test node-identity via
 * object-identity. DTM2DOM proxying is a great example of a case where
 * that doesn't work. DOM Level 3 will provide the isSameNode() method
 * to fix that, but until then this is going to be flaky.
 *
 * @param node A node, which may be null.
 *
 * @return The node handle or <code>DTM.NULL</code>.
 */
private int getHandleFromNode(Node node)
{
  if (null != node)
  {
    int len = m_nodes.size();        
    boolean isMore;
    int i = 0;
    do
    {          
      for (; i < len; i++)
      {
        if (m_nodes.elementAt(i) == node)
          return makeNodeHandle(i);
      }

      isMore = nextNode();

      len = m_nodes.size();
          
    } 
    while(isMore || i < len);
  }
  
  return DTM.NULL;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:44,代码来源:DOM2DTM.java

示例4: getSourceTree

/**
 * Get the source tree from the input source.
 *
 * @param source The Source object that should identify the desired node.
 * @param locator The location of the caller, for diagnostic purposes.
 *
 * @return non-null reference to a node.
 *
 * @throws TransformerException if the Source argument can't be resolved to 
 *         a node.
 */
public int getSourceTree(Source source, SourceLocator locator, XPathContext xctxt)
        throws TransformerException
{

  int n = getNode(source);

  if (DTM.NULL != n)
    return n;

  n = parseToNode(source, locator, xctxt);

  if (DTM.NULL != n)
    putDocumentInCache(n, source);

  return n;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:27,代码来源:SourceTreeManager.java

示例5: getNumberSimple

private static int getNumberSimple(DTM dtm, int node) {
  final String localName = dtm.getLocalName(node);

  String uri = dtm.getNamespaceURI(node);
  if (uri == null) uri = "";

  final short type = dtm.getNodeType(node);

  int i = 1;
  int p = node;
  while ((p = dtm.getPreviousSibling(p)) != DTM.NULL) {
    if (dtm.getNodeType(p) == type) {
      switch (type) {
        case Node.TEXT_NODE:
        case Node.COMMENT_NODE:
        case Node.PROCESSING_INSTRUCTION_NODE:
          i++;
          break;
        default:
          if (localName.equals(dtm.getLocalName(p)) && uri.equals(dtm.getNamespaceURI(p))) {
            i++;
          }
      }
    }
  }
  return i;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:XalanSupport.java

示例6: execute

/**
 * Test a node to see if it matches the given node test.
 *
 * @param xctxt XPath runtime context.
 *
 * @return {@link org.apache.xpath.patterns.NodeTest#SCORE_NODETEST},
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_NONE},
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_NSWILD},
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_QNAME}, or
 *         {@link org.apache.xpath.patterns.NodeTest#SCORE_OTHER}.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt, int context)
        throws javax.xml.transform.TransformerException
{

  DTMIterator nl = m_functionExpr.asIterator(xctxt, context);
  XNumber score = SCORE_NONE;

  if (null != nl)
  {
    int n;

    while (DTM.NULL != (n = nl.nextNode()))
    {
      score = (n == context) ? SCORE_OTHER : SCORE_NONE;

      if (score == SCORE_OTHER)
      {
        context = n;

        break;
      }
    }

    // nl.detach();
  }
  nl.detach();

  return score;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:42,代码来源:FunctionPattern.java

示例7: item

/**
 * Returns the <code>index</code>th item in the collection. If 
 * <code>index</code> is greater than or equal to the number of nodes in 
 * the list, this returns <code>null</code>.
 * @param index Index into the collection.
 * @return The node at the <code>index</code>th position in the 
 *   <code>NodeList</code>, or <code>null</code> if that is not a valid 
 *   index.
 */
public Node item(int index)
{
    if (m_iter != null) {
        int handle=m_iter.item(index);
        if (handle == DTM.NULL) {
            return null;
        }
        return m_iter.getDTM(handle).getNode(handle);
    } else {
        return null;
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:DTMNodeList.java

示例8: XNodeSet

/**
 * Construct a XNodeSet object for one node.
 *
 * @param n Node to add to the new XNodeSet object
 */
public XNodeSet(int n, DTMManager dtmMgr)
{

  super(new NodeSetDTM(dtmMgr));
  m_dtmMgr = dtmMgr;

  if (DTM.NULL != n)
  {
    ((NodeSetDTM) m_obj).addNode(n);
    m_last = 1;
  }
  else
  	m_last = 0;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:19,代码来源:XNodeSet.java

示例9: getHandleOfNode

/** Get the handle from a Node. This is a more robust version of
 * getHandleFromNode, intended to be usable by the public.
 *
 * <p>%OPT% This will be pretty slow.</p>
 * 
 * %REVIEW% This relies on being able to test node-identity via
 * object-identity. DTM2DOM proxying is a great example of a case where
 * that doesn't work. DOM Level 3 will provide the isSameNode() method
 * to fix that, but until then this is going to be flaky.
 *
 * @param node A node, which may be null.
 *
 * @return The node handle or <code>DTM.NULL</code>.  */
public int getHandleOfNode(Node node)
{
  if (null != node)
  {
    // Is Node actually within the same document? If not, don't search!
    // This would be easier if m_root was always the Document node, but
    // we decided to allow wrapping a DTM around a subtree.
    if((m_root==node) ||
       (m_root.getNodeType()==DOCUMENT_NODE &&
        m_root==node.getOwnerDocument()) ||
       (m_root.getNodeType()!=DOCUMENT_NODE &&
        m_root.getOwnerDocument()==node.getOwnerDocument())
       )
      {
        // If node _is_ in m_root's tree, find its handle
        //
        // %OPT% This check may be improved significantly when DOM
        // Level 3 nodeKey and relative-order tests become
        // available!
        for(Node cursor=node;
            cursor!=null;
            cursor=
              (cursor.getNodeType()!=ATTRIBUTE_NODE)
              ? cursor.getParentNode()
              : ((org.w3c.dom.Attr)cursor).getOwnerElement())
          {
            if(cursor==m_root)
              // We know this node; find its handle.
              return getHandleFromNode(node); 
          } // for ancestors of node
      } // if node and m_root in same Document
  } // if node!=null

  return DTM.NULL;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:48,代码来源:DOM2DTM.java

示例10: getRoot

/**
 * @see DTMIterator#getRoot()
 */
public int getRoot()
{
	if(null != m_iter)
  	return m_iter.getRoot();
	else
	{
		// NodeSetDTM will call this, and so it's not a good thing to throw 
		// an assertion here.
		// assertion(false, "Can not get the root from a non-iterated NodeSequence!");
		return DTM.NULL;
	}
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:15,代码来源:NodeSequence.java

示例11: getAttributeNodeNS

/**
 *
 * @param namespaceURI
 * @param localName
 *
 *
 * @see org.w3c.dom.Element
 */
public final Attr getAttributeNodeNS(String namespaceURI, String localName)
{
     Attr retAttr = null;
     int n = dtm.getAttributeNode(node,namespaceURI,localName);
     if(n != DTM.NULL)
             retAttr = (Attr) dtm.getNode(n);
     return retAttr;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:16,代码来源:DTMNodeProxy.java

示例12: getLastPos

/**
 * Get the number of nodes in this node list.  The function is probably ill
 * named?
 *
 *
 * @param xctxt The XPath runtime context.
 *
 * @return the number of nodes in this node list.
 */
public int getLastPos(XPathContext xctxt)
{

  int count = 0;
  AxesWalker savedWalker = wi().getLastUsedWalker();

  try
  {
    ReverseAxesWalker clone = (ReverseAxesWalker) this.clone();

    clone.setRoot(this.getRoot());

    clone.setPredicateCount(m_predicateIndex);

    clone.setPrevWalker(null);
    clone.setNextWalker(null);
    wi().setLastUsedWalker(clone);

    // Count 'em all
    // count = 1;
    int next;

    while (DTM.NULL != (next = clone.nextNode()))
    {
      count++;
    }
  }
  catch (CloneNotSupportedException cnse)
  {

    // can't happen
  }
  finally
  {
    wi().setLastUsedWalker(savedWalker);
  }

  return count;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:48,代码来源:ReverseAxesWalker.java

示例13: previousNode

/** @return the next previous in the set and advance the position of the
 * iterator in the set.
 *
 * @throws DOMException - INVALID_STATE_ERR Raised if this method is
 * called after the detach method was invoked.
 *  */
public Node previousNode() 
  {
    if(!valid)
      throw new DTMDOMException(DOMException.INVALID_STATE_ERR);
    
    int handle=dtm_iter.previousNode();
    if (handle==DTM.NULL)
      return null;      
    return dtm_iter.getDTM(handle).getNode(handle);
  }
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:16,代码来源:DTMNodeIterator.java

示例14: execute

/**
 * 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
 */
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 (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:Legostaev,项目名称:xmlsec-gost,代码行数:77,代码来源:FuncHere.java

示例15: traverse

/** Perform a non-recursive pre-order/post-order traversal,
 * operating as a Visitor. startNode (preorder) and endNode
 * (postorder) are invoked for each node as we traverse over them,
 * with the result that the node is written out to m_contentHandler.
 *
 * @param pos Node in the tree at which to start (and end) traversal --
 * in other words, the root of the subtree to traverse over.
 *
 * @throws TransformerException */
public void traverse(int pos) throws org.xml.sax.SAXException
{
  // %REVIEW% Why isn't this just traverse(pos,pos)?

  int top = pos;		// Remember the root of this subtree

  while (DTM.NULL != pos)
  {
    startNode(pos);
    int nextNode = m_dtm.getFirstChild(pos);
    while (DTM.NULL == nextNode)
    {
      endNode(pos);

      if (top == pos)
        break;

      nextNode = m_dtm.getNextSibling(pos);

      if (DTM.NULL == nextNode)
      {
        pos = m_dtm.getParent(pos);

        if ((DTM.NULL == pos) || (top == pos))
        {
          // %REVIEW% This condition isn't tested in traverse(pos,top)
          // -- bug?
          if (DTM.NULL != pos)
            endNode(pos);

          nextNode = DTM.NULL;

          break;
        }
      }
    }

    pos = nextNode;
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:49,代码来源:DTMTreeWalker.java


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