> For the complete documentation index, see [llms.txt](https://community-test.logicnets.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://community-test.logicnets.com/release-9/platform-documentation/process-node-parts/generate-xml-via-xslt-template.md).

# Generate XML via XSLT-template

## Description

The *Generate XML via XSLT-template* part is available in project nodes in the *App Dev* dropdown menu. You can use this part to create an XML document using a translation template that specifies how to format the document and which data objects to output in a specific way.

## Use

You can use the required template from the *resources\documents* folder of the same LogicNets project. The following is a basic template example and the file format is XML:

```
<report>
  <meta>
    <reportMeta>
      <reportId>$(reportKey)</reportId>
    </reportMeta>
  <patientMeta>
    <patientId>$(patientId)</patientId>
    <patientName>$(patientName)</patientName>
    <patientGender>$(patientGender)</patientGender>
    <patientBirthdate>$(patientBirthdate)</patientBirthdate>
  </patientMeta>
  </meta>
  <xsl:include-template group="templates.example"/>
</report>
```

Interpolation is used for obtaining the actual values to be inserted into the specified places.

The system interprets all XML nodes starting with *xsl:* as commands to allow reuse of output template definitions and to specify how to print data objects. The select attribute specifies the name of the object without interpolation.

The system interprets the following commands:

| Command                        | Action                                                                                                                                                                                                                                                                     |
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| xsl:import-session             | Import the current session data and write it as base64-encoded content.                                                                                                                                                                                                    |
| xsl:import                     | Write the content of a container object instead of a text object.                                                                                                                                                                                                          |
| xsl:plain-text-string          | Simple text write. The system strips the HTML content of the string.                                                                                                                                                                                                       |
| xsl:for-each-k-v               | Write the data object as key/value pairs.                                                                                                                                                                                                                                  |
| xsl:for-each-k-v-simple        | Write the values of a data object.                                                                                                                                                                                                                                         |
| xsl:for-each-k-v-in-collection | Write the values of a collection data object.                                                                                                                                                                                                                              |
| xsl:collection-to-string       | Write the collection data object as a concatenated string. Specify the separator as attribute; for example, *separator="\|">*.                                                                                                                                             |
| xsl:for-each                   | Write simply the values of a collection data object.                                                                                                                                                                                                                       |
| xsl:xsl-escape-html            | Write the text data object with enforced HTML escaping. You can use this to prevent broken XML if there are illegal characters in the text.                                                                                                                                |
| xsl:xsl-base64                 | Write the data object as base64-encoded string.                                                                                                                                                                                                                            |
| xsl:if                         | Make the internal nodes conditional; for example, *test="'$(settings.ExportText)' \~='no'">*. You can use the ctx attribute to specify the context to extract the variables for the test attribute. Use base for the root object specified in the *Data Source* parameter. |
| xsl:template                   | Defines a reusable template.                                                                                                                                                                                                                                               |
| xsl:include-template           | Specify that a configured template should be printed; for example, *group="templates.example"/>*.                                                                                                                                                                          |

## Editor Fields

| Field Name                | Description/Use                                                                                                                                           | Type/Options       | Optional/Mandatory |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ------------------ |
| Data Object               | This is the name of the data object in which the messages will be stored.                                                                                 | Data Object        | Mandatory          |
| Filename of XSLT-template | This is the name of the translation file.                                                                                                                 | Document Reference | Mandatory          |
| Data source               | This is the data object containing the content used by the template. If you do not specify this item the system uses the running context of the logicnet. | Data Object        | Options            |

## Example

Download and import the [following example](/release-9/example-gallery/example-projects-for-parts/xml_xslt-example-project.md) project in your workspace.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://community-test.logicnets.com/release-9/platform-documentation/process-node-parts/generate-xml-via-xslt-template.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
