Java / XSD解析 [英] Java/XSD parsing
问题描述
我怀疑是否有这样的东西,但是我想问:
有人知道Java中是否有一个读取xsd文件的库,并且创建定义的元素,例如以字符串格式使用代码?
例如请阅读以下模式:
I doubt if there is something like this but I thought to ask though:
Does anyone know if there is a library in Java that reads an xsd file and "creates" the defined elements e.g. in a String format to use in the code?
E.g. read in the following schema:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Address">
<xs:complexType>
<xs:sequence>
<xs:element name="Street" type="xs:string" />
<xs:element name="Town" type="xs:string" />
<xs:element name="Country" type="xs:string" minOccurs="0" />
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
并且具有以下格式的字符串:
And have a String in the following format:
<Address>
<Street></Street>
<Town></Town>
<Country></Country>
</Address>
自动工具执行类似的操作,即解析一个WSDL,并从类型部分创建例如JAXB类可以是在模式中定义的元素的实例。
有没有任何库来做这个?
Automatic tools do something similar, i.e. parse a WSDL and from the types section create for example JAXB classes that can be instances of the elements defined in schema.
Is there any library to do this?
更新:
例如在Eclipse中为Web应用程序创建一个xml描述符时,它会呈现一个树表,所有必需的元素供用户根据模式填写。他们是如何做到的呢?我想象他们解析包含在jars中的xsds
任何输入都是非常受欢迎的。
谢谢!
UPDATE:
For example in Eclipse when creating an xml descriptor for a web application it presents a tree table with all the required elements for the users to fill in according to schema. How do they do it? I imagine they parse the xsds included in the jars
Any input is very welcome.
Thank you!
推荐答案
oXygen有一个XML实例生成器 可以基于给定的XML模式生成一组XML文档样本。
oXygen has an XML instance generator that can generate a set of XML document samples based on a given XML Schema.
您还可以从命令行中调用它。
You can also invoke it from the commandline.
这篇关于Java / XSD解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!