本文整理汇总了Java中net.sf.saxon.s9api.XdmNode.getNodeKind方法的典型用法代码示例。如果您正苦于以下问题:Java XdmNode.getNodeKind方法的具体用法?Java XdmNode.getNodeKind怎么用?Java XdmNode.getNodeKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.saxon.s9api.XdmNode
的用法示例。
在下文中一共展示了XdmNode.getNodeKind方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildWhen
import net.sf.saxon.s9api.XdmNode; //导入方法依赖的package包/类
private WhenEntry buildWhen(XdmNode whenNode, HashMap<QName,ParameterValue> parameters) throws InvalidSyntaxException {
String test = whenNode.getAttributeValue(WhenEntry.ATTR_TEST);
// particular case of the otherwise, which is implemented as a when[@test='true()']
if((test==null || test.length()==0) && WhenEntry.QN_OTHERWISE.equals(whenNode.getNodeName()) ) {
test="true()";
}
WhenEntry when = new WhenEntry(test);
XdmSequenceIterator it = whenNode.axisIterator(Axis.CHILD);
while(it.hasNext()) {
XdmItem item = it.next();
if(item instanceof XdmNode) {
XdmNode node = (XdmNode)item;
if(Xslt.QNAME.equals(node.getNodeName())) {
when.addStep(buildXslt(node,parameters));
} else if(JavaStep.QNAME.equals(node.getNodeName())) {
when.addStep(buildJavaStep(node, parameters));
} else if(ChooseStep.QNAME.equals(node.getNodeName())) {
when.addStep(buildChooseStep(node, parameters));
} else if(node.getNodeKind()==XdmNodeKind.TEXT) {
// on ignore
} else if(node.getNodeKind()==XdmNodeKind.COMMENT) {
// on ignore
} else {
throw new InvalidSyntaxException(node.getNodeKind().toString()+" - "+ node.getNodeName()+": unexpected element in "+Pipe.QNAME);
}
}
}
return when;
}
示例2: parseFile
import net.sf.saxon.s9api.XdmNode; //导入方法依赖的package包/类
private void parseFile(String fileHddCachePath) {
//logger.info("parseFile: " + decodedUrl);
try {
containsUncachableXsltConref = false;
isFileParsed = true; // on failure the value remains true since a reparsing makes no sense.
final XdmNode rootNode = bookCache.getDocumentBuilder().build(source, expandAttributeDefaults);
final XdmSequenceIterator iterator = rootNode.axisIterator(Axis.CHILD);
//logger.info(SaxonNodeWrapper.serializeNode(rootNode.getUnderlyingNode()));
rootElement = null;
while ((iterator.hasNext()) && (rootElement == null)) {
final XdmNode child =(XdmNode)iterator.next();
//logger.info(" node: " + node.getNodeName() + ", " + node.getNodeKind());
if (child.getNodeKind() == XdmNodeKind.ELEMENT) {
rootElement = new SaxonNodeWrapper(child.getUnderlyingNode(), bookCache.getXPathCache());
}
}
if (rootElement != null) {
parseNode(rootElement.getNodeInfo(), this, null);
rootClass = rootElement.getAttribute(DitaUtil.ATTR_CLASS, null);
rootTitle = extractString(rootElement, LINK_TITLE_XSL);
rootName = rootElement.getName();
if ((fileHddCachePath != null) && (isHddCachable())) {
writeHddCache(fileHddCachePath, fileTimestamp);
}
}
} catch(SaxonApiException | TransformerException e) {
logger.error(e, e);
rootElement = null;
}
}
示例3: addRecordValues
import net.sf.saxon.s9api.XdmNode; //导入方法依赖的package包/类
protected boolean addRecordValues(XdmNode node, Axis axis, XdmNodeKind nodeTest, Record record) {
boolean isEmpty = true;
XdmSequenceIterator iter = node.axisIterator(axis);
while (iter.hasNext()) {
XdmNode child = (XdmNode) iter.next();
if (child.getNodeKind() == nodeTest) {
String strValue = child.getStringValue();
if (strValue.length() > 0) {
record.put(child.getNodeName().getLocalName(), strValue);
isEmpty = false;
}
}
}
return !isEmpty;
}
示例4: getLabel
import net.sf.saxon.s9api.XdmNode; //导入方法依赖的package包/类
static String getLabel(XdmNode n) {
String label = n.getAttributeValue(LABEL_QNAME);
if (label == null) {
XdmNode value = (XdmNode) n.axisIterator(Axis.CHILD).next();
XdmItem childItem = null;
try {
childItem = value.axisIterator(Axis.CHILD).next();
} catch (Exception e) {
// Not an error
}
if (childItem == null) {
XdmSequenceIterator it = value.axisIterator(Axis.ATTRIBUTE);
if (it.hasNext()) {
label = it.next().getStringValue();
} else {
label = "";
}
} else if (childItem.isAtomicValue()) {
label = childItem.getStringValue();
} else if (childItem instanceof XdmNode) {
XdmNode n2 = (XdmNode) childItem;
if (n2.getNodeKind() == XdmNodeKind.ELEMENT) {
label = "<" + n2.getNodeName().toString() + ">";
} else {
label = n2.toString();
}
}
}
return label;
}
示例5: evaluateResults
import net.sf.saxon.s9api.XdmNode; //导入方法依赖的package包/类
private void evaluateResults(List<ValidatorEvent> events, XPathSet xPathSet, String baseXPathExpression, ExpectedResults xPathSetContent)
throws SaxonApiException, XPathException {
ValidatorLocation loc;
CrigttLocation locObj;
boolean assertionStatus = false;
boolean xPathComparisonElementResult = xPathSet.getXPathResultComparison() && xPathSet.getElementNodeKindExpected();
ValidatorEvent event = CrigttTestcaseUtils.setEventDetails(loc = new ValidatorLocationImpl());
events.add(event);
loc.setNodeExpression(baseXPathExpression);
List<String> expectedResults =
CrigttTestcaseUtils.addNullFlavors(xPathSetContent.getIncludeNullFlavors(), this.nullFlavors, xPathSetContent.getExpectedResults());
List<XdmNode> locNodes = Arrays.asList(this.xpathCompiler.evaluateNodes(xPathSet.getXPathExpression(), this.xpathContext, this.doc));
MatchingCondition matchingCondition = xPathSet.getMatchingCondition();
Set<String> expectedXPathResults = new HashSet<>(expectedResults.size());
List<XdmNode> xPathNodeResults = new ArrayList<>(expectedResults.size());
for (XdmNode locNode : locNodes) {
if (locNode != null) {
loc.setColumnNumber((locObj = new CrigttLocation(locNode.getUnderlyingNode())).getColumnNumber());
loc.setLineNumber(locObj.getLineNumber());
XdmNodeKind locNodeKind = locNode.getNodeKind();
String actualResult = (locNodeKind == XdmNodeKind.ATTRIBUTE || locNodeKind == XdmNodeKind.TEXT) ? locNode.getStringValue() : locNode.toString();
if (xPathSet.getXPathResultComparison()) {
for (String expectedResult : expectedResults) {
XdmNode resultNode = this.xpathCompiler.evaluateNode(expectedResult, this.xpathContext, this.doc);
if (resultNode != null) {
XdmNodeKind nodeKind = resultNode.getNodeKind();
if (nodeKind == XdmNodeKind.ATTRIBUTE || nodeKind == XdmNodeKind.TEXT) {
expectedXPathResults.add(resultNode.getStringValue());
} else if (nodeKind == XdmNodeKind.ELEMENT) {
xPathNodeResults.add(resultNode);
}
}
}
assertionStatus = xPathSet.getElementNodeKindExpected()
? CrigttTestcaseUtils.getAssertionStatus(xPathNodeResults, locNode, this.xpathContext.getConfiguration(), matchingCondition)
: CrigttTestcaseUtils.getAssertionStatus(new ArrayList<>(expectedXPathResults), actualResult, baseXPathExpression, matchingCondition);
} else {
assertionStatus = CrigttTestcaseUtils.getAssertionStatus(expectedResults, actualResult, baseXPathExpression, matchingCondition);
}
event.setActualResult(actualResult);
if (assertionStatus) {
break;
}
} else {
assertionStatus =
expectedResults.isEmpty() || CrigttTestcaseUtils.getAssertionStatus(
xPathComparisonElementResult ? (expectedResults = findEmptyResult(expectedResults)) : expectedResults, CrigttTestcaseUtils.EMPTY_RESULT,
baseXPathExpression);
}
}
if (locNodes.size() == 0) {
assertionStatus =
expectedResults.isEmpty() || CrigttTestcaseUtils.getAssertionStatus(
xPathComparisonElementResult ? (expectedResults = findEmptyResult(expectedResults)) : expectedResults, CrigttTestcaseUtils.EMPTY_RESULT,
baseXPathExpression);
}
if (expectedXPathResults.size() > 0) {
expectedResults.addAll(expectedXPathResults);
} else if (xPathComparisonElementResult && xPathNodeResults.size() > 0) {
expectedResults.addAll(new HashSet<>(xPathNodeResults).stream().map(XdmNode::toString).collect(Collectors.toList()));
}
event.setExpectedResults(expectedResults);
event.setStatus(assertionStatus);
}