开发者

How to extract tag names from an XSD?

I need to write in Java. Is there any sample code available in t开发者_运维百科his regard?


You could use Apache XmlSchema library (http://ws.apache.org/commons/xmlschema14).

The idea is to create the instance of XmlSchema class that represents your schema:

InputStream is = new FileInputStream(fileName);
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
XmlSchema schema = schemaCol.read(new StreamSource(is), null);

and use it to obtain information about elements and types specified by your schema. You could for instance enlist all element names:

XmlSchemaObjectTable objTable = schema.getElements();
Iterator elementNames = objTable.getNames();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