net.sf.saxon.s9api.XdmDestination.getXdmNode()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(184)

本文整理了Java中net.sf.saxon.s9api.XdmDestination.getXdmNode()方法的一些代码示例,展示了XdmDestination.getXdmNode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XdmDestination.getXdmNode()方法的具体详情如下:
包路径:net.sf.saxon.s9api.XdmDestination
类名称:XdmDestination
方法名:getXdmNode

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

  1. public XdmNode getResult() {
  2. return destination.getXdmNode();
  3. }

代码示例来源:origin: com.xmlcalabash/xmlcalabash

  1. public XdmNode getResult() {
  2. return destination.getXdmNode();
  3. }

代码示例来源:origin: org.daisy.libs/com.xmlcalabash

  1. public XdmNode getResult() {
  2. return destination.getXdmNode();
  3. }

代码示例来源:origin: com.xmlcalabash/xmlcalabash

  1. public XdmNode getResult() {
  2. return destination.getXdmNode();
  3. }

代码示例来源:origin: org.opengis.cite/schema-utils

  1. private void writeResultsToTempFile(XdmDestination xdmResult) {
  2. File temp = null;
  3. try {
  4. temp = File.createTempFile("SchematronValidator-dump-", ".xml");
  5. BufferedWriter out = new BufferedWriter(new FileWriter(temp));
  6. out.write(xdmResult.getXdmNode().toString());
  7. out.close();
  8. } catch (IOException e) {
  9. LOGR.warning(e.getMessage());
  10. }
  11. if (temp.exists()) {
  12. LOGR.log(Level.FINER, "Dumped Schematron results to {0}", temp.getAbsolutePath());
  13. }
  14. }

代码示例来源:origin: org.daisy.pipeline/common-utils

  1. public XdmNode doneWriting() throws TransformerException {
  2. try {
  3. receiver.close();
  4. return destination.getXdmNode();
  5. } catch (XPathException e) {
  6. throw new TransformerException(e);
  7. }
  8. }
  9. };

