# What is ADX?

The Atfinity Document XML (ADX) format is a way to describe what should be on a document and how it should be rendered. It's design is loosely inspired by HTML, so if you are familiar with HTML you will probably feel right at home quickly.

ADX documents are just [XML](https://www.w3schools.com/xml/xml_whatis.asp) documents that are templated with [Jinja](https://jinja.palletsprojects.com) to display case information where you need it. To write ADX it helps if you are familiar with XML and Jinja.

## Getting Started

### Document Structure

An ADX template needs to at least contain a root tag and a body. For everything but testing, you probably also want to add content within the body. A very simple ADX would look like this:

```xml
<adx>
  <body>
    <text>
      Hello World! This is an ADX document rendered by Atfinity.
    </text>
  </body>
</adx>
```

In most cases, you also want to customise the template your content is printed on. You do this by defining a template and then using it, like this:

```xml
<adx>
  <pageTemplates>
    <template
      id="simple_header"
      pageSize="A4"
      pageMargins="10cm 2cm 5cm 2cm"
    >
        <text
          bottom="287mm"
          left="20mm"
          width="190mm"
          height="10mm"
          color="blue"
          fontSize="80"
        >
            Header
        </text>
    </template>
  </pageTemplates>
  <body template="simple_header">
    <text>
      Hello World! This is an ADX document rendered by Atfinity.
    </text>
  </body>
</adx>
```

Above we define a template with the id `simple_header` and then use it later by setting the template of body to the same id.

### Displaying Case Information

To connect such a document to a case, we add some Jinja instructions to place information values and fields. The matches instances of a document conditions are available to you, so you can place information like this:

```xml
<adx>
  <body>
    <text>
      Hello World! Here is a field from a person matched in the case {{p.first_name}}
    </text>
  </body>
</adx>
```

As you can see, Jinja instructions are within `{{...}}` blocks. They follow a syntax very similar to Python (head to the [Jinja documentation](http://jinja.palletsprojects.com) for details).

If you want to display a field, you can combine this with a field tag like this:

```xml
<adx>
  <body>
    <field title="First Name" type="box_below">
      {{p.first_name}}
    </field>
    <field title="Last Name" type="box_below">
      {{p.last_name}}
    </field>
  </body>
</adx>
```


---

# 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.atfinity.io/document-xml-adx/what-is-adx.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.
