本文整理汇总了Java中net.sf.saxon.om.NodeInfo.iterateAxis方法的典型用法代码示例。如果您正苦于以下问题:Java NodeInfo.iterateAxis方法的具体用法?Java NodeInfo.iterateAxis怎么用?Java NodeInfo.iterateAxis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.saxon.om.NodeInfo
的用法示例。
在下文中一共展示了NodeInfo.iterateAxis方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOutputProperties
import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
protected Properties getOutputProperties(NodeInfo paramsElem) {
Properties props = new Properties();
paramsElem = unwrapNodeInfo(paramsElem);
AxisIterator iter = paramsElem.iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT);
NodeInfo paramElem;
while ((paramElem = iter.next()) != null) {
props.put(paramElem.getLocalPart(), paramElem.getAttributeValue("", "value"));
}
return props;
}
示例2: parseNode
import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
private void parseNode(NodeInfo node, TopicRefContainer parentTopicRefContainer, String parentTopicId) throws TransformerException {
//logger.info("parseNode: " + node/*.getUnderlyingNode()*/.getDisplayName() + ", " + node.getNodeKind());
//if (node.getNodeKind() == XdmNodeKind.ELEMENT) {
if (node.getNodeKind() == Type.ELEMENT) {
final SaxonNodeWrapper nodeWrapper = new SaxonNodeWrapper(node/*.getUnderlyingNode()*/, bookCache.getXPathCache());
final KeyDef keyDef = KeyDef.fromNode(nodeWrapper, parentTopicId);
if (keyDef != null) {
keyDefList.add(keyDef);
bookCache.addKeyDef(keyDef);
}
final XsltConref xsltConref = XsltConref.fromNode(nodeWrapper, xsltConrefCache);
if (xsltConref != null) {
processXsltConref(xsltConref, parentTopicRefContainer, parentTopicId);
}
final String classAttr = nodeWrapper.getAttribute(DitaUtil.ATTR_CLASS, null);
//logger.info("parsing element: <" + nodeWrapper.getName() + " class=\"" + classAttr + "\">");
if (classAttr != null) {
final TopicRef topicRef = parseTopicRef(nodeWrapper, classAttr, parentTopicRefContainer);
if (topicRef != null) {
parentTopicRefContainer = topicRef; // take it as new parent for child nodes.
}
parseKeyTypeDefNode(nodeWrapper, classAttr);
final String id = nodeWrapper.getAttribute(DitaUtil.ATTR_ID, null);
if ((id != null) && (!id.isEmpty())) {
if (classAttr.contains(DitaUtil.CLASS_TOPIC)) {
addElementId(nodeWrapper, null, id);
parentTopicId = id;
} else {
addElementId(nodeWrapper, parentTopicId, id);
}
}
}
final AxisIterator iterator = node.iterateAxis(AxisInfo.CHILD, NodeKindTest.ELEMENT);
NodeInfo child = iterator.next();
while (child != null) {
parseNode(child, parentTopicRefContainer, parentTopicId);
child = iterator.next();
}
}
}
示例3: createNodeFromNodeInfo
import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
public static Node createNodeFromNodeInfo(NodeInfo nodeInfo,
Document doc, DiffXML.WhitespaceStrippingPolicy whitespaceHandling) {
Node node = null;
switch (nodeInfo.getNodeKind()) {
case Type.TEXT:
String content = nodeInfo.getStringValue();
boolean isWhitespace = Whitespace.isWhite(content);
if (isWhitespace && whitespaceHandling.equals(DiffXML.WhitespaceStrippingPolicy.ALL)) {
break;
}
node = doc.createTextNode(content);
break;
case Type.WHITESPACE_TEXT:
content = nodeInfo.getStringValue();
if (whitespaceHandling.equals(DiffXML.WhitespaceStrippingPolicy.ALL)) {
node = doc.createTextNode(content);
}
break;
case Type.ELEMENT:
if (nodeInfo.getURI().equals("")) {
node = doc.createElement(nodeInfo.getLocalPart());
} else {
node = doc.createElementNS(nodeInfo.getURI(), nodeInfo.getLocalPart());
}
AxisIterator namespaces = nodeInfo.iterateAxis(AxisInfo.NAMESPACE);
NodeInfo ns;
while ((ns = namespaces.next()) != null) {
String localPart = ns.getLocalPart();
String qualifiedName;
if (localPart.equals(""))
qualifiedName = "xmlns";
else
qualifiedName = "xmlns:" + localPart;
((Element) node).setAttributeNS("http://www.w3.org/2000/xmlns/", qualifiedName, ns.getStringValue());
}
AxisIterator attrs = nodeInfo.iterateAxis(AxisInfo.ATTRIBUTE);
NodeInfo attr;
while ((attr = attrs.next()) != null) {
if (attr.getURI().equals("")) {
((Element) node).setAttribute(attr.getLocalPart(), attr.getStringValue());
} else if (attr.getURI().equals(Definitions.NAMESPACEURI_DELTAXML) && attr.getLocalPart().equals("whitespace")) {
String value = attr.getStringValue();
try {
whitespaceHandling = WhitespaceStrippingPolicy.valueOf(value);
} catch (Exception e) {
throw new XSLWebException("Value for whitespace handling not supported: \"" + value + "\"");
}
} else {
((Element) node).setAttributeNS(attr.getURI(), attr.getPrefix() + ":" + attr.getLocalPart(), attr.getStringValue());
}
}
break;
/*
case Type.COMMENT:
treeNode = new CommentNode(nodeInfo.getStringValue());
break;
case Type.PROCESSING_INSTRUCTION:
treeNode = new ProcessingInstructionNode(nodeInfo.getStringValue()); // TODO
break;
*/
}
if (node != null && nodeInfo.hasChildNodes()) {
AxisIterator childs = nodeInfo.iterateAxis(AxisInfo.CHILD);
NodeInfo childNodeInfo;
while ((childNodeInfo = childs.next()) != null) {
Node newNode = createNodeFromNodeInfo(childNodeInfo, doc, whitespaceHandling);
if (newNode != null) {
node.appendChild(newNode);
}
}
}
return node;
}
示例4: 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;
}
示例5: NodeInfoSequence
import net.sf.saxon.om.NodeInfo; //导入方法依赖的package包/类
NodeInfoSequence(NodeInfo nodeInfo, byte axis){
this.nodeInfo = nodeInfo;
this.axis = axis;
iterator = nodeInfo.iterateAxis(axis);
}