我知道网上有很多这样的主题,但问题是,没有一个解决方案适合我。 我使用的语言:Java IDE:Intellij
澄清一下,我使用的是社区版,也许这就是为什么 JAXB 等插件不起作用的原因。
我从另一个文件中提取了数据(值),并且需要使用该数据创建 XML 文件。这里还有 XSD 架构:http://www.bpsim.org/schemas/1.0/
我想也许有我可以使用的第三方解决方案? 因为我真的不想手动编写所有 XML 文件,因为它有数千个值和代码。
有人知道一个好的解决方案吗?
最佳答案
在 Linux 上,您可以使用 xmlbeans、xmlbeans-tools 包中的 xsd2inst
来生成 xsd 并实例化
XMLBEANS_LIB='/usr/share/java/xmlbeans/' xsd2inst test.xsd -name Shiporder> test.xml
xsd2inst -h
Generates a document based on the given Schema file
having the given element as root.
The tool makes reasonable attempts to create a valid document,
but this is not always possible since, for example,
there are schemas for which no valid instance document
can be produced.
Usage: xsd2inst [flags] schema.xsd -name element_name Flags:
-name the name of the root element
-dl enable network downloads for imports and includes
-nopvr disable particle valid (restriction) rule
-noupa disable unique particle attribution rule
关于java - 根据XSD架构创建XML文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50106696/