# HTML Mask (HtmlMaskGenerator)

The [HTML Mask](https://docs.tonic.ai/app/generation/generators/generator-reference/html-mask) generator masks text columns. It parses the content as HTML, and applies sub-generators to specified path expressions.

If a sub-generator application fails because of an error, then Structural applies the fallback generator instead.

## Link object structure <a href="#generator-api-html-mask-link-object" id="generator-api-html-mask-link-object"></a>

For the HTML Mask generator, there is a link object for each XPath expression value to assign a generator to.

The generator does not itself support consistency or differential privacy.

The `metadata` object is populated from the [`HtmlMaskMetadata`](https://app.tonic.ai/apidocs/index.html#/models/HtmlMaskMetadata) object. It includes:

* `pathExpression`, which is the XPath expression that identifies the value to apply the sub-generator to.
* The `subGeneratorMetadata` object, which identifies and configures the sub-generator.

{% code overflow="wrap" %}

```json
{
  "schema": "string",
  "table": "string",
  "column": "string",
  "metadata": {
    "generatorId": "HtmlMaskGenerator",
    "customValueProcessor": "string",  //If custom value processor applied
    "pathExpression": "string",
    "subGeneratorMetadata": {
      "presetId": "string",
      "generatorId": "string",
      //Metadata for the selected sub-generator
      "customValueProcessor": "string"  //If custom value processor applied to the sub-generator
    }
  }
}
```

{% endcode %}

## Example replacement <a href="#generator-api-html-mask-replacement" id="generator-api-html-mask-replacement"></a>

In the following example replacement for the HTML Mask generator:

* The Character Scramble generator is assigned to the value of the XPath expression `//p`. Consistency is disabled.
* The Company Name generator is assigned to the value of the XPath expression `//p/@data`. Consistency is disabled.
* In the case of an error applying either of those generators, the fallback generator is the Constant generator, which sets the value to `10`.

```json
{
  "name": "html_data",
  "schema": "public",
  "table": "html_me",
  "links": [
    {
      "schema": "public",
      "table": "html_me",
      "column": "html_data",
      "metadata": {
        "generatorId": "HtmlMaskGenerator",
        "presetId": "HtmlMaskGenerator",
        "pathExpression": "//p",
        "subGeneratorMetadata": {
          "presetId": "TextMaskGenerator",
          "generatorId": "TextMaskGenerator",
          "isConsistent": false
        }
      }
    },
    {,
      "schema": "public",
      "table": "html_me",
      "column": "html_data",
      "metadata": {
        "generatorId": "HtmlMaskGenerator",
        "presetId": "HtmlMaskGenerator",
        "pathExpression": "//p/@data",
        "subGeneratorMetadata": {
          "presetId": "CompanyNameGenerator",
          "generatorId": "CompanyNameGenerator",
          "isConsistent": false
        }
      }
    }
  ],
  "fallbackLinks": [
    {
      "schema": "public",
      "table": "html_me",
      "column": "html_data",
      "metadata": {
        "presetId": "string",
        "generatorId": "ConstantGenerator",
        "constant": "10"
      }
    }
  ]
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tonic.ai/app/api/quick-start-guide/tonic-api-generator-assignment/generator-api-reference/generator-api-ref-html-mask.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
