Enumerations

<< Click to Display Table of Contents >>

Navigation:  EDP > EQuIS Format Files >

Enumerations

•Overview

•Updating an Enumeration

•To Add, Replace, or Remove 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 enforce vocabulary in fields that do not have reference tables. Enumerations can also restrict the vocabulary of fields that already use reference tables. In EDP and EDGE, enumerations are used to enforce specific lookup values for 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 or embedded in the *.dll.

2.Enum File – This is an auxiliary enumeration file (e.g., EQEDD-enum.xml). It is unencrypted and can be edited by the user. The enumeration file must be in the same directory as the other format files, and it must be 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 define valid values that are typically not stored in the EQuIS database, and they can also be used to limit the list of valid values from 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. An example 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 name attribute in the simpleType tag defines the name of the enumeration and is only used when the enumeration is defined in an enumeration file. The base attribute in the restriction tag defines the data type for each enumeration value (for example, xs:string means text), and the value attribute in the maxLength tag defines the maximum length allowed for each  enumeration. In the example above, the enumeration contains two values, “Y” and “N”, defined by the value attribute in the two enumeration tags. Multiple fields can use the same enumeration.

 

 

Updating an Enumeration

To update an enumeration file, locate the enumeration name within the text file. An EDD Description file can be generated in EDP to aid in locating enumeration names (see EQuIS Descriptions and Blank EDD Files for more information). The enumeration file can be opened in Microsoft Visual Studio, which allows collapsing of enumerations and color coding, or in Notepad.

 

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 Add, Replace, or Remove the Values in the Enumeration File

 

Original depth_unit Enumeration

1  <xs:simpleType name="depth_unit">

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

3       <xs:maxLength value="2" />

4       <xs:enumeration value="ft" />

5       <xs:enumeration value="m" />

6    </xs:restriction>

7  </xs:simpleType>

 

 

Add: To add ‘in’ as value to the original depth_unit enumeration, insert the following record anywhere between lines 3-6. Then save the changes.

 

<xs:enumeration value="in" />  

 

1  <xs:simpleType name="depth_unit">

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

3       <xs:maxLength value="2" />

4       <xs:enumeration value="ft" />

5       <xs:enumeration value="m" />

6       <xs:enumeration value="in" />

7    </xs:restriction>

8  </xs:simpleType>

 

Replace: To replace ‘m’ with ‘in’ in the original depth_unit enumeration, replace “m” with “in” on line 5. Then save the changes.

 

1  <xs:simpleType name="depth_unit">

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

3       <xs:maxLength value="2" />

4       <xs:enumeration value="ft" />

5       <xs:enumeration value="in" />

6    </xs:restriction>

7  </xs:simpleType>

 

Remove: To remove ‘m’ in the original depth_unit enumeration, delete line 5. Then save the changes.

 

1  <xs:simpleType name="depth_unit">

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

3       <xs:maxLength value="2" />

4       <xs:enumeration value="ft" />

5    </xs:restriction>

6  </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 shown above. To apply the enumeration to the field, add type attribute to the field declaration and set its value to the enumeration name.

 

Examples:

 

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

 

In the above example, from the EQEDD format, TestResult_v1,detect_flag will point to the detect_flag enumeration defined in EQEDD-enum.xml.

 

<xs:element name="composite_yn" type="yes_no_values" nillable="false">

 

In the above example, from the EQEDD format, FieldSample_v1,composite_yn will point to the yes_no_values enumeration defined in EQEDD-enum.xml.

 

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. To do this, add the edd_column namespace to the schema element in the file that contains 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 adds another column to the enumeration drop-down. The enumeration name becomes 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 to the enumeration, or (2) add it to the format field that uses the enumeration. If both are used, then the sort order defined 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, Professional EDP (with application-level security) and Enterprise EDP require the format either or be embedded as a resource in a strong-named .NET assembly (i.e., *.dll) or encrypted (i.e., .xse). 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 custom handler logic referring 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.