What is Peach
Installing
Tutorials
Methodology
Introduction
Training
Enterprise
FAQ
Support Forums
Peach 3
Peach Pits
 General Conf
 Data Modeling
 State Modeling
 Agents
  Monitors
 Test
  Publishers
  Loggers
Running
Minset
Peach 2.3

License

DataModel

The DataModel element is a child of the Peach root element. A DataModel defines the structure of a data block by specifying additional child elements such as Number, Blob, or String.

Attributes:

  • name — [Required] Friendly name of the DataModel this is useful when referencing the model or debugging.

  • ref — Reference to a DataModel to use as a template (optional)

  • mutable-- Is data element changeable (should it be mutated) (optional, defaults to true)

  • constraint — Specifies an expression that helps Peach identify if the data element has been properly consumed (optional)

Examples:

Any number of DataModels can be specified in a Peach Pit file. However, each must each have a unique name. Break complex formats into smaller models by split them into logical parts. This makes DataModels easier to read, debug, and re-use.

A DataModel named "HelloWorld" contains a single string and outputs "Hello world!"

<DataModel name="HelloWorld">
  <String value="Hello world!" />
</DataModel>

DataModels can reference other DataModels and inherit their child elements with the ref attribute.

<DataModel name="ParentModel">
  <String value="Hello " />
</DataModel>

<DataModel name="HelloWorldModel" ref="ParentModel" >
  <String value=" world!" />
</DataModel>

References (ref attribute)

When a reference (ref attribute) is supplied, the contents of the referenced DataModel are copied to create the base of the new DataModel. Any child elements in the new DataModel will override elements from that base with the same name. In this example the child model Customized contains a String named Key. It’s value will overwrite the parent’s String "Key" which has no value.

<DataModel name="Template">
  <String name="Key" />
  <String value=": " token="true" />
  <String name="Value" />
  <String value="\r\n" token="true" />
</DataModel>

<DataModel name="Customized" ref="Template">
  <String name="Key" value="Content-Length" />
  <String name="Value">
    <Relation type="size" of="HttpBody" />
  </String>
  <Blob name="HttpBody" />
</DataModel>
The output of "Template"   is " : \r\n"
The output of "Customized" is "Content-Length: 100\r\n"

When parsed into a DataModel, Customized will look like the combination of both data models.

<DataModel name="Customized" ref="Template">
  <String name="Key" value="Content-Length" />
  <String value=": " token="true" />
  <String name="Value">
    <Relation type="size" of="HttpBody" />
  </String>
  <String value="\r\n" token="true" />
</DataModel>