开发者

How to extract tag names from an XSD?

开发者 https://www.devze.com 2023-02-20 08:10 出处:网络
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).

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

精彩评论

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