XML Syntax Warm-Up!

Elements are containers that begin with a tag (looking similar to <element>) and end with a matching tag (looking similar to </element>). Some elements are allowed to contain other elements. This allows elements to nest within each other in a hierarchical fashion, but the rules about containment are strict. Some elements are not allowed to contain other elements (these are defined to be EMPTY). Empty elements may be abbreviated by using a single tag that looks like <element />.

Elements may have attribute values in the opening tag. Attribute values look like <element attributes="value"/>, with the value portion always enclosed in double quotes. Sometimes you will need to use two sets of quotes to enclose an attribute value (for example, a string literal 'A' in the Patchworks query language would be enclosed as <element attribute="'A'">).

Comments in an XML document are allowed anywhere that elements are allowed, and are surrounded by <!-- and -->. Spaces, tabs and line breaks are not significant in the document other than as word separators.

The ForestModel utilizes two attribute data types: CDATA and NMTOKEN. The CDATA type can contain any string of text acceptable in a well formed XML attribute value (any ASCII character other than the & character). The & character may be inserted in a CDATA attribute by using a special &amp; entity symbol. The NMTOKEN (name token) is more restrictive and limits the input data to alphanumeric characters and punctuation. A NMTOKEN may not contain whitespace. Some attributes may have further restrictions (for example, varable names cannot start with a numeral).

Element attributes in the ForestModel DTD are either #REQUIRED, #IMPLIED, or have a default value.

#REQUIRED means that the attribute value is required in the element and no default is provided. #IMPLIED on the other hand means that the attribute is optional but no default is provided. The final attribute type means the default value is provided if one is not specified in the tag.

Some elements may contain other child elements. A syntax is provided in the reference section to describe the types, number and order of allowed children. Child elements are identified by name, and the order that they are presented in is significant. When you are reading the reference section the following special suffixes define the number of allowed children elements:

?Zero or one child elements allowed
*Zero or more child elements allowed
+One or more child elements allowed

That should be all we need to know for now! Further details can be found at http://xml.com/axml/testaxml.htm. Let's dive in and take a look at some basic ForestModel elements and XML examples.