Meta tags
- cml:instructions - Specify instructions for a field
- cml:gold - Define the gold specification for a field
- cml:group - Group related fields together
- cml:meta - Define gold or aggregation behavior for non-CML fields
cml:instructions
Can only be a child of a regular field tag. The contents of this tag specify the instructions for a field. If both an instructions attribute and a <cml:instructions> tag are specified, only the value of the attribute on the field tag will be used.
<cml:radios label="Sample radio buttons:">
<cml:instructions>Check one of these.</cml:instructions>
<cml:radio label="Radio 1" />
<cml:radio label="Radio 2" />
<cml:radio label="Radio 3" />
</cml:radios>

cml:gold
The various attributes of this tag define the behavior of gold on a field. This can only be a child of a regular field tag.
<cml:checkboxes label="Sample radio buttons:">
<cml:gold src="gold_column_name" strict="true" />
<cml:checkbox label="Checkbox 1" />
<cml:checkbox label="Checkbox 2" />
<cml:checkbox label="Checkbox 3" />
</cml:checkboxes><cml:text label="Sample text field:">
<cml:gold src="source_column_name" regex="\\d+\." flags="i" no_escape="true" />
</cml:text>
Attributes:
src
exact
strict
matcher
cml:gold and regular expressions
Regular expressions can be used to create flexible criteria for gold on text and textarea fields. Suppose you want to allow any response that contains the phrase ‘foo bar’ to be submitted in a text field.
Here’s how you would go about setting up the regular expression match for the text field:
1. Inside your CML text field tag, add a cml:gold tag and its associated attributes.
<cml:text label="What words are sometimes used as placeholder names?" name="field_name"><cml:gold regex="{seed}" flags="i"></cml:gold></cml:text>
You can set the following regular expression attributes in your cml:gold tag:
regex:
The value of this attribute is the regular expression that a correct response should satisfy. The token {seed} will be replaced with the value of the 'response_gold' field in your data when the regex attempts to match the response. For example, if you’re trying to match ‘foo bar’, or another simple phrase, set the the regex to {seed} (regex="{seed}") in your cml:gold field, and set ‘response_gold’ to ‘foo bar’.
flags:
In this attribute, you can set modifiers that will change the behavior of the regular expression. Currently, there are two values that are accepted.
- flags="i" - Makes the regex insensitive to case. E.g., If you set the 'response_gold' field to 'foo bar' but also want to accept 'Foo bar', the capital F will not cause the match to fail.
- flags="m" - If you are expecting to receive multiple line responses, the 'm' flag will ensure that the entire response is evaluated. This is essential for copy/paste jobs.
flags="im"). No delimiter is needed.
no_escape:
When the ‘response_gold’ for your unit is substituted for {seed} in the regular expression, any special or illegal regular expression characters are escaped. E.g., ”|” is considered a special character in regular expressions. By default, it will be escaped and lose its special meaning unless ‘no_escape’ contains the value “true”.
Example: If you wanted to match either ‘first base’,’second base’ or ‘third base’, you might try setting ‘response_gold’ to '(first|second|third) base'. However, this would not work since the special characters would be escaped and only the literal string '(first|second|third) base' would be matched, parentheses, pipe and all. Setting no_escape="true" would have the desired effect, allowing any of the three options as a correct response.
2. Add the gold data column to your input spreadsheet or in the gold digging interface.
Let’s say you name your regex text field ‘response’. In your input data, you will need to add a 'response_gold' field and populate it with the phrase or pattern to match for each unit. Your spreadsheet might look like this:
| query | response_gold |
| Most popular sports in the United Stated? | baseball|football|backetball |
| The largest political parties in the United States? | Republican|Democratic |
| Pet names for your children? | sweetie|toots|sugarpie |
Keep in mind that if you’re using special regex characters like ”|”, you’ll have to set no_escape=”true” in your CML.
Digging gold can be done as usual, except you have to be conscious of using regular expression special characters and escaping characters if needed.
3. Set the field to gold in the graphical form interface
If you’ve predefined your gold in an uploaded spreadsheet, you’ll have to use the graphical form builder to make the ‘response’ field gold and use the ‘response_gold’ column for gold data. See the faq for more details.
cml:group
Groups related fields together so that they can easily be hidden/shown with CML logic without writing only-if attributes for every field.
<cml:checkbox label="Show extra fields?" name="show_extras" />
<cml:group only-if="!show_extras:unchecked">
<cml:text label="Sample text field:" instructions="Enter text above" />
<cml:checkboxes validates="required" label="Sample checkboxes:">
<cml:checkbox label="Checkbox 1" />
<cml:checkbox label="Checkbox 2" />
<cml:checkbox label="Checkbox 3" />
</cml:checkboxes>
</cml:group>
In the above example, both the cml:text and cml:checkboxes fields will be hidden/shown depending on whether the show_extras field passes the checked validator.
cml:meta
Defines gold and aggregation behavior for non-CML fields. This is useful when you want to use custom non-CML fields for gold and have worker responses aggregated.
<cml:meta name="my_field" gold="true" aggregation="agg" />