XSLT macro - Cloud

XSLT macro - Cloud

Features

  • Uses XSLT to transform XML to HTML.

  • Provides backward compatibility till XSLT 1.0 version.

  • Supports capabilities for including data similar to other scripting macros.

  • Supports find and replace for adjusting the resulting output.

  • Allows administrators to restrict the usage of JavaScript in the XSLT macro (based on Allow JavaScript in Configuration settings). The Confluence page throws a rendering error if this parameter is not enabled, and JavaScript is inserted while using the macro.

Parameters

HTML for Confluence XSLT macro editor with location and output fields
Use attachments in XSLT macro editor

 

HTML for Confluence XSLT macro output preview on a Confluence page
Use profile in XSLT macro editor

 

Macro editor label

Default

Description

Macro editor label

Default

Description

Data source

Data source

 

Specify the source of the XML content to be rendered. The options available are:

  • XML embed code: Enter XML code to display content. If this option is selected, a code block section appears where you can enter customized XML code to be displayed.

    • To add XSL code click “Click here to add/edit xsl source” and enter XSL code.

  • URL: If this option is selected, a URL parameter is displayed. Enter the URL of the required source from which the XML content is to be displayed on the page.

    • To add XSL URL click “Click here to add/edit xsl source” and enter the URL of the XSL content.

  • Profile: Select a profile to access the required source for XML content. Refer to this link to know more about profiles.

    • To add XSL profile click “Click here to add/edit xsl source” and enter the profile for the XSL content.

  • Attachment: Specify the attachment whose XML content is to be rendered. By default, Space and Page show the current space and page, respectively.

    • Space: Data is read from an attachment to the page name provided in the space indicated.

    • Page: Data is read from an attachment to the page name provided.

    • Attachment: Data is read from an attachment to the current page.

    • To add XSL attachment click “Click here to add/edit xsl source” and select the XSL attachment similar way.

Layout

Height of iframe (in px)

 

Enter the minimum height (in px or em) to be used for the rendered content.

If you do not specify, the height is auto-rendered according to the rendered content.
If you specify the height, the rendered content fits within the specified height. If the content exceeds the specified height, a scroll bar is displayed that lets you scroll through the content.

Example: 500px

Settings

Format

html

Specify how the output is treated. The options are as follows:

  • html - transformed output is standard HTML

  • xhtml - transformed output is treated as XHTML and rendered with the Confluence XHTML renderer

  • wiki - transformed output is treated as wiki markup and rendered with the Confluence wiki renderer

Find regex patterns

 

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. Example: (google\.dtd)

Replacement strings

 

Enter a comma-separated list corresponding to find patterns via index position in the list. Example: http://www.google.com/$1

Error Level

NONE

Specify the level at which the data processing fails. The options are:

  • NONE - No action is to be taken.

  • WARNING - Display a warning about the data process; processing does not stop.

  • ERROR - Display an error, and further processing is halted.

  • FATAL - Stops any further data processing.

Timeout in milliseconds

 

Enter time in milliseconds such that URL connections do not timeout before getting data. Use this to increase time needed for slow connections. Note that if a zero is given the connection may wait infinitely.

File encoding

system default

Specify the encoding for an external file, if different from the system default handling. Example: UTF-8.

Usage

Download a copy of the cdcatalog.xsl from https://www.w3schools.com/xml/cdcatalog.xsl and attach it to your page.

{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}

Passing parameters to the XSLT engine

Parameters that are not interpreted by the XSLT macro are passed through to XSLT. You must use wiki macro syntax to take advantage of this.

Consider the following example provided by Johan Nagels:

{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}

The output is: The value of winnersOnly is "lala".

If you omit the parameter, then the output is: The value of winnersOnly is "no".

Download a copy of the cdcatalog.xsl from https://www.w3schools.com/xml/cdcatalog.xsl and attach it to your page.

{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}

Passing parameters to the XSLT engine

Parameters that are not interpreted by the XSLT macro are passed through to XSLT. You must use wiki macro syntax to take advantage of this.

Consider the following example provided by Johan Nagels:

{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}

The output is: The value of winnersOnly is "lala".

If you omit the parameter, then the output is: The value of winnersOnly is "no".

Need support? Create a request with our support team.

Copyright © 2005 - 2026 Appfire | All rights reserved.