Package org.geotools.xml
The package supports GML version 2.X defined at http://www.opengis.net/gml/. Although the schema and instance parsers appearing in this package can be extended for use in most xml applications, the package was intended to be used as a starting point to parse GML 2.0 documents.
For simplistic parsing requirements, you should refer to the 'Basics' portion of this document. For more complex parsing requirements, or optimizations you should also read 'Extending the Parser'.
Basics
This set of parsers (one xsi + one xml) is intended to parse arbitrary schema defined xml documents. This means that the XML document must have namespace definitions for the document, although there may be one default namespace defined within the document.
When asked to parse an XML instance document, the parser will first defer to another instance to create a Schema instance of the document requested. In some cases the entire Schema, or portions of the Schema, may already be parsed and reside in a cahce. In this case the Schema will not be parsed, otherwise a new instance of the Schema requested will be created and stored. The Schema is important because it is used in the parsing and validation of the XML document.
To complete basic parsing, use the DocumentFactory.getInstance(URI) method. This will return an Object representing the document (undefined ComplexTypes are Object[], simpleTypes are their type parsed ... int is an Integer). In some cases, specific pre-defined namespaces will not return Object[] for complexTypes (such as gml elements, and gml-inherited elements).
Extending the Parser
Parser extensions should be completed for two reasons: either you want it to go faster, or you want specific types to parse information in a specific manner. In either case you should construct a Schema instance, and add it to the SchemaFactory.properties file found in this package. You will note that you will be required to implement any ComplexTypes which are included in your schema, as such providing an opportunity [getValue(Element,ElementValue[],Attributes)] to create your own parsed values.
The framework will automatically get all you children's values and place then in the order parsed into the ElementValue[]. This means that each type is only responsible for interpreting it's own data, removing the need for recursion. Please be careful or unwanted resources staying in memory, as memory usage can grow quickly. I should also note that I make no claims as to Thread safety, and as such you may wish to consider this when creating an extension implementation.
For more information study the interfaces found in the org.geotools.xml.schema package, and an example hardcoded Schema, look in org.geotools.xml.gml .
Credits
Some of the code and design within this package was first though of by Ian Schneider. Much of the remaining design and implementation was completed by David Zwiers.
-
Interface Summary Interface Description FlowHandler Provides a mechanism to indicate that the XMLSAXHandler should stop parsing.PrintHandler PrintHandler accepts SAXish events and generated output. -
Class Summary Class Description DocumentFactory This is the main entry point into the XSI parsing routines.DocumentWriter This is the thing that writes documents.SchemaFactory This is the main entry point into the XSI parsing routines.XmlConverterFactory A ConverterFactory which can convert strings usingDatatypeFactory
.XMLElementHandler Intended to act as both a definition and a generic handler.XMLHandlerHints Hint object with known parameters for XML parsing.XMLSAXHandler This is a schema content handler.XMLUtils XML related utilities not otherwise found in base librariesXSIElementHandler This abstract class is intended to act as both a definition of what a generic handler is, and a default handler.XSISAXHandler This is a schema handler.