Views - XML Overlays

Last Updated 2/10/2015
Provides examples of view overlays on base tables.
A view is a series of XML overlays that occur on a base table. Views come from the following sources and are applied in the following order
  • Bundles
  • Customer "root" views
  • User/Group specific views

Tree matching

The base Table document and the overlying View document must have the same name structure. The only exception is the root element, it is Table for a table and View for an overlaid view.

Within an element children are matched by Name and ID. Both child elements must have the same name. Both child elements must have the same ID, or both child elements must have no ID.

If a view element has no corresponding element in the table it is appended to the final document.

Example

<Table Id="Contacts">
    <Fields>
        <Column Id="FirstName" Type="VarChar" Length="255"/>
        <Column Id="LastName" Type="VarChar" Length="255" />
    </Fields>
</Table>
<View Id="People" TableId="Contacts">
    <Fields>
        <Column Id="FirstName" Length="100" Required="true"/>
        <CustomField Id="DOB" Type="Date"/>
    </Fields>
</View>
Result
<Table Id="Contacts">
    <Fields>
        <Column Id="FirstName" Type="VarChar" Length="100" Required="true"/>
        <Column Id="LastName" Type="VarChar" Length="255" />
        <CustomField Id="DOB" Type="Date"/>
    </Fields>
</Table>

Insert Element

By default unmatched elements are appended as the child of the current element. If you want the default position you can include the <Insert/> element.

Example

<Table Id="Contacts">
    <Fields>
        <Column Id="FirstName" Type="VarChar" Length="255"/>
        <Insert/>
        <Column Id="LastName" Type="VarChar" Length="255" />
    </Fields>
</Table>
<View Id="People" TableId="Contacts">
    <Fields>
        <CustomField Id="DOB" Type="Date"/>
    </Fields>
</View>
Result
<Table Id="Contacts">
    <Fields>
        <Column Id="FirstName" Type="VarChar" Length="255"/>
        <CustomField Id="DOB" Type="Date"/>
        <Insert/>
        <Column Id="LastName" Type="VarChar" Length="255" />
    </Fields>
</Table>
 

Cmd Attribute

A Cmd attribute is provided to provide further control over the merging of the table and the view.

Cmd="Remove"

Specifying Cmd="Remove" causes the element to be excluded from the final document.

Example
<Table Id="Contacts">
    <Fields>
        <Column Id="FirstName" Type="VarChar" Length="255"/>
        <Column Id="LastName" Type="VarChar" Length="255" />
    </Fields>
</Table>

<View Id="People" TableId="Contacts">
    <Fields>
        <Column Id="FirstName" Cmd="Remove"/>
    </Fields>
</View>
Result
<Table Id="Contacts">
    <Fields>
        <Column Id="LastName" Type="VarChar" Length="255" />
    </Fields>
</Table>

Cmd="First"

The element should be placed first in the parent element.
Example
<Table Id="Contacts">
    <Fields>
        <Column Id="FirstName" Type="VarChar" Length="255"/>
        <Column Id="LastName" Type="VarChar" Length="255" />
    </Fields>
</Table>

<View Id="People" TableId="Contacts">
    <Fields>
        <CustomField Id="DOB" Type="Date" Cmd="First"/>
    </Fields>
</View>

Result

<Table Id="Contacts">
    <Fields>
        <CustomField Id="DOB" Type="Date" />
        <Column Id="FirstName" Type="VarChar" Length="255"/>
        <Column Id="LastName" Type="VarChar" Length="255" />
    </Fields>
</Table>

Cmd="Last"

The element should be placed last in the parent element. Note that Cmd attributes can also be used on existing elements.

Example
<Table Id="Contacts">
    <Fields>
        <Column Id="FirstName" Type="VarChar" Length="255"/>
        <Column Id="LastName" Type="VarChar" Length="255" />
    </Fields>
</Table>

<View Id="People" TableId="Contacts">
    <Fields>
        <Column Id="FirstName" Cmd="Last"/>
    </Fields>
</View>

Result

<Table Id="Contacts">
    <Fields>
        <Column Id="LastName" Type="VarChar" Length="255" />
        <Column Id="FirstName" Type="VarChar" Length="255"/>
    </Fields>
</Table>

Cmd="Before:ID"

The element should be placed before the referenced element.
Example
<Table Id="Contacts">
    <Fields>
        <Column Id="FirstName" Type="VarChar" Length="255"/>
        <Column Id="LastName" Type="VarChar" Length="255" />
    </Fields>
</Table>

<View Id="People" TableId="Contacts">
    <Fields>
        <CustomField Id="DOB" Type="Date" Cmd="Before:LastName"/>
    </Fields>
</View>

Result

<Table Id="Contacts">
    <Fields>
        <Column Id="FirstName" Type="VarChar" Length="255"/>
        <CustomField Id="DOB" Type="Date" />
        <Column Id="LastName" Type="VarChar" Length="255" />
    </Fields>
</Table>

Cmd="After:ID"

The element should be placed before the referenced element.
Example
<Table Id="Contacts">
    <Fields>
        <Column Id="FirstName" Type="VarChar" Length="255"/>
        <Column Id="LastName" Type="VarChar" Length="255" />
    </Fields>
</Table>

<View Id="People" TableId="Contacts">
    <Fields>
        <Column Id="FirstName" Cmd="After:LastName"/>
    </Fields>
</View>

Result

<Table Id="Contacts">
    <Fields>
        <Column Id="LastName" Type="VarChar" Length="255" />
        <Column Id="FirstName" Type="VarChar" Length="255"/>
    </Fields>
</Table>

NoOverride attribute

To prevent attributes from being overridden you can use the NoOverride attribute. This contains a comma delimited list of attributes that will remain unchanged by additional views
Example

<Table Id="Contacts">
    <Fields>
        <Column Id="FirstName" Type="VarChar" Length="255" NoOverride="Required"/>
    </Fields>
</Table>

<View Id="People" TableId="Contacts">
    <Fields>
        <Column Id="FirstName" Length="100" Required="true"/>
    </Fields>
</View>

Result, note Required="true" is ignored.

<Table Id="Contacts">
    <Fields>
        <Column Id="FirstName" Type="VarChar" Length="100" />
    </Fields>
</Table>

Article Topics

For Developers

Want to learn more?

Call 800-924-5220 or

Schedule a demo