代码示例来源:origin: org.daisy.pipeline/common-utils

  1. public XdmNode transform(XdmNode xml, Map<String, Object> parameters)
  2. throws SaxonApiException {
  3. XdmDestination dest = new XdmDestination();
  4. genericTransform(xml, parameters, dest);
  5. return dest.getXdmNode();
  6. }

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. @Override
  2. public Sequence<?> getPrimaryResult() throws XPathException {
  3. XdmNode node = destination.getXdmNode();
  4. return node == null ? null : postProcess(baseOutputUri, node.getUnderlyingNode());
  5. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

  1. @Override
  2. public Sequence<?> getPrimaryResult() throws XPathException {
  3. XdmNode node = destination.getXdmNode();
  4. return node == null ? null : postProcess(baseOutputUri, node.getUnderlyingNode());
  5. }

代码示例来源:origin: org.daisy.libs/com.xmlcalabash

  1. public XdmNode read() throws SaxonApiException {
  2. read = true;
  3. if (doc != null) {
  4. return doc;
  5. }
  6. if (nodes != null) {
  7. // Find the document element so we can get the base URI
  8. XdmNode node = null;
  9. for (int pos = 0; pos < nodes.size() && node == null; pos++) {
  10. if (((XdmNode) nodes.get(pos)).getNodeKind() == XdmNodeKind.ELEMENT) {
  11. node = (XdmNode) nodes.get(pos);
  12. }
  13. }
  14. XdmDestination dest = new XdmDestination();
  15. try {
  16. S9apiUtils.writeXdmValue(cfgProcessor, nodes, dest, node.getBaseURI());
  17. doc = dest.getXdmNode();
  18. if (excludeUris.size() != 0) {
  19. doc = S9apiUtils.removeNamespaces(cfgProcessor, doc, excludeUris, true);
  20. }
  21. } catch (SaxonApiException sae) {
  22. throw new XProcException(sae);
  23. }
  24. } else {
  25. doc = readXML(href, base);
  26. }
  27. return doc;
  28. }

代码示例来源:origin: com.xmlcalabash/xmlcalabash

  1. public XdmNode read() throws SaxonApiException {
  2. read = true;
  3. if (doc != null) {
  4. return doc;
  5. }
  6. if (nodes != null) {
  7. // Find the document element so we can get the base URI
  8. XdmNode node = null;
  9. for (int pos = 0; pos < nodes.size() && node == null; pos++) {
  10. if (((XdmNode) nodes.get(pos)).getNodeKind() == XdmNodeKind.ELEMENT) {
  11. node = (XdmNode) nodes.get(pos);
  12. }
  13. }
  14. XdmDestination dest = new XdmDestination();
  15. try {
  16. S9apiUtils.writeXdmValue(cfgProcessor, nodes, dest, node.getBaseURI());
  17. doc = dest.getXdmNode();
  18. if (excludeUris.size() != 0) {
  19. doc = S9apiUtils.removeNamespaces(cfgProcessor, doc, excludeUris, true);
  20. }
  21. } catch (SaxonApiException sae) {
  22. throw new XProcException(sae);
  23. }
  24. } else {
  25. doc = readXML(href, base);
  26. }
  27. return doc;
  28. }

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. @Override
  2. public Receiver resolve(XPathContext context, String href, String baseUri, SerializationProperties properties) throws XPathException {
  3. URI absolute = getAbsoluteUri(href, baseUri);
  4. XdmDestination destination = new XdmDestination();
  5. destination.setDestinationBaseURI(absolute);
  6. destination.onClose(() -> {
  7. XdmNode root = destination.getXdmNode();
  8. results.put(absolute.toASCIIString(), root.getUnderlyingValue().getTreeInfo());
  9. });
  10. return destination.getReceiver(context.getReceiver().getPipelineConfiguration(), properties);
  11. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

  1. @Override
  2. public Receiver resolve(XPathContext context, String href, String baseUri, SerializationProperties properties) throws XPathException {
  3. URI absolute = getAbsoluteUri(href, baseUri);
  4. XdmDestination destination = new XdmDestination();
  5. destination.setDestinationBaseURI(absolute);
  6. destination.onClose(() -> {
  7. XdmNode root = destination.getXdmNode();
  8. results.put(absolute.toASCIIString(), root.getUnderlyingValue().getTreeInfo());
  9. });
  10. return destination.getReceiver(context.getReceiver().getPipelineConfiguration(), properties);
  11. }

代码示例来源:origin: org.opengis.cite/schema-utils

  1. /**
  2. * Counts all rule violations: failed asserts and successful reports).
  3. *
  4. * @param results
  5. * The validation results (svrl:schematron-output).
  6. * @return An integer value.
  7. */
  8. private int countRuleViolations(XdmDestination results) {
  9. XPathCompiler xpath = processor.newXPathCompiler();
  10. xpath.declareNamespace("svrl", ISO_SCHEMATRON_SVRL_NS);
  11. XdmAtomicValue totalCount = null;
  12. try {
  13. XPathExecutable exe = xpath.compile("count(//svrl:failed-assert) + count(//svrl:successful-report)");
  14. XPathSelector selector = exe.load();
  15. selector.setContextItem(results.getXdmNode());
  16. totalCount = (XdmAtomicValue) selector.evaluateSingle();
  17. } catch (SaxonApiException e) {
  18. LOGR.warning(e.getMessage());
  19. }
  20. return Integer.parseInt(totalCount.getValue().toString());
  21. }

代码示例来源:origin: msokolov/lux

  1. @Override
  2. public void close(Result result) throws TransformerException {
  3. XdmDestinationProxy receiver = (XdmDestinationProxy) result;
  4. if (docWriter == null) {
  5. throw new TransformerException ("Attempted to write document " + receiver.getSystemId() + " to a read-only Evaluator");
  6. }
  7. docWriter.write(receiver.dest.getXdmNode().getUnderlyingNode(), receiver.getSystemId());
  8. }

代码示例来源:origin: org.daisy.libs/com.xmlcalabash

  1. private XdmNode transform(XdmNode source, SAXSource stylesheet) throws SaxonApiException {
  2. XsltCompiler compiler = runtime.getProcessor().newXsltCompiler();
  3. compiler.setSchemaAware(schemaAware);
  4. compiler.setURIResolver(new UResolver());
  5. XsltExecutable exec = compiler.compile(stylesheet);
  6. XsltTransformer schemaCompiler = exec.load();
  7. schemaCompiler.setInitialContextNode(source);
  8. XdmDestination result = new XdmDestination();
  9. schemaCompiler.setDestination(result);
  10. schemaCompiler.transform();
  11. return result.getXdmNode();
  12. }

代码示例来源:origin: com.xmlcalabash/xmlcalabash

  1. private XdmNode transform(XdmNode source, SAXSource stylesheet) throws SaxonApiException {
  2. XsltCompiler compiler = runtime.getProcessor().newXsltCompiler();
  3. compiler.setSchemaAware(schemaAware);
  4. compiler.setURIResolver(new UResolver());
  5. XsltExecutable exec = compiler.compile(stylesheet);
  6. XsltTransformer schemaCompiler = exec.load();
  7. schemaCompiler.setInitialContextNode(source);
  8. XdmDestination result = new XdmDestination();
  9. schemaCompiler.setDestination(result);
  10. schemaCompiler.transform();
  11. return result.getXdmNode();
  12. }

代码示例来源:origin: ndw/xmlcalabash1

  1. public void run() throws SaxonApiException {
  2. Processor processor = new Processor(true);
  3. SchemaManager manager = processor.getSchemaManager();
  4. // No resolver here, there isn't one.
  5. DocumentBuilder builder = processor.newDocumentBuilder();
  6. SAXSource source = new SAXSource(new InputSource("http://tests.xproc.org/tests/doc/compoundEntity.xml"));
  7. XdmNode document = builder.build(source);
  8. source = new SAXSource(new InputSource("http://tests.xproc.org/tests/doc/document.xsd"));
  9. XdmNode schema = builder.build(source);
  10. manager.load(schema.asSource());
  11. XdmDestination destination = new XdmDestination();
  12. Controller controller = new Controller(processor.getUnderlyingConfiguration());
  13. Receiver receiver = destination.getReceiver(controller.getConfiguration());
  14. PipelineConfiguration pipe = controller.makePipelineConfiguration();
  15. pipe.setRecoverFromValidationErrors(false);
  16. receiver.setPipelineConfiguration(pipe);
  17. SchemaValidator validator = manager.newSchemaValidator();
  18. validator.setDestination(destination);
  19. dumpTree(document, "Input");
  20. validator.validate(document.asSource());
  21. XdmNode valid = destination.getXdmNode();
  22. dumpTree(valid, "Output");
  23. }

代码示例来源:origin: org.daisy.libs/com.xmlcalabash

  1. public void close(Result result) throws TransformerException {
  2. String href = result.getSystemId();
  3. XdmDestination xdmResult = secondaryResults.get(href);
  4. XdmNode doc = xdmResult.getXdmNode();
  5. try {
  6. S9apiUtils.assertDocument(doc);
  7. secondaryPipe.write(doc);
  8. } catch (XProcException e) {
  9. // If the document isn't well-formed XML, encode it as text
  10. if (runtime.getAllowTextResults()) {
  11. // Document is apparently not well-formed XML.
  12. TreeWriter tree = new TreeWriter(runtime);
  13. tree.startDocument(doc.getBaseURI());
  14. tree.addStartElement(XProcConstants.c_result);
  15. tree.addAttribute(_content_type, "text/plain");
  16. tree.addAttribute(cx_decode, "true");
  17. tree.startContent();
  18. tree.addText(doc.toString());
  19. tree.addEndElement();
  20. tree.endDocument();
  21. secondaryPipe.write(tree.getResult());
  22. } else {
  23. throw new XProcException(step.getStep(), "p:xslt returned non-XML secondary result", e.getCause());
  24. }
  25. }
  26. }
  27. }

代码示例来源:origin: org.daisy.libs/com.xmlcalabash

  1. protected String serialize(XdmNode doc, MediaType type) {
  2. XProcRuntime runtime = getGlobalRuntime();
  3. String format = "text";
  4. if (MediaType.TEXT_HTML.equals(type)) {
  5. format = "html";
  6. } else if (MediaType.APPLICATION_XML.equals(type)) {
  7. format = "xml";
  8. } else if (MediaType.APPLICATION_JSON.equals(type)) {
  9. format = "json";
  10. }
  11. if (xsl() != null) {
  12. XdmDestination result = null;
  13. try {
  14. XsltCompiler compiler = runtime.getProcessor().newXsltCompiler();
  15. XsltExecutable exec = compiler.compile(xsl().asSource());
  16. XsltTransformer transformer = exec.load();
  17. transformer.setParameter(_format, new XdmAtomicValue(format));
  18. transformer.setInitialContextNode(doc);
  19. result = new XdmDestination();
  20. transformer.setDestination(result);
  21. transformer.transform();
  22. } catch (SaxonApiException e) {
  23. throw new XProcException(e);
  24. }
  25. doc = result.getXdmNode();
  26. }
  27. return doc.toString();
  28. }

相关文章