Skip to end of banner
Go to start of banner

XSLT macro - Cloud

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 16 Next »

On this page

Removal notice

Please note that the URL user and URL user password parameters were removed (see Deprecation notice: URL user and URL user password parameters). We recommend using profiles to access external data.

Features

  • Uses XSLT to transform XML to HTML, XHTML, or wiki markup.
  • Provides backward compatibility till XSLT 1.0 version.
  • Supports capabilities for including data similar to other scripting macros.
  • Supports find and replace for adjusting 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.

With this release, nested macros within the XSLT macro are supported. To make this work, select the Transformed output format macro parameter as Xhtml.

Known issue:

When a user edits the macro body in the macro editor, the preview is not shown. Publish the page to view the output.

Parameters

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".

  • No labels