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


Java DTM.getPreviousSibling方法代码示例

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


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

示例1: getNumberSimple

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

示例2: findPrecedingOrAncestorOrSelf

import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
 * Given a 'from' pattern (ala xsl:number), a match pattern
 * and a context, find the first ancestor that matches the
 * pattern (including the context handed in).
 * @param xctxt The XPath runtime state for this.
 * @param fromMatchPattern The ancestor must match this pattern.
 * @param countMatchPattern The ancestor must also match this pattern.
 * @param context The node that "." expresses.
 * @param namespaceContext The context in which namespaces in the
 * queries are supposed to be expanded.
 *
 * @return the first preceding, ancestor or self node that 
 * matches the given pattern
 *
 * @throws javax.xml.transform.TransformerException
 */
private int findPrecedingOrAncestorOrSelf(
        XPathContext xctxt, XPath fromMatchPattern, XPath countMatchPattern, 
        int context, ElemNumber namespaceContext)
          throws javax.xml.transform.TransformerException
{
  DTM dtm = xctxt.getDTM(context);
  while (DTM.NULL != context)
  {
    if (null != fromMatchPattern)
    {
      if (fromMatchPattern.getMatchScore(xctxt, context)
              != XPath.MATCH_SCORE_NONE)
      {
        context = DTM.NULL;

        break;
      }
    }

    if (null != countMatchPattern)
    {
      if (countMatchPattern.getMatchScore(xctxt, context)
              != XPath.MATCH_SCORE_NONE)
      {
        break;
      }
    }

    int prevSibling = dtm.getPreviousSibling(context);

    if (DTM.NULL == prevSibling)
    {
      context = dtm.getParent(context);
    }
    else
    {

      // Now go down the chain of children of this sibling 
      context = dtm.getLastChild(prevSibling);

      if (context == DTM.NULL)
        context = prevSibling;
    }
  }

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


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