Enumerations

<< Click to Display Table of Contents >>

EQuIS 7  >>  EDP > EDP Install, Configuration, Administration > Configuration >

Enumerations

Enumerations are a way to enforce vocabulary on fields that have no reference tables. Enumerations can also restrict the vocabulary of fields that do have existing reference tables. They are used in EDP and in EDGE to enforce specific lookup values for key fields.

The enumerations are defined in one of two places:

1.Format File. This is in the code of the format itself (.xse, .xsd) and is typically encrypted.

2.Enum File. This is an auxiliary enumeration file, e.g. EQEDD-enum.xml. This remains unencrypted and is editable by the user. The enumeration file must be in the same directory as the rest of the format files and properly named and referenced within the format file, otherwise an error will occur when opening the format.

 
Fields that use enumerations have a drop-down list, similar to fields with lookup mappings. Enumerations are used for specifying valid values that are typically not in the EQuIS database. They can also be used to limit the list of valid values found in a reference table. For example, use an enumeration to limit the valid values for units in a reference table. If you are adding elevation units to the format and the only options you would want the user to have available in the drop-down list would be “Y” (Yes) and “N” (No), you create an enumeration with only those two values. Defining an enumeration is shown below:

 

<xs:simpleType name="yes_no">
 <xs:restriction base="xs:string">
   <xs:maxLength value="1" />
   <xs:enumeration value="Y" />
   <xs:enumeration value="N" />
 </xs:restriction>
</xs:simpleType>

The attribute name defines the name of the enumeration and is only used if the enumeration is defined in an enumeration file. The attribute base in the restriction tag defines the type (“xs:string” means text) each enumeration value must be, and the attribute value in the maxLength tag defines the maximum length an enumeration value can have. This enumeration contains two values, “Y” and “N”, defined by the value attribute in the two enumeration tags. Several different fields can use the same enumeration. For an example of how to use an enumeration with a field, see the Fields section.

 

Updating an Enumeration

 

For EQEDD, the enumerations are stored in an auxiliary file: C:\Program Files\EarthSoft\EQuIS\Formats\EarthSoft\EQEDD-enum.xml. These enumerations can be edited as needed.

To update an enumeration file, find the enumeration name within the text file (generating an EDD Description can be used). The enumeration file can be opened in Microsoft Visual Studio (allows collapsing of enumerations and color coding) or Notepad. To add an enumeration to a field, add an attribute type to the field declaration with the value equal to the enumeration name.

 

<xs:element name="composite_yn" type="yes_no" nillable="false" default="Y">

 

Multi-Column Enumerations

 

Enumerations can be set up to display more than one column in the drop-down in EDP. The edd_column namespace must be added to the schema element in the file containing the enumeration.

 

<xs:schema id="EQEDD" targetNamespace="http://tempuri.org/EQEDD" xmlns:edd_column="http://www.earthsoft.com/support/edp/ff"/>

 

Adding the edd_column attribute to an enumeration will add another column to the enumeration drop-down. The enumeration name will be the column name for the list of values.

 

<xs:simpleType name="yes_no">
 <xs:restriction base="xs:string">
   <xs:maxLength value="1" />
   <xs:enumeration value="Y" edd_column:description="Yes" />
   <xs:enumeration value="N" edd_column:description="No" />
 </xs:restriction>
</xs:simpleType>

 

Sorting Enumerations

 

There are two ways to sort an enumeration. Either (1) Add the edd:enum_sort attribute on the enumeration, or (2) the format field using the enumeration. If both are used, then the sort order placed on the format field declaration will take precedence.

 

The following example sorts the enumeration in descending value by the description column.

 

<xs:simpleType name="yes_no" edd:enum_sort="description desc">
 <xs:restriction base="xs:string">
   <xs:maxLength value="1" />
   <xs:enumeration value="Y" edd_column:description="Yes" />
   <xs:enumeration value="N" edd_column:description="No" />
 </xs:restriction>
</xs:simpleType>

 

The following example sorts the enumeration by the yes_no/value column in ascending order.

 

<xs:element name="composite_yn" type="yes_no" edd:enum_sort="yes_no asc" nillable="false" default="Y">