Saxon 9.6.0.7版还需要saxon-dom?

时间:2015-10-08 10:28:21

标签: java xslt dom saxon

我正在升级我的撒克逊依赖项版本,项目无法运行,因为我正在使用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中的节点/文档吗?

由于

1 个答案:

答案 0 :(得分:-1)

我正在使用:

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

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

将xmlDocument作为StreamSource:

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

使用saxon 9.6.0-7