The element Element

The element element is used to declare child elements of an element. Thus, the element element is always a child element of either an ElementType element (which defines elements) or a group element. Just as you could for the element element in the W3C schema, you can define the number of occurrences of an element child element.

With BizTalk schemas, you will also use the minOccurs and maxOccurs attributes. In this case, minOccurs can only be 0 or 1. If minOccurs is 0, the element is optional; if it is 1, the element must occur once. The maxOccurs attribute can only be 1 or an asterisk (*). If maxOccurs is 1, the element can appear at most once; if it is *, the element can appear an unlimited number of times. This is different from the W3C schema, which allows any value to be assigned to minOccurs and maxOccurs.

The group Element

The BizTalk group element is similar to the group element of the W3C schema, but unlike the group element defined in the W3C standard, the BizTalk group element cannot be a child element of the schema element. This means that you cannot have document scope group elements. A group element can be used only to group elements within an element declaration-for example, within an ElementType declaration. One of the most useful features of the group element is that it can be used to define a sequence for the child elements of an element.

The group element contains element child elements. The sequence of the child elements can be specified by using the group element's order attribute. If the order attribute is set to one, there can only be one instance of each element in the group. The one value is equivalent to the pipe (|) symbol in a DTD. When the order attribute is set to seq, the elements must appear in the order in which they are declared. Using the seq value is the same as using parentheses and commas in a DTD. The many value indicates that the child elements can appear in any order. The minOccurs and maxOccurs attributes work the same as their counterparts in the element element. We will look at some examples of groups in the section "The ElementType Element" later in this chapter.

The Schema Element

Because the Schema element will be included within the body of the BizTalk document, it cannot really be considered a root element. Therefore, instead of calling the Schema element the root element, we will call it the document element-that is, the highest level element of the BizTalk document. The Schema element indicates the start of a schema definition.

Two namespace attributes should be associated with the Schema element. The first is urn:schemas-microsoft-com:xml-data. This namespace is used by applications such as the Internet Explorer 5 XML parser as a processing instruction to identify the Schema elements defined in the sample DTD at the beginning of this section. This is the default namespace, so you do not have to prefix all the Schema element names with a namespace name. The second namespace attribute is urn:schemas-microsoft-com:datatypes. This namespace is used by applications to include all the data types associated with schemas. The data types listed in the dataTypes entity in the sample DTD are the currently allowable data types for elements.

Our sample DTD allows the following elements to be child elements of the Schema element: AttributeType, ElementType, and description. The description child element can occur once and provides a text description of the business document. Because the AttributeType child element belongs to the Schema element, this element is similar to the attributeGroup element of the W3C schema in that it represents an element with document scope. Unlike the attributeGroup element, however, the AttributeType element allows you to define only a single type of attribute instead of a group of attributes. The ElementType child element is equivalent to the element element in the W3C schema and is used to define elements.

An example of a Schema element is shown here:

  <Schema name="NorthwindSchema"

by BrainBellupdated