本文整理汇总了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;
}
示例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;
}