gpt4 book ai didi

java - Saxon 9.6.0.7版本也需要saxon-dom?

转载 作者:行者123 更新时间:2023-12-01 06:11:46 25 4
gpt4 key购买 nike

我正在升级 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();
}

在 saxon 9.6 中还有另一种方法来转换节点/文档吗?

谢谢

最佳答案

我正在使用:

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)))

使用撒克逊9.6.0-7

关于java - Saxon 9.6.0.7版本也需要saxon-dom?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33013163/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com