如何在 Moxy 中获取根元素

How to get the root element in Moxy

我正在尝试通过使用 Moxy 分析 xsd 来创建 xml。我不会知道 xsd 的样子。 xsd 将即时提供。使用 Moxy 我能够加载 xsd 并打印所有 XmlDescriptors 的详细信息。我的问题是,如何识别根元素。

谢谢

具有 xsd,任何全局类型都可以是 xml 文档的根元素。对于这样的全局类型,使用方法

org.eclipse.persistence.oxm.XMLDescriptor#getDefaultRootElement

获取根元素的名称。