找到你要的答案

Q:Saxon 9.6.0.7 version also needs saxon-dom?

Q:撒克逊9.6.0.7版本还需要人呢?

I was upgrading the version of my saxon dependency and the project can't run because I'm using DOMSource instance to make a transformation.

public String getXML(Node objNode) throws Exception{
     Transformer t = ThreadLocalHelper.getDomTransformer().get();
     t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"yes");
     StringWriter w = new StringWriter(4096);
     t.transform(new DOMSource(objNode), new StreamResult(w));
     return w.toString();
}

There is another way to transform a Node/Document in saxon 9.6?

Thanks

我升级我撒克逊依赖和项目不能运行的版本,因为我使用了domsource实例进行改造。

public String getXML(Node objNode) throws Exception{
     Transformer t = ThreadLocalHelper.getDomTransformer().get();
     t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"yes");
     StringWriter w = new StringWriter(4096);
     t.transform(new DOMSource(objNode), new StreamResult(w));
     return w.toString();
}

有另一种方法来转换节点/文件在撒克逊9.6?

谢谢

answer1: 回答1:

I am using:

ByteArrayOutputStream bos = new ByteArrayOutputStream();
Result result = new StreamResult(bos);

// Transform into HTML
try {
    transformer.transform(xmlDocument, result);
} catch (TransformerException e) {
    // do stuff
}

with xmlDocument as a StreamSource:

xmlDocument = new StreamSource(new ByteArrayInputStream(xml.getBytes(encoding)))

Using saxon 9.6.0-7

我正在使用:

ByteArrayOutputStream bos = new ByteArrayOutputStream();
Result result = new StreamResult(bos);

// Transform into HTML
try {
    transformer.transform(xmlDocument, result);
} catch (TransformerException e) {
    // do stuff
}

随着XML文档作为一个StreamSource:

xmlDocument = new StreamSource(new ByteArrayInputStream(xml.getBytes(encoding)))

使用撒克逊9.6.0-7

java  xslt  dom  saxon