简体   繁体   English

如何将 Saxon XdmNode 转换为 XmlDocument?

[英]How can I convert a Saxon XdmNode to an XmlDocument?

I have a fully populated XdmNode and need to create an XmlDocument from it.我有一个完全填充的 XdmNode,需要从中创建一个 XmlDocument。 How can I do that?我怎样才能做到这一点?

It's possible that the XdmNode is already a wrapper for an XmlDocument , in which case you can dive down through the wrappers to extract the underlying XmlDocument using XdmNode.getUnderlyingXmlNode() . XdmNode可能已经是XmlDocument的包装器,在这种情况下,您可以深入这些包装器以使用XdmNode.getUnderlyingXmlNode()提取底层 XmlDocument。

On the other hand, in the general case, you will need to copy the data across.另一方面,在一般情况下,您将需要复制数据。 The easiest way to do this is probably to run the XQuery "."最简单的方法可能是运行 XQuery “.” using XQueryEvaluator.Run() with a DomDestination as the supplied XmlDestination ;使用XQueryEvaluator.Run()DomDestination作为提供的XmlDestination on completion, DomDestination.XmlDocument gives you the DOM document node.完成后, DomDestination.XmlDocument为您提供 DOM 文档节点。

If you're constructing the tree using an XSLT transformation or XSD validation, then you can supply a DomDestination as the output for that process, in which case you can avoid the copying process.如果您使用 XSLT 转换或 XSD 验证构建树,那么您可以提供DomDestination作为该过程的输出,在这种情况下,您可以避免复制过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM