本文介绍了任何Java“API”从XSD生成Sample XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为我们应用程序的一部分,我们需要开发一个接收XSD架构并提供示例XML的模块。 XSD架构将在运行时提供。那么有没有可以完成这项工作的Java API?

As part of our application we need to develop a module that takes in an XSD schema and gives out a sample XML. The XSD schemas will be supplied during runtime. So is there any Java API out there that can do the job?


推荐答案

没有这样的API,但它是可能的。
'给出样本XML'意味着你必须从XSD基本类型实现样本XML节点的生成,如< xs:element name =valuetype =xs :整数minOccurs =0/> ,处理minoccurs / maxoccurs属性,不在 xs:integer 节点等中存储日期等等。

There is no such API, but it's possible.'gives out sample XML' means that you will have to implement generation of sample XML node(s) from XSD basic types like <xs:element name="value" type="xs:integer" minOccurs="0"/>, taking care of minoccurs/maxoccurs attributes, not storing dates in xs:integer nodes, etc, etc..

一旦完成,剩下的就不是问题了:用 XPath 或<$遍历XSD c $ c> org.w3c.dom。* ,展平复杂类型和扩展将起到作用。我打赌你会在发布问题后几分钟内在stackoverflow上收到工作遍历代码。

Once it's done, the rest is not a problem: traversing XSD with XPath or org.w3c.dom.*, flattening complex types and extensions will do the trick. I bet you'll receive working traversing code here on stackoverflow within minutes after posting question.

这篇关于任何Java“API”从XSD生成Sample XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 19:22