net.sf.saxon.s9api.XdmDestination类的使用及代码示例

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

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

XdmDestination介绍

[英]An XdmDestination is a Destination in which an XdmNodeis constructed to hold the output of a query or transformation: that is, a tree using Saxon's implementation of the XDM data model

No data needs to be supplied to the XdmDestination object. The query or transformation populates an XmlNode, which may then be retrieved using the getXdmNode method.

An XdmDestination can be reused to hold the results of a second transformation only if the #reset method is first called to reset its state.
[中]XdmDestination是一个目的地,其中XDMNode被构造为保存查询或转换的输出:也就是说,一个使用Saxon的XDM数据模型实现的树
无需向XdmDestination对象提供任何数据。查询或转换填充一个XmlNode,然后可以使用getXdmNode方法检索它。
只有在第一次调用#reset方法重置其状态时,XDMDestation才能被重用以保存第二次转换的结果。

代码示例

代码示例来源: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: org.daisy.pipeline/common-utils

public static XMLStreamWritable<XdmNode> nodeWriter(Configuration configuration) throws SaxonApiException, XPathException {
  XdmDestination destination = new XdmDestination();
  Receiver receiver = new NamespaceReducer(destination.getReceiver(configuration));
  receiver.open();
  BaseURIAwareXMLStreamWriter writer = new BaseURIAwareStreamWriterToReceiver(receiver);
  return new XMLStreamWritable<XdmNode>() {
    public BaseURIAwareXMLStreamWriter getWriter() {
      return writer;
    }
    public XdmNode doneWriting() throws TransformerException {
      try {
        receiver.close();
        return destination.getXdmNode();
      } catch (XPathException e) {
        throw new TransformerException(e);
      }
    }
  };
}

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

@Override
public Result resolve(String href, String base) throws TransformerException {
  try {
    XdmDestination dest = new XdmDestination();
    URI uri = new URI("lux:/").resolve(href);
    dest.setBaseURI(uri);
    Configuration config = getCompiler().getProcessor().getUnderlyingConfiguration();
    Receiver receiver = dest.getReceiver(config);
    receiver.setSystemId(href);
    XdmDestinationProxy xdmDestinationProxy = new XdmDestinationProxy(receiver, dest);
    xdmDestinationProxy.setSystemId(href);
    return xdmDestinationProxy;
  } catch (SaxonApiException e) {
    throw new TransformerException(e);
  } catch (URISyntaxException e) {
    throw new TransformerException(e);
  }
}

代码示例来源: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: com.xmlcalabash/xmlcalabash

XdmDestination destination = new XdmDestination();
Controller controller = new Controller(config);
Receiver receiver = destination.getReceiver(controller.getConfiguration());
PipelineConfiguration pipe = controller.makePipelineConfiguration();
pipe.setRecoverFromValidationErrors(!getOption(_assert_valid,false));
XdmNode valid = destination.getXdmNode();
result.write(valid);

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

nodes.add(iter.next());
  XdmDestination dest = new XdmDestination();
  S9apiUtils.writeXdmValue(runtime, nodes, dest, node.getBaseURI());
  add(input, port, dest.getXdmNode());
XdmDestination dest = new XdmDestination();
dest.setBaseURI(node.getBaseURI());
S9apiUtils.writeXdmValue(runtime, node, dest, node.getBaseURI());
XdmNode newNode = dest.getXdmNode();
add(input, port, newNode);

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

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

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

/**
 * Get the base URI that will be used for the document node when the XdmDestination is written to.
 *
 * @return the base URI that will be used for the node that is constructed when the XdmDestination is written to.
 * @since 9.1
 */
public URI getBaseURI() {
  return getDestinationBaseURI();
}

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

String systemId = getBaseURI() == null ? null : getBaseURI().toASCIIString();
if (systemId != null) {
  builder.setUseEventLocation(false);

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

XdmDestination destination = new XdmDestination();
Controller controller = new Controller(config);
Receiver receiver = destination.getReceiver(controller.getConfiguration());
PipelineConfiguration pipe = controller.makePipelineConfiguration();
pipe.setRecoverFromValidationErrors(!getOption(_assert_valid,false));
XdmNode valid = destination.getXdmNode();
result.write(valid);

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

nodes.add(iter.next());
  XdmDestination dest = new XdmDestination();
  S9apiUtils.writeXdmValue(runtime, nodes, dest, node.getBaseURI());
  add(input, port, dest.getXdmNode());
XdmDestination dest = new XdmDestination();
dest.setBaseURI(node.getBaseURI());
S9apiUtils.writeXdmValue(runtime, node, dest, node.getBaseURI());
XdmNode newNode = dest.getXdmNode();
add(input, port, newNode);

代码示例来源: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.daisy.libs/com.xmlcalabash

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

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

/**
 * Get the base URI that will be used for the document node when the XdmDestination is written to.
 *
 * @return the base URI that will be used for the node that is constructed when the XdmDestination is written to.
 * @since 9.1
 */
public URI getBaseURI() {
  return getDestinationBaseURI();
}

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

String systemId = getBaseURI() == null ? null : getBaseURI().toASCIIString();
if (systemId != null) {
  builder.setUseEventLocation(false);

代码示例来源: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: 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: com.xmlcalabash/xmlcalabash

result = new XdmDestination();
  transformer.setDestination(result);
      result.setBaseURI(new URI(outputBaseURI));
    } catch (URISyntaxException use) {
XdmNode xformed = result.getXdmNode();

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

public Result resolve(String href, String base) throws TransformerException {
  URI baseURI = null;
  try {
    baseURI = new URI(base);
    baseURI = baseURI.resolve(href);
  } catch (URISyntaxException use) {
    throw new XProcException(use);
  }
  logger.trace(MessageFormatter.nodeMessage(step.getNode(), "XSLT secondary result document: " + baseURI));
  try {
    XdmDestination xdmResult = new XdmDestination();
    secondaryResults.put(baseURI.toASCIIString(), xdmResult);
    Receiver receiver = xdmResult.getReceiver(runtime.getProcessor().getUnderlyingConfiguration());
    return new FixedSysidReceiver(receiver, baseURI.toASCIIString());
  } catch (SaxonApiException sae) {
    throw new XProcException(sae);
  }
}

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

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

相关文章