When Acrolinx extracts elements from YAML documents, it recognizes areas with relevant information and assigns them contexts. To determine what Acrolinx extracts, you can select and configure these contexts.
Keep in mind that you can't configure the Content Profile to extract YAML comments.
Note
It's also possible to check JSON documents with the YAML Content Profile since JSON is a subset of YAML. However, we recommend that you use the JSON Content Profile. Acrolinx will provide you with this and other Content Profiles that you can adjust according to your needs.
There are two types of contexts — static and dynamic.
Static contexts are document independent. Acrolinx assigns the following static contexts to portions of the extracted text. None of these have attributes.
YAML_MAP
Use the Element Name YAML_MAP to indicate that the extracted text snippet is inside a map.
To include YAML_MAP, follow these steps:
-
Enter
YAML_MAPin Element Name. -
Select include in Filter Mode.
YAML_COMPLEX_NAME
Use the Element Name YAML_COMPLEX_NAME to indicate that the text snippet is inside a map's value and has a hierarchical key. In other words, a Dynamic Context can't address it.
To include YAML_COMPLEX_NAME in your check, follow these steps:
-
Enter
YAML_COMPLEX_NAMEin Element Name. -
Select include in Filter Mode.
YAML_ITEM
Use the Element Name YAML_ITEM to indicate that a text snippet is inside an item within a sequence.
To include YAML_ITEM in your check, follow these steps:
-
Enter
YAML_ITEMin Element Name. -
Select include in Filter Mode.
YAML_SEQUENCE
Use the Element Name YAML_SEQUENCE to indicate that the extracted text snippet is inside a sequence.
To include YAML_SEQUENCE in your check, follow these steps:
-
Enter
YAML_SEQUENCEin Element Name. -
Select include in Filter Mode.
From a practical perspective, static contexts aren't very useful. This is because static contexts target all of the content in typical YAML documents. For that reason, they’re usually not specific enough.
In the configuration example below, for instance, the information is a YAML_SEQUENCE of YAML_ITEMs of a YAML_MAP. If you specify one of these static contexts in the Content Profile, it will reference all of the values in the example. But what if you're only interested in job, name, and skill set? This is why Acrolinx can also extract dynamic contexts.
For every map's value, the extracted text has a context that the:
-
Respective
keyin the map names -
with an attribute "name" that is also the
value'skey.
The only exceptions are key/value pairs with hierarchic keys.
You can only extract the values from the key/value pairs. There are 3 ways to select these values for extraction:
Specify the Key as the Element Name
To extract names, you can use the Element Name fullname.
To include fullname in your check, for example, follow these steps:
-
Enter
fullnamein Element Name. -
Select include in Filter Mode.
Specify the Key as a Name Attribute
If you want to extract a key with a space in the name, for example "skill set", you’ll need to use the name attribute *name="". This references the attribute name that is identical to the two-word key.
To include a two-word element like "skill set" in your check, follow these steps:
-
Enter
*name="skill set"in Element Name. -
Select include in Filter Mode.
Specify a Key That Is a Hierarchical Structure
If the key is a hierarchical structure instead of a string, you’ll need to specify a different Element Name to extract the value of this type of key.
To extract the value of a key with a hierarchical structure, follow these steps:
-
Enter
YAML_COMPLEX_NAMEin Element Name. -
Select include in Filter Mode.
Because YAML_COMPLEX_NAME is a static context, it targets all values of all the hierarchical keys of the YML document.
Note
By default, Acrolinx extracts all non-key surfaces from the document with sentence breaks between them. All static contexts default to included and the Default Break Level is sentence. Parent maps or sequences won’t cause additional breaks (For YAML_SEQUENCE and YAML_MAP, the configured Break Level is none).
In production, you would want to exclude everything from the start, and include specific keys (dynamic contexts) only.
Let's say you want to configure a Content Profile for customer YAML documents like this one:
employees.yaml
# Employee records
- martin:
id: sdzre-88-921
fullname: Martin Dev
department: 344/2233 - B
job: Developer
skill set:
- lisp
- erlang
age: 32
Without a dedicated Content Profile, all of these text snippets would have sentence breaks between them. You'll want to check (and extract) the following:
-
Martin Dev
-
Developer
-
lisp
-
erlang
The following Content Profile does the trick:
Note
You can't address "skill set" by element name (the space makes "skill set" an invalid element name). You’ll need to use the name attribute instead. That's why every static context also hosts its name in an attribute "name".