本文整理汇总了Java中net.sf.saxon.om.NodeInfo.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java NodeInfo.getParent方法的具体用法?Java NodeInfo.getParent怎么用?Java NodeInfo.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.saxon.om.NodeInfo
的用法示例。
在下文中一共展示了NodeInfo.getParent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeNodeInfo
import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
private void initializeNodeInfo(@Nullable NodeInfo nodeInfo) {
if (nodeInfo == null) {
return;
}
int nodeKind = nodeInfo.getNodeKind();
NodeInfo elemInfo = null;
if (nodeKind == Type.ATTRIBUTE) {
this.attrQname = new QName(nodeInfo.getPrefix(), nodeInfo.getURI(), nodeInfo.getLocalPart());
elemInfo = nodeInfo.getParent();
} else if (nodeKind == Type.ELEMENT) {
elemInfo = nodeInfo;
}
if (elemInfo == null) {
return;
}
this.elemQname = new QName(elemInfo.getPrefix(), elemInfo.getURI(), elemInfo.getLocalPart());
}
示例2: selectID
import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
/**
* Get the element with a given ID, if any
*
* @param id
* the required ID value
* @param getParent
* true if running the element-with-id() function rather than the id()
* function; the difference is that in the case of an element of type xs:ID,
* the parent of the element should be returned, not the element itself.
* @return the element with the given ID, or null if there is no such ID
* present (or if the parser has not notified attributes as being of
* type ID).
*/
public NodeInfo selectID(String id, boolean getParent) {
if (idIndex == null) {
Element elem;
switch (nodeKind) {
case Type.DOCUMENT :
elem = ((Document) node).getRootElement();
break;
case Type.ELEMENT :
elem = (Element) node;
break;
default:
return null;
}
idIndex = new HashMap(50);
buildIDIndex(elem);
}
NodeInfo result = (NodeInfo) idIndex.get(id);
if (result != null && getParent && result.isId() && result.getStringValue().equals(id)) {
result = result.getParent();
}
return result ;
}
示例3: buildSegments
import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
private static LinkedList<ContentPathSegment<?, ?>> buildSegments(LinkedList<ContentPathSegment<?, ?>> segments, NodeInfo nodeInfo,
@Nullable String nsPrefix, @Nullable String nsUri, String localName) {
boolean attrNode = (nodeInfo.getNodeKind() == Type.ATTRIBUTE);
if (attrNode) {
segments.add(0, new AttributePathSegmentImpl(nsPrefix, nsUri, localName));
}
ElementPathSegment elemSegment = new ElementPathSegmentImpl(nsPrefix, nsUri, localName);
segments.add(0, elemSegment);
NodeInfo parentNodeInfo = nodeInfo.getParent();
if ((parentNodeInfo != null) && (parentNodeInfo.getNodeKind() != Type.DOCUMENT)) {
if (!attrNode) {
int nodeIndex = -1;
SameNameTest siblingNodeTest = new SameNameTest(nodeInfo);
AxisIterator precedingSiblingNodeIterator = nodeInfo.iterateAxis(AxisInfo.PRECEDING_SIBLING, siblingNodeTest);
while (precedingSiblingNodeIterator.next() != null) {
nodeIndex++;
}
if (nodeIndex == -1) {
if (nodeInfo.iterateAxis(AxisInfo.FOLLOWING_SIBLING, siblingNodeTest).next() != null) {
nodeIndex = 0;
}
} else {
nodeIndex++;
}
if (nodeIndex >= 0) {
elemSegment.setIndex(nodeIndex);
}
}
buildSegments(segments, parentNodeInfo, parentNodeInfo.getPrefix(), parentNodeInfo.getURI(), parentNodeInfo.getLocalPart());
}
return segments;
}
示例4: parent
import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
@Override
public NodeInfo parent(NodeInfo node){
return node.getParent();
}