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");