---
title: "XSLT macro"
canonical: "https://support.appfire.com/space/HTML/70617219/XSLT%20macro"
format: markdown
---
> Macro (aura-html)

## <span style="color: #000000">Features</span>

- <span style="color: #000000">Uses XSLT to transform XML to HTML, XHTML, or wiki markup. Supports XSLT 1.0.</span>
- <span style="color: #000000">It supports working with XSL parameters, but it is only available with the </span><span style="color: #000000">*wiki*</span><span style="color: #000000"> output format. See the </span><span style="color: #000000">[Passing parameters to the XSLT engine](#transformerParameters)</span><span style="color: #000000"> section.</span>
- <span style="color: #000000">Supports security restrictions as described in</span> [Macro Security for Confluence](https://appfire.atlassian.net/wiki/x/CIAEB)<span style="color: #000000">.</span>
- <span style="color: #000000">Supports capabilities for including data similar to other scripting macros.</span>
- <span style="color: #000000">Supports find and replace for adjusting the resulting output.</span>

> ℹ️ - <span style="color: #000000">The macro works with valid, downloadable XML and XSLT files only. </span>
> ℹ️ - <span style="color: #000000">If you want to specify a URL in the </span>*Location*<span style="color: #000000"> parameters, make sure that only a raw URL is provided. A raw URL is defined as the part of the URL following the domain information and includes the query string, if present. For example, in the URL string </span>`http://www.contoso.com/articles/recent.aspx`<span style="color: #000000">, the raw URL is </span>`/articles/recent.aspx`<span style="color: #000000">.</span>

## <span style="color: #000000">Parameters</span>

| **Macro browser label** | **Default** | **Description** | **Macro parameter** |
| --- | --- | --- | --- |
| <span style="color: #000000">*Transformed output format*</span> | <span style="color: #000000">*html*</span> | <span style="color: #000000">Specify how the output is treated. The options are as follows:</span><br>- <span style="color: #000000">*html*</span><span style="color: #000000"> - transformed output is standard HTML.</span>
- <span style="color: #000000">*xhtml*</span><span style="color: #000000"> - transformed output is treated as XHTML and rendered with the Confluence XHTML renderer.</span>
- <span style="color: #000000">*wiki*</span><span style="color: #000000"> - transformed output is treated as wiki markup and rendered with the Confluence wiki renderer.</span> | <span style="color: #000000">output</span> |
| <span style="color: #000000">*Profile*</span> |  | <span style="color: #000000">Enter the profile name to access the files to be transformed. Profiles contain a basic set of parameters used to access a remote location, such as the type of URL, user credentials, and so on. </span>Refer to the [profiles configuration](https://appfire.atlassian.net/wiki/x/l4E1B#html_57_config_profiles) to learn more about profiles and see [tutorials](https://appfire.atlassian.net/wiki/x/2IE1B).<br>> ⚠️ - <span style="color: #000000">Contact your Confluence administrator for further information about the profiles available in your instance.</span>
> ⚠️ - <span style="color: #000000">If a profile is specified, it is recommended to provide the relative path to the location of the XML file to be rendered.</span> | <span style="color: #000000">profile</span> |
| <span style="color: #000000">*Location of XML code*</span> | <span style="color: #000000">macro body</span> | <span style="color: #000000">Enter the location of the XML data. By default, the macro transforms the code entered in the macro body.</span><br>- <span style="color: #000000">*#filename*</span><span style="color: #000000"> - Data is read from the file located in Confluence </span>`home/script/filename`<span style="color: #000000"> directory. Subdirectories can be specified.</span>
- <span style="color: #000000">*global page template name*</span><span style="color: #000000"> - Data is read from a global page template. Special note:</span> [How to deal with templates on Confluence 4.3 and later](https://appfire.atlassian.net/wiki/spaces/info/pages/86120194)<span style="color: #000000">.</span>
- <span style="color: #000000">*space:page template name*</span><span style="color: #000000"> - Data is read from a space template.</span>
- <span style="color: #000000">*#http://...*</span><span style="color: #000000"> - Data is read from the URL specified. May require user name and password as well.</span><br>> ℹ️ <span style="color: #000000">If a </span><span style="color: #000000">*Profile*</span><span style="color: #000000"> is specified, the pound (#) sign is optional; that is, the URL is processed regardless of the pound (#) sign before the URL.</span><br>- *^attachment*<span style="color: #000000"> - Data is read from an attachment to the current page.</span>
- <span style="color: #000000">*page^attachment*</span><span style="color: #000000"> - Data is read from an attachment to the page name provided.</span>
- <span style="color: #000000">*space:page^attachment*</span><span style="color: #000000"> - Data is read from an attachment to the page name provided in the space indicated.</span><br>> ⚠️ *Precedence in URL handling*
> ⚠️ 
> ⚠️ <span style="color: #000000">URLs are processed using a fixed precedence explained as follows:</span>
> ⚠️ 
> ⚠️ 1. <span style="color: #000000">If the given URL is linked to a specific application like Bitbucket, GitLab, or GitHub, the macro does not require any user credentials and processes and renders the given file. </span>Refer to [application links](https://appfire.atlassian.net/wiki/x/14Q1B) for information.
> ⚠️ 2. <span style="color: #000000">If </span><span style="color: #000000">*Profile*</span><span style="color: #000000"> is specified, the macro appends the URL given here with the URL specified in the profile configuration and accesses the location to render the required file.</span>
> ⚠️ 3. <span style="color: #000000">Lastly, if no application links or profiles were given, the URLs are processed as-is and the required file is rendered.</span> | <span style="color: #000000">source</span> |
| <span style="color: #000000">*Location of XSL code*</span> | <span style="color: #000000">macro body</span> | <span style="color: #000000">Enter the location of the XSL code. This field becomes mandatory if source XML code is entered in the macro body. By default, though, the XSL content in the macro body is considered.</span><br>- <span style="color: #000000">*#filename*</span><span style="color: #000000"> - Data is read from the file located in Confluence </span>`home/script/filename`<span style="color: #000000"> directory. Subdirectories can be specified.</span>
- <span style="color: #000000">*global page template name*</span><span style="color: #000000"> - Data is read from a global page template. Special note:</span> [How to deal with templates on Confluence 4.3 and later](https://appfire.atlassian.net/wiki/spaces/info/pages/86120194)<span style="color: #000000">.</span>
- <span style="color: #000000">*space:page template name*</span><span style="color: #000000"> - Data is read from a space template.</span>
- <span style="color: #000000">*#http://...*</span><span style="color: #000000"> - Data is read from the URL specified. May require user name and password as well. </span><br>> ℹ️ <span style="color: #000000">If a </span><span style="color: #000000">*Profile*</span><span style="color: #000000"> is specified, the pound (#) sign is optional, that is, the URL is processed regardless of the pound (#) sign before the URL.</span><br>- *^attachment*<span style="color: #000000"> - Data is read from an attachment to the current page.</span>
- <span style="color: #000000">*page^attachment*</span><span style="color: #000000"> - Data is read from an attachment to the page name provided.</span>
- <span style="color: #000000">*space:page^attachment*</span><span style="color: #000000"> - Data is read from an attachment to the page name provided in the space indicated.</span> | <span style="color: #000000">style</span> |
| <span style="color: #000000">*Find regex patterns*</span> |  | <span style="color: #000000">Enter a comma-separated list of regex patterns to repair and modify XML prior to processing by the XSLT processor with find and replace logic. </span>Read more about [regular expressions](https://appfire.atlassian.net/wiki/x/JIE1B).<br><span style="color: #000000">Example: </span>`(google\.dtd)` | <span style="color: #000000">find</span> |
| <span style="color: #000000">*Replacement strings*</span> |  | <span style="color: #000000">Enter a comma-separated list of positions to search for patterns in the output content. Note that the positions are indexed beginning at "1". If a comma is a part of an entry, use single quotes around it.</span><br><span style="color: #000000">Example: </span>`http://www.google.com/$1` | <span style="color: #000000">replace</span> |
| <span style="color: #000000">*Include head section HTML*</span> | <span style="color: #000000">false</span> | <span style="color: #000000">Enable this option to retain all the other tags from the header section and treat them as regular body content. This is useful for retaining style information in particular. By default, the head tag is always removed. </span> | <span style="color: #000000">head</span> |
| *Show error message panel* | <span style="color: #000000">false</span> | <span style="color: #000000">Displays the XSL transformer generated warning and errors in a panel even if the transformation is not terminated with an error. Terminating errors automatically generate an error panel.</span> | <span style="color: #000000">showErrors</span> |
| <span style="color: #000000">*Error level*</span> | *NONE* | <span style="color: #000000">Specify the level at which the data processing fails. The selected level determines how the XSLT macro handles data processing errors. The options are:</span><br>- <span style="color: #000000">*NONE*</span><span style="color: #000000"> - No action is to be taken.</span>
- <span style="color: #000000">*WARNING*</span><span style="color: #000000"> - Display a warning about the data process; processing does not stop.</span>
- <span style="color: #000000">*ERROR*</span><span style="color: #000000"> - Display an error and further processing is halted.</span>
- <span style="color: #000000">*FATAL*</span><span style="color: #000000"> - Stops any further data processing.</span> |  |
| <span style="color: #000000">*File encoding*</span> | <span style="color: #000000">system default</span> | <span style="color: #000000">Specify the encoding for an external file, if different from the system default handling. </span><br><span style="color: #000000">Example: </span>`UTF-8` | <span style="color: #000000">encoding</span> |
| <span style="color: #000000">*Timeout in milliseconds*</span> |  | <span style="color: #000000">Enter the time in milliseconds to wait until the URL connection times out before getting data. Use this to increase the time needed for slow connections. Note that if a zero is given, the connection may wait indefinitely.</span> | <span style="color: #000000">timeout</span> |
| <span style="color: #000000">*Disable secure processing feature*</span> | <span style="color: #000000">false</span> | <span style="color: #000000">Enable this option to disable secure processing of XML and XSL files. </span><br><span style="color: #000000">If authorized by your Confluence administrator to change this setting, more powerful capabilities are available. See</span> > Macro (jira)

<span style="color: #000000"> for details. Administrators can use</span> [Macro Security for Confluence](https://appfire.atlassian.net/wiki/x/CIAEB) <span style="color: #000000">to enable these more powerful capabilities.</span> | <span style="color: #000000">disableSecureProcessing</span> |
| <span style="color: #000000">*XSLT Version*</span> | <span style="color: #000000">*1.0*</span> | <span style="color: #000000">Select the version based on your style (XSLT) input document. This drop-down contains the XSLT versions that the macro is compatible with. It has been available since version 5.4.0.</span> | <span style="color: #000000">xsltVersion</span> |

> ℹ️ *About profiles:*
> ℹ️ 
> ℹ️ - <span style="color: #000000">Administrators create profiles to connect to remote locations. A profile contains the basic information required to access a remote location and usually contains the base URLs of the location. In the macro editor, you must specify the relative URL in the </span><span style="color: #000000">*Location of XML data*</span><span style="color: #000000"> parameter. The macro combines these paths to create an absolute URL. If any part of this URL is incorrect or the URL itself is invalid, the macro generates an error. To get more information about profiles, select the relevant article specified in the </span><span style="color: #000000">[Helpful resources](#XSLTmacro-#html_57_helpfulResources)</span><span style="color: #000000"> section.</span>
> ℹ️ - <span style="color: #000000">If you get an error message, "Security restricted macro with parameter 'profile' is not allowed. An edit restriction is required that matches the macro authorization list.", it means that the </span><span style="color: #000000">*Macro Security*</span><span style="color: #000000"> macro has restricted the use of profiles in the macro. Ask your administrator to add the following entries in </span><span style="color: #000000">**Macro Security for Confluence Configuration **</span><span style="color: #000000">> </span><span style="color: #000000">**Secured macros**</span><span style="color: #000000">:</span>
> ℹ️   - <span style="color: #000000">Key: </span><span style="color: #000000">*xslt.profile.**</span>  
> ℹ️ <span style="color: #000000">Value: </span><span style="color: #000000">**ANY*</span>
> ℹ️   - <span style="color: #000000">Key: </span><span style="color: #000000">*xslt*</span>  
> ℹ️ <span style="color: #000000">Value: </span><span style="color: #000000">**ANY*</span>

## <span style="color: #000000">Usage</span>

<span style="color: #000000">Download a copy of the </span><span style="color: #000000">*cdcatalog.xsl*</span><span style="color: #000000"> from</span> [https://www.w3schools.com/xml/cdcatalog.xsl](https://www.w3schools.com/xml/cdcatalog.xsl) <span style="color: #000000">and attach it to your page.</span>

```
{xslt:style=^cdcatalog.xsl}
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
</cd>
<cd>
<title>Maggie May</title>
<artist>Rod Stewart</artist>
<country>UK</country>
</cd>
</catalog>
{xslt}

```


```
{xslt:source=^cdcatalog.xml|style=#http://www.w3schools.com/xsl/cdcatalog.xsl}
{xslt}

```


```
{xslt:source=xslt - basic^cdcatalog.xml|style=#http://www.w3schools.com/xsl/cdcatalog.xsl}
{xslt}

```

> Macro (anchor)



### <span style="color: #000000">Passing parameters to the XSLT engine</span>

<span style="color: #000000">Parameters not interpreted by the </span><span style="color: #000000">*XSLT*</span><span style="color: #000000"> macro are passed through to XSLT. You must use wiki syntax to take advantage of this.</span>

<span style="color: #000000">The following example is provided by Johan Nagels:</span>

```
{xslt:output=wiki|source=Home^snippets.xml|winnersOnly=lala}
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:param name="winnersOnly">no</xsl:param>
<xsl:output method="html"/>
<xsl:template match="/">
The value of winnersOnly is "<xsl:value-of select="$winnersOnly"/>"
</xsl:template>
</xsl:stylesheet>{xslt}

```

<span style="color: #000000">The output of the code is: </span><span style="color: #000000">*The value of winnersOnly is "lala"*</span>

<span style="color: #000000">If you omit the parameter tag, the output shown is: </span><span style="color: #000000">*The value of winnersOnly is "no"*</span>

## > Macro (anchor)

<span style="color: #000000">Helpful resources</span>

- <span style="color: #000000">[Profiles](https://appfire.atlassian.net/wiki/x/l4E1B#Configuration-html_57_config_profiles)</span><span style="color: #000000"> in the Configuration screen</span>
- <span style="color: #000000">[Key concepts](https://appfire.atlassian.net/wiki/x/voU1B)</span><span style="color: #000000"> to understand how to link and render XML content from other sources</span>

## <span style="color: #000000">Gallery</span>

![Gallery images](media://50b35c65-2f2a-4eac-a616-24e3719b3e33)