As we have already said, the JaxMe parser for XML Schema, is an application of multiple layers. There is a generic parser, which is mostly independent of a certain XML language. The second layer is the syntax parser, which you typically do not want to use. Most probably you are mainly interested in the topmost layer: The logical parser.
The logical parser presents the XML Schema in a way, which you will definitely like, because it is easy to use and frees you from the burden to understand XML Schema. It handles groups, restrictions, extensions, redefinitions and all that kind of stuff for you. Ideally you do not even notice, that they are in use.
The structural parser is used as follows:
import java.io.FileInputStream; import net.sf.jaxme.xs.XSParser; import net.sf.jaxme.xs.XSSchema; import org.xml.sax.InputSource; XSParser xsp = new XSParser(); InputSource isource = new InputSource(new FileInputStream("myschema.xsd")); isource.setSystemId(f.toURL().toString()); XSSchema schema = xsp.parse(isource); // Print the names of all global elements: XSElement[] elements = schema.getElements(); for (int i = 0; i < elements.length; i++) { System.out.println(elements[i].getName()); }
As of this writing, access to context information has not been specified, the exception being the syntactical schemas that are currently being parsed.
For example, if you are parsing a schema, which is importing another schema. The latter might still be importing a third schema. While parsing this third schema, you might be interested to know the outermost or the middle schema. Access to these items is provided through
XSObject.getContext().getImmutableContext().getXSLogicalParser().getSyntaxSchemas()
Back to Contents |