Reputation: 133
i have simple xsd file:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
and some code to parse it
String aFile = "C:\\1.xsd";
XSDParser parser=null;
XSDSchema schema;
URI schemaUri = new File(aFile).toURI();
String uri;
try {
uri = schemaUri.toURL().toString();
parser=XSDParser.class.newInstance();
parser.parse(uri);
schema = parser.getSchema();
for (XSDElementDeclaration element : schema.getElementDeclarations()) {
System.out.println(element.getName());
}
Program prints "note". I debuged it, and can not find element to,from,heading and body. what do I change to receive output:
note
to
from
heading
body
Upvotes: 1
Views: 335
Reputation: 3068
org.eclipse.xsd.util.XSDPrototypicalSchema
Builds instances is likely to help you understand how to traverse them.
Upvotes: 1