The Modello Data Model.
Staging site giving full modello's model (under construction) can be found here: http://dcabasson.developpez.com/maven/modello-metamodel.html
Here's an example of a modello data model.
| Code Block | ||
|---|---|---|
| ||
<model>
<id>myproject</id>
<name>MyProject</name>
<description>My Project's Data Model</description>
<defaults>
<default>
<key>package</key>
<value>org.codehaus.myproject.model</value>
</default>
</defaults>
<classes>
<class rootElement="true" xml.tagName="myproject">
<name>Model</name>
<version>3.0.0+</version>
<fields>
<field>
<name>myfield</name>
<version>1.0.0</version>
<description>The example of field.</description>
<type>String</type>
</field>
</fields>
</class>
</classes>
</model>
|
Top level <model>
The top level <model> must contain an <id> <name> and at least 1 <classes><class> element.
The optional <defaults> tag is commonly used to define properties that the various modello generators use.
The <classes> section.
You can have 1 or more <class> elements within this section.
Each <class> represents a container for a set of <field>s.
Every <field> is a component in the container.
Notes on the <field> section
XML Generator Notes about <field>
- By default each
<field>starts out life as an<element>with text content. - A
<field>can be set to be an attribute on the<class>element by using the<field xml.attribute="true">syntax. field/namebecomes the name of the element (or attribute key).field#xml.tagNamecan be used to change the name of the element (or attribute key)
field/versionis unused.field/descriptionis unused.field/typeis one of the following- boolean
- char
- double
- int
- long
- short
- date
- String
- Boolean
- DOM (currently only supported by xpp3 generators)
- Another
<class>this can only be achieved through an association tag
field/associationallows linking to other classes of the model- generated readers and writers do not enforce the multiplicity rules (yet)
field/associationmust have at a minimum the <type> element defined.field/association/multiplicitydictates the multiplicity of a field (1 or*: 0 to many so far)field/association/typeonly refers to other <class> id's, no java primitives allowed here.field/association/typewill be used to determine the name of the nested elements.- singular form of the field tagname will be used for the nested element name.
s/(.*)ies$/\1y/g-"Properies"becomes"Property"s/(.*(ch)?)es$/\1/g-"Branches"becomes"Branch"s/(.*)s$/\1/g-"Reports"becomes"Report"
field/association#xml.associationTagNamecan be used to specify an overridden nested element name.- To learn more about tagName resolution, see TagName resolution
field#xml.listStyledefaults to "wrapped".- Example of
field#xml.listStyle="wrapped"Code Block xml <!-- Model --> <class> <name>example</name> <fields> <field xml.listStyle="wrapped"> <name>components</name> <version>4.0.0</version> <association> <type>Component</type> <multiplicity>*</multiplicity> </association> </field> </fields> </class> <class> <name>Component</name> <version>4.0.0</version> <fields> <field> <name>name</name> <type>String</type> </field> </fields> </class>Code Block xml <!-- xml --> <example> <components> <component> <name>foo</name> </component> <component> <name>bar</name> </component> </components> </example> - Example of
field#xml.listStyle="flat"Code Block xml <!-- Model --> <class> <name>example</name> <fields> <field xml.listStyle="flat"> <name>components</name> <version>4.0.0</version> <association> <type>Component</type> <multiplicity>*</multiplicity> </association> </field> </fields> </class> <class> <name>Component</name> <version>4.0.0</version> <fields> <field> <name>name</name> <type>String</type> </field> </fields> </class>Code Block xml <!-- xml --> <example> <component> <name>foo</name> </component> <component> <name>bar</name> </component> </example>
- Example of
