[go: up one dir, main page]

Menu

Getting Started

Elias N Vasylenko

Installation

The first step to get started with is setting up the build environment. As an example, we will assume a requirement for XML support. To achieve this, we can either download the [jars] we need, modabi-core and modabi-xml, and manually add them to our classpath, or if we are using a build tool which supports Maven artefact resolution we can add the following dependencies to our build:

<dependency>
    <groupId>uk.co.strangeskies</groupId>
    <artifactId>modabi-core</artifactId>
    <version>1.0.0</version>
</dependency>

<dependency>
    <groupId>uk.co.strangeskies</groupId>
    <artifactId>modabi-xml</artifactId>
    <version>1.0.0</version>
</dependency>

Users interested in building from source, or making contributions, should check out the [Developers] section.

As with all other [Examples], the source files used here can be found in the modabi-examples project in the main repository.

Loading a Schema

For now we will start with a simple example just to demonstrate the system in action and to make sure our build environment is set up correctly. The details of the schema definition we use will not be covered to any significant depth here.

Class Definition

First, let's define a simple class to be bound and unbound to and from XML. No special consideration for Modabi needs to be made at this point in the design of the class.

[[include can't find file /modabi-examples/src/main/java/uk/co/strangeskies/modabi/example/person/Person.java in revision fb1ef3f6ce74e9c16eb6f829fbccbef6e2e9cfdb]]

Schema Definition

Now we need to define a schema so that we can bind and unbind to and from this class.

[[include can't find file /modabi-examples/src/main/resources/uk/co/strangeskies/modabi/example/person/PersonSchema.xml in revision fb1ef3f6ce74e9c16eb6f829fbccbef6e2e9cfdb]]

Data Definition

And it's as simple as that, now we're ready to try binding some data! Here is an example of an XML data file which conforms to the schema we just defined. It's clearly too simplistic to be useful in a real-life program, but it is sufficient to serve as an example here.

[[include can't find file /modabi-examples/src/main/resources/uk/co/strangeskies/modabi/example/person/PersonData.xml in revision fb1ef3f6ce74e9c16eb6f829fbccbef6e2e9cfdb]]

In Action

Now we will create a small main class to test out our new schema definition.

[[include can't find file /modabi-examples/src/main/java/uk/co/strangeskies/modabi/example/person/PersonTest.java in revision fb1ef3f6ce74e9c16eb6f829fbccbef6e2e9cfdb]]

Next Steps

Now that we have got things up and running, we can start to take a look at some more complex [Examples]. Alternatively, we can dive right into the [Schema Definition Format] documentation, or the [API] documentation.


Related

Wiki: Examples
Wiki: Home