Package de.uni_trier.wi2.procake.utils.io.xerces
CAKE IO xceres XML
CAKE uses XML for communication and storage format. This package provides some classes which simplify the usage of XML streams. The classes using the xerces XML package from the Apache project, see http://xerces.apache.org/.
XML Parser
To parse an XML stream the XMLParser
can be
used. The usage is
quite simple:
XMLParser parser = new XMLParser(this.getClass().getClassLoader()); parser.setContentHandler(new DefaultHandler()); // use your own DefaultHandler parser.setFilename("filename.xml"); parser.read();
In the default configuration no validation is performed. To validate the content two
special parsers are provided: DTDBasedParser
and XMLSchemaBasedParser
. The corresponding grammars are
automatically loaded from the directory /resources/XML that must be in the
classpath.
XML Writer
To write an XML stream the XMLSchemaBasedWriter
is provided. The usage for an XML Schema
writer is quite simple:
XMLSchemaBasedWriter writer = new XMLSchemaBasedWriter("filename.xml"); writer.setTargetNamespace("http://cake.wi2.uni-trier.de/xml/catl"); writer.setSchemaLocation("http://cake.wi2.uni-trier.de/xml/catl", "catl.xsd"); writer.addImport("co", "http://cake.wi2.uni-trier.de/xml/cdol");
-
Class Summary Class Description DTDBasedParser A XMLParser with full DTD checking enabled.ResourceEntityResolver The resource entity resolver loads the grammars from the pathIO.RESOURCE_XML
.SimpleErrorHandler A simple error handler that prints sax parser exception to standard error.XMLParser A XMLParser that uses the xerces package from the Apache group, see http://xerces.apache.org/.XMLSchemaBasedParser A XMLParser with full XML Schema checking enabled.XMLSchemaBasedWriter A XMLWriter for XML content based on a XML Schema grammar.