本文整理了Java中net.sf.saxon.s9api.XdmDestination.getXdmNode()
方法的一些代码示例,展示了XdmDestination.getXdmNode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XdmDestination.getXdmNode()
方法的具体详情如下:
包路径:net.sf.saxon.s9api.XdmDestination
类名称:XdmDestination
方法名:getXdmNode
[英]Return the node at the root of the tree, after it has been constructed.
This method should not be called while the tree is under construction.
[中]构造完树后,返回树的根节点。
在构建树时不应调用此方法。
代码示例来源:origin: org.daisy.libs/com.xmlcalabash
public XdmNode getResult() {
return destination.getXdmNode();
}
代码示例来源:origin: com.xmlcalabash/xmlcalabash
public XdmNode getResult() {
return destination.getXdmNode();
}
代码示例来源:origin: org.daisy.libs/com.xmlcalabash
public XdmNode getResult() {
return destination.getXdmNode();
}
代码示例来源:origin: com.xmlcalabash/xmlcalabash
public XdmNode getResult() {
return destination.getXdmNode();
}
代码示例来源:origin: org.opengis.cite/schema-utils
private void writeResultsToTempFile(XdmDestination xdmResult) {
File temp = null;
try {
temp = File.createTempFile("SchematronValidator-dump-", ".xml");
BufferedWriter out = new BufferedWriter(new FileWriter(temp));
out.write(xdmResult.getXdmNode().toString());
out.close();
} catch (IOException e) {
LOGR.warning(e.getMessage());
}
if (temp.exists()) {
LOGR.log(Level.FINER, "Dumped Schematron results to {0}", temp.getAbsolutePath());
}
}
代码示例来源:origin: org.daisy.pipeline/common-utils
public XdmNode doneWriting() throws TransformerException {
try {
receiver.close();
return destination.getXdmNode();
} catch (XPathException e) {
throw new TransformerException(e);
}
}
};
代码示例来源:origin: org.daisy.pipeline/common-utils
public XdmNode transform(XdmNode xml, Map<String, Object> parameters)
throws SaxonApiException {
XdmDestination dest = new XdmDestination();
genericTransform(xml, parameters, dest);
return dest.getXdmNode();
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
@Override
public Sequence<?> getPrimaryResult() throws XPathException {
XdmNode node = destination.getXdmNode();
return node == null ? null : postProcess(baseOutputUri, node.getUnderlyingNode());
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
@Override
public Sequence<?> getPrimaryResult() throws XPathException {
XdmNode node = destination.getXdmNode();
return node == null ? null : postProcess(baseOutputUri, node.getUnderlyingNode());
}
代码示例来源:origin: org.daisy.libs/com.xmlcalabash
public XdmNode read() throws SaxonApiException {
read = true;
if (doc != null) {
return doc;
}
if (nodes != null) {
// Find the document element so we can get the base URI
XdmNode node = null;
for (int pos = 0; pos < nodes.size() && node == null; pos++) {
if (((XdmNode) nodes.get(pos)).getNodeKind() == XdmNodeKind.ELEMENT) {
node = (XdmNode) nodes.get(pos);
}
}
XdmDestination dest = new XdmDestination();
try {
S9apiUtils.writeXdmValue(cfgProcessor, nodes, dest, node.getBaseURI());
doc = dest.getXdmNode();
if (excludeUris.size() != 0) {
doc = S9apiUtils.removeNamespaces(cfgProcessor, doc, excludeUris, true);
}
} catch (SaxonApiException sae) {
throw new XProcException(sae);
}
} else {
doc = readXML(href, base);
}
return doc;
}
代码示例来源:origin: com.xmlcalabash/xmlcalabash
public XdmNode read() throws SaxonApiException {
read = true;
if (doc != null) {
return doc;
}
if (nodes != null) {
// Find the document element so we can get the base URI
XdmNode node = null;
for (int pos = 0; pos < nodes.size() && node == null; pos++) {
if (((XdmNode) nodes.get(pos)).getNodeKind() == XdmNodeKind.ELEMENT) {
node = (XdmNode) nodes.get(pos);
}
}
XdmDestination dest = new XdmDestination();
try {
S9apiUtils.writeXdmValue(cfgProcessor, nodes, dest, node.getBaseURI());
doc = dest.getXdmNode();
if (excludeUris.size() != 0) {
doc = S9apiUtils.removeNamespaces(cfgProcessor, doc, excludeUris, true);
}
} catch (SaxonApiException sae) {
throw new XProcException(sae);
}
} else {
doc = readXML(href, base);
}
return doc;
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
@Override
public Receiver resolve(XPathContext context, String href, String baseUri, SerializationProperties properties) throws XPathException {
URI absolute = getAbsoluteUri(href, baseUri);
XdmDestination destination = new XdmDestination();
destination.setDestinationBaseURI(absolute);
destination.onClose(() -> {
XdmNode root = destination.getXdmNode();
results.put(absolute.toASCIIString(), root.getUnderlyingValue().getTreeInfo());
});
return destination.getReceiver(context.getReceiver().getPipelineConfiguration(), properties);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
@Override
public Receiver resolve(XPathContext context, String href, String baseUri, SerializationProperties properties) throws XPathException {
URI absolute = getAbsoluteUri(href, baseUri);
XdmDestination destination = new XdmDestination();
destination.setDestinationBaseURI(absolute);
destination.onClose(() -> {
XdmNode root = destination.getXdmNode();
results.put(absolute.toASCIIString(), root.getUnderlyingValue().getTreeInfo());
});
return destination.getReceiver(context.getReceiver().getPipelineConfiguration(), properties);
}
代码示例来源:origin: org.opengis.cite/schema-utils
/**
* Counts all rule violations: failed asserts and successful reports).
*
* @param results
* The validation results (svrl:schematron-output).
* @return An integer value.
*/
private int countRuleViolations(XdmDestination results) {
XPathCompiler xpath = processor.newXPathCompiler();
xpath.declareNamespace("svrl", ISO_SCHEMATRON_SVRL_NS);
XdmAtomicValue totalCount = null;
try {
XPathExecutable exe = xpath.compile("count(//svrl:failed-assert) + count(//svrl:successful-report)");
XPathSelector selector = exe.load();
selector.setContextItem(results.getXdmNode());
totalCount = (XdmAtomicValue) selector.evaluateSingle();
} catch (SaxonApiException e) {
LOGR.warning(e.getMessage());
}
return Integer.parseInt(totalCount.getValue().toString());
}
代码示例来源:origin: msokolov/lux
@Override
public void close(Result result) throws TransformerException {
XdmDestinationProxy receiver = (XdmDestinationProxy) result;
if (docWriter == null) {
throw new TransformerException ("Attempted to write document " + receiver.getSystemId() + " to a read-only Evaluator");
}
docWriter.write(receiver.dest.getXdmNode().getUnderlyingNode(), receiver.getSystemId());
}
代码示例来源:origin: org.daisy.libs/com.xmlcalabash
private XdmNode transform(XdmNode source, SAXSource stylesheet) throws SaxonApiException {
XsltCompiler compiler = runtime.getProcessor().newXsltCompiler();
compiler.setSchemaAware(schemaAware);
compiler.setURIResolver(new UResolver());
XsltExecutable exec = compiler.compile(stylesheet);
XsltTransformer schemaCompiler = exec.load();
schemaCompiler.setInitialContextNode(source);
XdmDestination result = new XdmDestination();
schemaCompiler.setDestination(result);
schemaCompiler.transform();
return result.getXdmNode();
}
代码示例来源:origin: com.xmlcalabash/xmlcalabash
private XdmNode transform(XdmNode source, SAXSource stylesheet) throws SaxonApiException {
XsltCompiler compiler = runtime.getProcessor().newXsltCompiler();
compiler.setSchemaAware(schemaAware);
compiler.setURIResolver(new UResolver());
XsltExecutable exec = compiler.compile(stylesheet);
XsltTransformer schemaCompiler = exec.load();
schemaCompiler.setInitialContextNode(source);
XdmDestination result = new XdmDestination();
schemaCompiler.setDestination(result);
schemaCompiler.transform();
return result.getXdmNode();
}
代码示例来源:origin: ndw/xmlcalabash1
public void run() throws SaxonApiException {
Processor processor = new Processor(true);
SchemaManager manager = processor.getSchemaManager();
// No resolver here, there isn't one.
DocumentBuilder builder = processor.newDocumentBuilder();
SAXSource source = new SAXSource(new InputSource("http://tests.xproc.org/tests/doc/compoundEntity.xml"));
XdmNode document = builder.build(source);
source = new SAXSource(new InputSource("http://tests.xproc.org/tests/doc/document.xsd"));
XdmNode schema = builder.build(source);
manager.load(schema.asSource());
XdmDestination destination = new XdmDestination();
Controller controller = new Controller(processor.getUnderlyingConfiguration());
Receiver receiver = destination.getReceiver(controller.getConfiguration());
PipelineConfiguration pipe = controller.makePipelineConfiguration();
pipe.setRecoverFromValidationErrors(false);
receiver.setPipelineConfiguration(pipe);
SchemaValidator validator = manager.newSchemaValidator();
validator.setDestination(destination);
dumpTree(document, "Input");
validator.validate(document.asSource());
XdmNode valid = destination.getXdmNode();
dumpTree(valid, "Output");
}
代码示例来源:origin: org.daisy.libs/com.xmlcalabash
public void close(Result result) throws TransformerException {
String href = result.getSystemId();
XdmDestination xdmResult = secondaryResults.get(href);
XdmNode doc = xdmResult.getXdmNode();
try {
S9apiUtils.assertDocument(doc);
secondaryPipe.write(doc);
} catch (XProcException e) {
// If the document isn't well-formed XML, encode it as text
if (runtime.getAllowTextResults()) {
// Document is apparently not well-formed XML.
TreeWriter tree = new TreeWriter(runtime);
tree.startDocument(doc.getBaseURI());
tree.addStartElement(XProcConstants.c_result);
tree.addAttribute(_content_type, "text/plain");
tree.addAttribute(cx_decode, "true");
tree.startContent();
tree.addText(doc.toString());
tree.addEndElement();
tree.endDocument();
secondaryPipe.write(tree.getResult());
} else {
throw new XProcException(step.getStep(), "p:xslt returned non-XML secondary result", e.getCause());
}
}
}
}
代码示例来源:origin: org.daisy.libs/com.xmlcalabash
protected String serialize(XdmNode doc, MediaType type) {
XProcRuntime runtime = getGlobalRuntime();
String format = "text";
if (MediaType.TEXT_HTML.equals(type)) {
format = "html";
} else if (MediaType.APPLICATION_XML.equals(type)) {
format = "xml";
} else if (MediaType.APPLICATION_JSON.equals(type)) {
format = "json";
}
if (xsl() != null) {
XdmDestination result = null;
try {
XsltCompiler compiler = runtime.getProcessor().newXsltCompiler();
XsltExecutable exec = compiler.compile(xsl().asSource());
XsltTransformer transformer = exec.load();
transformer.setParameter(_format, new XdmAtomicValue(format));
transformer.setInitialContextNode(doc);
result = new XdmDestination();
transformer.setDestination(result);
transformer.transform();
} catch (SaxonApiException e) {
throw new XProcException(e);
}
doc = result.getXdmNode();
}
return doc.toString();
}
内容来源于网络,如有侵权,请联系作者删除!