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

Java DTM类代码示例

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

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



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

示例1: getPath

import org.apache.xml.dtm.DTM; //导入依赖的package包/类
public static String getPath(DTM dtm, int node) {
  String pre;
  switch (dtm.getNodeType(node)) {
    case Node.DOCUMENT_NODE:
      return "/";
    case Node.ELEMENT_NODE:
      pre = getPath(dtm, dtm.getParent(node));
      return (pre.equals("/") ? "" : pre) +
             "/" + dtm.getNodeName(node) + "[" + getNumberSimple(dtm, node) + "]";
    case Node.ATTRIBUTE_NODE:
      return getPath(dtm, dtm.getParent(node)) + "/@" + dtm.getNodeNameX(node);
    case Node.TEXT_NODE:
      pre = getPath(dtm, dtm.getParent(node));
      return (pre.equals("/") ? "" : pre) +
             "/text()[" + getNumberSimple(dtm, node) + "]";
    case Node.COMMENT_NODE:
      pre = getPath(dtm, dtm.getParent(node));
      return (pre.equals("/") ? "" : pre) +
             "/comment()[" + getNumberSimple(dtm, node) + "]";
    case Node.PROCESSING_INSTRUCTION_NODE:
      pre = getPath(dtm, dtm.getParent(node));
      return (pre.equals("/") ? "" : pre) +
             "/processing-instruction()[" + getNumberSimple(dtm, node) + "]";
  }
  return "?";
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:XalanSupport.java


示例2: executeCharsToContentHandler

import org.apache.xml.dtm.DTM; //导入依赖的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:keplersj,项目名称:In-the-Box-Fork,代码行数:34,代码来源:LocPathIterator.java


示例3: isDefinedNSDecl

import org.apache.xml.dtm.DTM; //导入依赖的package包/类
/**
 * Returns whether a namespace is defined
 *
 *
 * @param attr Namespace attribute node
 * @param dtm The DTM that owns attr.
 *
 * @return True if the namespace is already defined in
 * list of namespaces
 */
public static boolean isDefinedNSDecl(
    SerializationHandler serializer,
    int attr,
    DTM dtm)
{

    if (DTM.NAMESPACE_NODE == dtm.getNodeType(attr))
    {

        // String prefix = dtm.getPrefix(attr);
        String prefix = dtm.getNodeNameX(attr);
        String uri = serializer.getNamespaceURIFromPrefix(prefix);
        //      String uri = getURI(prefix);

        if ((null != uri) && uri.equals(dtm.getStringValue(attr)))
            return true;
    }

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


示例4: ensureNamespaceDeclDeclared

import org.apache.xml.dtm.DTM; //导入依赖的package包/类
/**
 * This function checks to make sure a given prefix is really
 * declared.  It might not be, because it may be an excluded prefix.
 * If it's not, it still needs to be declared at this point.
 * TODO: This needs to be done at an earlier stage in the game... -sb
 *
 * NEEDSDOC @param dtm
 * NEEDSDOC @param namespace
 *
 * @throws org.xml.sax.SAXException
 */
public static void ensureNamespaceDeclDeclared(
    SerializationHandler handler,
    DTM dtm,
    int namespace)
    throws org.xml.sax.SAXException
{

    String uri = dtm.getNodeValue(namespace);
    String prefix = dtm.getNodeNameX(namespace);

    if ((uri != null && uri.length() > 0) && (null != prefix))
    {
        String foundURI;
        NamespaceMappings ns = handler.getNamespaceMappings();
        if (ns != null)
        {

            foundURI = ns.lookupNamespace(prefix);
            if ((null == foundURI) || !foundURI.equals(uri))
            {
                handler.startPrefixMapping(prefix, uri, false);
            }
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:37,代码来源:SerializerUtils.java


示例5: getCurrentNode

import org.apache.xml.dtm.DTM; //导入依赖的package包/类
/**
 * Return the last fetched node.  Needed to support the UnionPathIterator.
 *
 * @return the last fetched node.
 * @throws RuntimeException thrown if this NodeSetDTM is not of 
 * a cached type, and thus doesn't permit indexed access.
 */
public int getCurrentNode()
{

  if (!m_cacheNodes)
    throw new RuntimeException(
      "This NodeSetDTM can not do indexing or counting functions!");

  int saved = m_next;
  // because nextNode always increments
  // But watch out for copy29, where the root iterator didn't
  // have nextNode called on it.
  int current = (m_next > 0) ? m_next-1 : m_next; 
  int n = (current < m_firstFree) ? elementAt(current) : DTM.NULL;
  m_next = saved; // HACK: I think this is a bit of a hack.  -sb
  return n;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:24,代码来源:NodeSetDTM.java


示例6: shouldStripWhiteSpace

import org.apache.xml.dtm.DTM; //导入依赖的package包/类
/**
 * Get information about whether or not an element should strip whitespace.
 * @see <a href="http://www.w3.org/TR/xslt#strip">strip in XSLT Specification</a>
 *
 * @param support The XPath runtime state.
 * @param targetElement Element to check
 *
 * @return true if the whitespace should be stripped.
 *
 * @throws TransformerException
 */
public boolean shouldStripWhiteSpace(
        XPathContext support, int targetElement) throws TransformerException
{
  if (null != m_whiteSpaceInfoList)
  {
    while(DTM.NULL != targetElement)
    {
      DTM dtm = support.getDTM(targetElement);
      WhiteSpaceInfo info = (WhiteSpaceInfo) m_whiteSpaceInfoList.getTemplate(support,
              targetElement, null, false, dtm);
      if(null != info)
        return info.getShouldStripSpace();
      
      int parent = dtm.getParent(targetElement);
      if(DTM.NULL != parent && DTM.ELEMENT_NODE == dtm.getNodeType(parent))
        targetElement = parent;
      else
        targetElement = DTM.NULL;
    }
  }
  return false;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:34,代码来源:StylesheetRoot.java


示例7: getArg0AsNumber

import org.apache.xml.dtm.DTM; //导入依赖的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:keplersj,项目名称:In-the-Box-Fork,代码行数:34,代码来源:FunctionDef1Arg.java


示例8: execute

import org.apache.xml.dtm.DTM; //导入依赖的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
{

  int which = getArg0AsNode(xctxt);

  if (DTM.NULL != which)
  {
    // Note that this is a different value than in previous releases
    // of Xalan. It's sensitive to the exact encoding of the node
    // handle anyway, so fighting to maintain backward compatability
    // really didn't make sense; it may change again as we continue
    // to experiment with balancing document and node numbers within
    // that value.
    return new XString("N" + Integer.toHexString(which).toUpperCase());
  }
  else
    return XString.EMPTYSTRING;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:27,代码来源:FuncGenerateId.java


示例9: execute

import org.apache.xml.dtm.DTM; //导入依赖的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:keplersj,项目名称:In-the-Box-Fork,代码行数:30,代码来源:FuncCurrent.java


示例10: getNextNode

import org.apache.xml.dtm.DTM; //导入依赖的package包/类
/**
   * Get the next node via getNextXXX.  Bottlenecked for derived class override.
   * @return The next node on the axis, or DTM.NULL.
   */
  protected int getNextNode()
  {                     
    if(true /* 0 == m_extendedTypeID */)
    {
      m_lastFetched = (DTM.NULL == m_lastFetched)
                   ? m_traverser.first(m_context)
                   : m_traverser.next(m_context, m_lastFetched);
    }
//    else
//    {
//      m_lastFetched = (DTM.NULL == m_lastFetched)
//                   ? m_traverser.first(m_context, m_extendedTypeID)
//                   : m_traverser.next(m_context, m_lastFetched, 
//                                      m_extendedTypeID);
//    }

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


示例11: getSourceTree

import org.apache.xml.dtm.DTM; //导入依赖的package包/类
/**
 * 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,代码行数:28,代码来源:SourceTreeManager.java


示例12: TransformerHandlerImpl

import org.apache.xml.dtm.DTM; //导入依赖的package包/类
/**
 * Construct a TransformerHandlerImpl.
 *
 * @param transformer Non-null reference to the Xalan transformer impl.
 * @param doFragment True if the result should be a document fragement.
 * @param baseSystemID  The system ID to use as the base for relative URLs.
 */
public TransformerHandlerImpl(TransformerImpl transformer,
                              boolean doFragment, String baseSystemID)
{

  super();

  m_transformer = transformer;
  m_baseSystemID = baseSystemID;

  XPathContext xctxt = transformer.getXPathContext();
  DTM dtm = xctxt.getDTM(null, true, transformer, true, true);
  
  m_dtm = dtm;
  dtm.setDocumentBaseURI(baseSystemID);

  m_contentHandler = dtm.getContentHandler();
  m_dtdHandler = dtm.getDTDHandler();
  m_entityResolver = dtm.getEntityResolver();
  m_errorHandler = dtm.getErrorHandler();
  m_lexicalHandler = dtm.getLexicalHandler();
  m_incremental = transformer.getIncremental();
  m_optimizer = transformer.getOptimize();
  m_source_location = transformer.getSource_location();
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:32,代码来源:TransformerHandlerImpl.java


示例13: removeElement

import org.apache.xml.dtm.DTM; //导入依赖的package包/类
/**
 * Removes the first occurrence of the argument from this vector.
 * If the object is found in this vector, each component in the vector
 * with an index greater or equal to the object's index is shifted
 * downward to have an index one smaller than the value it had
 * previously.
 *
 * @param s Node to remove from the list
 *
 * @return True if the node was successfully removed
 */
public boolean removeElement(int s)
{

  if (null == m_map)
    return false;

  for (int i = 0; i < m_firstFree; i++)
  {
    int node = m_map[i];

    if (node == s)
    {
      if (i > m_firstFree)
        System.arraycopy(m_map, i + 1, m_map, i - 1, m_firstFree - i);
      else
        m_map[i] = DTM.NULL;

      m_firstFree--;

      return true;
    }
  }

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


示例14: getNamedItemNS

import org.apache.xml.dtm.DTM; //导入依赖的package包/类
/**
 * Retrieves a node specified by local name and namespace URI. HTML-only
 * DOM implementations do not need to implement this method.
 * @param namespaceURI The namespace URI of the node to retrieve.
 * @param localName The local name of the node to retrieve.
 *
 * @return A <code>Node</code> (of any type) with the specified local
 *   name and namespace URI, or <code>null</code> if they do not
 *   identify any node in this map.
 * @since DOM Level 2
 */
public Node getNamedItemNS(String namespaceURI, String localName)
{
     Node retNode = null;
     for (int n = dtm.getFirstAttribute(element); n != DTM.NULL;
                     n = dtm.getNextAttribute(n))
     {
       if (localName.equals(dtm.getLocalName(n)))
       {
         String nsURI = dtm.getNamespaceURI(n); 
         if ((namespaceURI == null && nsURI == null)
                || (namespaceURI != null && namespaceURI.equals(nsURI)))
         {
           retNode = dtm.getNode(n);
           break;
         }
       }
     }
     return retNode;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:31,代码来源:DTMNamedNodeMap.java


示例15: getHandleFromNode

import org.apache.xml.dtm.DTM; //导入依赖的package包/类
/**
 * 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,代码行数:45,代码来源:DOM2DTM.java


示例16: executeCharsToContentHandler

import org.apache.xml.dtm.DTM; //导入依赖的package包/类
/**
 * 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,代码行数:33,代码来源:FuncNormalizeSpace.java


示例17: endDocument

import org.apache.xml.dtm.DTM; //导入依赖的package包/类
/**
 * Receive notification of the end of the document.
 *
 * %REVIEW% Y'know, this isn't all that much of a deoptimization. We
 * might want to consider folding the start/endDocument changes back
 * into the main SAX2DTM so we don't have to expose so many fields
 * (even as Protected).
 *
 * @throws SAXException Any SAX exception, possibly
 *            wrapping another exception.
 * @see org.xml.sax.ContentHandler#endDocument
 * */
public void endDocument() throws SAXException
{
  charactersFlush();

  m_nextsib.setElementAt(NULL,m_currentDocumentNode);

  if (m_firstch.elementAt(m_currentDocumentNode) == NOTPROCESSED)
    m_firstch.setElementAt(NULL,m_currentDocumentNode);

  if (DTM.NULL != m_previous)
    m_nextsib.setElementAt(DTM.NULL,m_previous);

  m_parents = null;
  m_prefixMappings = null;
  m_contextIndexes = null;

  m_currentDocumentNode= NULL; // no longer open
  m_endDocumentOccured = true;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:32,代码来源:SAX2RTFDTM.java


示例18: getNextNode

import org.apache.xml.dtm.DTM; //导入依赖的package包/类
/**
 * Get the next node in document order on the axes.
 *
 * @return the next node in document order on the axes, or null.
 */
protected int getNextNode()
{
  if (m_foundLast)
    return DTM.NULL;

  int next = m_iterator.next();
  
  if (m_isFresh)
    m_isFresh = false;

  if (DTM.NULL == next)
    this.m_foundLast = true;

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


示例19: returnNextNode

import org.apache.xml.dtm.DTM; //导入依赖的package包/类
/**
 * Bottleneck the return of a next node, to make returns
 * easier from nextNode().
 *
 * @param nextNode The next node found, may be null.
 *
 * @return The same node that was passed as an argument.
 */
protected int returnNextNode(int nextNode)
{

  if (DTM.NULL != nextNode)
  {
    m_pos++;
  }

  m_lastFetched = nextNode;

  if (DTM.NULL == nextNode)
    m_foundLast = true;

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


示例20: getArg0AsString

import org.apache.xml.dtm.DTM; //导入依赖的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:keplersj,项目名称:In-the-Box-Fork,代码行数:32,代码来源:FunctionDef1Arg.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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