我有一个XML Schema。我已经在Stax上写了一个薄层,以便“动态”生成符合要求的文档(我不需要类似dom的API,我需要低/无占用空间)。 API只有以下方法:
writeCar(String manufacturer)
writeWheels(String manufacturer, boolean winter)
...
执行状态检查,然后调用适当的stax方法。
一个专长是没有writeEndXXX方法(我的架构是不明确的,因此你不能在wheel元素中有任何汽车。这意味着我总是知道何时关闭打开的元素)。唯一的例外是有一个flush(),它将写入所有挂起的结束标记。
writeCar(..) // <car>
writeWheels(..) // inside the car <wheels>
writeCar(..) // close the pending tags </wheels></car> and new car <car>
flush() // this writes all pending close tags
这很好用。现在架构发展了:)
我现在正在手动更新API。因为我很有道德,我真的不想这样做:)。在给定XML Schema定义的情况下,是否有可用于生成此API(或类似)的工具?