xml2class - Introduction

In this document, you'll find a brief package description, some quick start information and the basic rules for xml2class usage.

[top] Description

xml2class provides you with a simple XML parser, which instantiates data structures written in Java out of a XML description (and supports storing them back as XML code). It is thought as an aid for programmers, as it won't do all the work for you.

With the aid of xml2class you may describe most data structures (such as linked lists, binary trees, tables, menus, and so on) in easy to modify XML. Following the XML descriptions, it won't be difficult to write the corresponding Java classes. Then the XML2ClassParser will read in and instantiate the entire structure in a way that you may save it back to disk easily (in XML).

[top] Quick start

Implement the data structure in XML. Think of one XML element as one Java class. E.g. for...

    <RootElementName att1="Constructor Parameter 1" att2="Constr. Param. 2">
        <method>
        	any parameters (any Objects)
        </method>
        <AnotherElement att3="Constr. param."/>
        <methodName/>
        ...
    </RootElementName>

...write the following Java class:

    public class ElementName {
        public ElementName(String anyValue1, String anyValue2) { ... }
        public void setMethod([ParameterObjectsClassType] value) { ... }
        public void addAnotherElement(AnotherElement element) { ... }
        public void methodName()
        ...
    }

Note how the tags correspond to classes, methods and parameters. Implement now the data structure like this. Have a look at the explicit rules for more precise information to be considered.

Now you can load it into your program with the following line:

    [RootElement] root = XMLFile.parse("[directory/filename.xml]", "[package.name]");

And save it back by using

    XMLFile.save([RootElement], "[directory/filename.xml]");

supposing your objects provide a toXMLString() method.

For more concrete information, have a look at the example.

[top] Basic rules

Tags & methods

Objects & classes

XML & entities

Character&<>"'
Entity&amp;&lt;&gt;&quot;&apos;

xml2class parsing

[top] The author

For any comments, bug reports ("it's not a bug, it's a feature!") and so on - I am aware of the insufficient quality of this documentation - just contact me:

Simon Bünzli, zeniko@gmx.ch

Version 05/08/01 - Copyleft (C) 2001