Enumerations

<< Click to Display Table of Contents >>

Navigation:  EDP > EQuIS Format Files >

Enumerations

Overview

Updating an Enumeration

To Add or Replace the Values in the Enumeration File

To Create a New Enumeration File and then Use the File

Multi-Column Enumerations

Sorting Enumerations

To Allow Text in the Result for Certain CAS_RNs in the EQEDD_v2 Enumeration File

Office Hour Video

Overview

 

Enumerations are a way to enforce vocabulary in 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.EQuIS Format Definition (EFD) File – This is in the code of the format itself (i.e., .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, create an enumeration with only "Y” (Yes) and “N” (No) to restrict the available drop-down list to only those two values in a format where a user is adding elevation units. 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.

 

 

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. Generate an EDD Description file in EDP to find the enumeration names (see EQuIS Descriptions and Blank EDD Files for more information). 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">

 

 

To Add or Replace the Values in the Enumeration File

 

<xs:simpleType name="detect_flag">

 <xs:restriction base="xs:string">

  <xs:maxLength value="2" />

  <xs:enumeration value="Y" />

  <xs:enumeration value="N" />

   <xs:enumeration value="TR" />

 </xs:restriction>

</xs:simpleType>

 

 

To Create a New Enumeration File and then Use the File

 

Use an unencrypted format file (.xsd) and then create the enumeration as show above. To add the enumeration to the field, add an attribute "type" to the field declaration with the value equal to the enumeration name.

 

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

 

If the type attribute is defined in the field declaration header, then it cannot have a simpleType sub node.

 

<xs:simpleType>

 <xs:restriction base="xs:string">

  <xs:maxLength value="40" />

  </xs:restriction>

</xs:simpleType>

 

 

Multi-Column Enumerations

 

Enumerations can be setup 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: (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">

 

Note: After making the desired changes to the format file, it is required when using Professional EDP (with application-level security) or Enterprise EDP that the format either be encrypted by EarthSoft (i.e., *.xse) or be embedded as a resource in a strong-named .NET assembly (i.e., *.dll). See Securing EDD Formats for additional information.

 

 

To Allow Text in the Result for Certain CAS_RNs in the EQEDD_v2 Enumeration File

 

This is possible only in formats that have a custom handler in the format logic that refers to the enumeration list for CAS RNs, such as the TestResults_v2 section in the EQEDD_v2 format. Only lowercase letters can be used in the "".

 

<xs:simpleType name="text_cas_rn">

 <xs:restriction base="xs:string">

   <xs:maxLength value="20" />

   <xs:enumeration value="asbestos" />

   <xs:enumeration value="color" />

   <xs:enumeration value="coliform" />

 </xs:restriction>

</xs:simpleType>

 

 

Office Hour Video

 
For more information, see our Office Hour video EQuIS FAQ Series: Enumerations - Your New Best Friend for Data Checks.