Tutorial 01 - Use the CodeGenerator to process a schema.
|Top Previous Next|
12/30/2016 - The current version of the software is 3.4.1
Please upgrade if you are not using the latest version of the software.
Last Updated: 12-06-2016
In this tutorial we will use the CodeGenerator to process a schema.
So imagine you have the following xml document with a list of books in it.
<Title>A Christmas Carol</Title>
<Title>Alice's Adventures In Wonderland</Title>
<Title>Charlie and the Chocolate Factory</Title>
How would you go about using the wickedfast solutions tools to access the data in it.
First, we need a schema describing the format of the xml document.
Second, we need to compile that schema into java code that can be used to access the data.
In this tutorial, we will provide you with a schema, in later tutorials we will show you how to create your own schemas.
Save the file http://www.wickedfastsolutions.com/resources/books-instance.xml to your desktop.
Save the file http://www.wickedfastsolutions.com/resources/books-schema.xml to your desktop.
Create a new folder on your desktop and call it schemas. Put the books-schema.xml file into it.
Type the following text into the console:
CodeGenerator -schemaFolder ../../../schemas -outputFolder ../../../output
Make sure that the CodeGenerator has created the following directories and files.
#2 contains all the classes and dependencies required for the software to run
#3 contains just the compiled domain objects with no dependencies
#4 contains just the required dependencies
#7 contains the UIDS for mapping between domains
#8 contains a w3c version of the schema (in russian doll format)
#9 contains an overview of the number of lines of code generated
#11 contains the javadoc of the generated source code
#12 contains the generated source code
Save the file http://www.wickedfastsolutions.com/resources/BooksApplication.java to your desktop.
Move the classes.jar located in output/build/dist/classes.jar to the desktop.
Compile the BooksApplication.java class with the following command.
(If you get warnings while compiling - try using the jdk that is distributed with the tools - wickedfastsolutions-3.3.6/bin/java/bin)
javac -cp classes.jar BooksApplication.java
Run the application with the following command.
java -cp .;classes.jar BooksApplication
Notice line 7 in the books-schema.xml
The length attribute specifies that the data contained in the field must be of length 10.
What happens if you go into the books-instance.xml and add a character to one of these fields.
In books-instance.xml go to line 14 and change the ISBN10 field from 1477581855 to 14775818553
Run the application again.
You should see the following output.
Try changing other aspects of the data and schema. You can use the syntax reference portion of the website for a full listing of all the attributes available to you.
Congratulations, you have just finished Tutorial-01!