Wxml |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Go to: Introduction
- Atom Attributes - Column Attributes - Data
Types - Dictionaries - Embedding code - Output Modes |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Wxml
is the
tool that generates code from your xml description of data models. A typical wxml input file looks like this:
That is, you define an object with a NAME and
TABLE attributes and then an arbitrary number of rows with attributes.Atom attributes
Column attributes
Data types
Dictionaries
Dictionaries
are very useful for limiting the range of values a column
can take, and mapping those values to symbolic names. This saves disk
space
and memory in the server and prevents bogus values from being inserted
into
the table. It also makes the application easier to use by users, since
it
maps numeric values to more meaningful strings.
Example dictionary -- type of fruit: Value Symbolic name Dictionary tables are defined using XML like table data models, but are much more limited:
We can now generate the dictionary table with Wxml: $ Wxml --sql FruitType.xml >
FruitType.sql Now that the table is stored in the database, we can tag our atoms as users of that dictionary:
Now :WOMB: knows the "tfruit" column is bound to the fruit dictionary, so doing something like: FruitTree tree = new FruitTree (db); will throw an exception, because "6" is not in the dictionary table. To prevent this from happening, Wxml can generate an enum mapped to the dictionary: $ Wxml.exe --body FruitType.xml >
FruitType.cs Now, if you include FruitType.cs in your application, you can use the symbolic names when assigning to the tfruit column: FruitTree tree = new FruitTree (db); Womb.Gtk also knows about dict-bound columns and will automatically show a combo box for selecting the values in the data entry widgets (eg. Womb.Gtk.AtomTab, Womb.Gtk.AtomEditor). Dictionary-bound columns can only be of type "int". Furthermore, you cannot use a pre-existing table as a dictionary: you must create it specifically using the output of Wxml. Multiple tables can consume the same dictionary efficiently: dictionaries are cached on a per-session basis in the Womb.DB class. Embedding code
You can have wxml include your own code when emitting C# code for your data model. For example, you may want to include some custom method in the generated atom, or override some of the Womb.Atom methods to do specific things. Arbitrary code is attached to the atom by using the <body> tag in the xml file.
Output modes
Wxml can generate different kinds of output for every input xml file.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Go to: Introduction
- Atom Attributes - Column Attributes - Data
Types - Dictionaries - Embedding code - Output Modes |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||