Reputation: 3783
I need to parse below XSD file.. and I have to read all the values..
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:books"
xmlns:bks="urn:books">
<xsd:complexType name="Book1">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="1" form="unqualified" name="Title" type="xs:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Please let me know how can I do it using "XSOMParser".
Upvotes: 0
Views: 6123
Reputation: 23268
What code have you tried?
Start off with the examples from the XSOM user guide:
import com.sun.xml.xsom.parser.XSOMParser;
import com.sun.xml.xsom.XSSchemaSet;
XSOMParser parser = new XSOMParser();
parser.setErrorHandler(...);
parser.setEntityResolver(...);
parser.parseSchema( new File("myschema.xsd"));
parser.parseSchema( new File("XHTML.xsd"));
XSSchemaSet sset = parser.getResult();
and further down in the user guide:
For example, the following code lists all the global element declarations and whether they are abstract or not.
// iterate each XSSchema object. XSSchema is a per-namespace schema.
Iterator itr = sset.iterateSchema();
while( itr.hasNext() ) {
XSSchema s = (XSSchema)itr.next();
System.out.println("Target namespace: "+s.getTargetNamespace());
Iterator jtr = s.iterateElementDecls();
while( jtr.hasNext() ) {
XSElementDecl e = (XSElementDecl)jtr.next();
System.out.print( e.getName() );
if( e.isAbstract() )
System.out.print(" (abstract)");
System.out.println();
}
}
Upvotes: 1