Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Modified contents as per style guide, changed to new editor and fixed links

This article provides an overview on how to render wiki markup through an XSLT macro. It is recommended to embed another macro that gives a wiki markup output inside the XSLT macro to get the optimal result.

Table of Contents
minLevel2
maxLevel6
outlinefalse
styledefault
typelist
printabletrue

Before you begin

  • Ensure that the URLs for the XML and XSL files are in the raw format.

     A

     A raw URL is defined as the part of the URL following the domain information and includes the query string, if present.

     For

     For example, in the URL string http://www.contoso.com/articles/recent.aspx, the raw URL is /articles/recent.aspx.

  • The XML and XSL files must be in the correct format and valid files. 

    Tip
    titleHow to identify if XML/XSL files are valid for the macro?

    Paste the file link into your browser's address bar. If the actual XML or XSL code is displayed in the browser, it is considered to be invalid or in an incorrect format. If the file downloads to your system, the macro can process the file and its contents.

Steps

For this example, let's assume that:

  • The XML file to be rendered is available on the Home page in the same space.

  • The XSL code is entered directly in the macro body.

  • A profile is not specified and direct URLs are mentioned in the Location of XML data parameter.

Note

These assumptions are made for this example. The basic premise of the example is that the that the XML file to be rendered must be attached to a page in the same space. You  You can replace the given XML and XSL files as required from your instance. However However, you can also specify a profile and provide the relative paths to the XML and XSL files in the macro as well. For more information, visit the links in the Helpful resources section.

Define these parameters/values

Transformed output format

wiki

Location of XML code

Home^animals.xml

Location of XSL code

blank

Contents of XSL file

The following code is given in the macro body:

Code Block
languagexml
<!-- <?xml version="1.0" encoding="UTF-8"?> this causes problems when loading without editor --> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> 
<xsl:template match="/"> h2. Animals 
{csv:output=wiki} Name, Type, Breed, Color 
<xsl:for-each select="animals/animal"> 
<xsl:value-of select="name"/>, <xsl:value-of select="type"/>, <xsl:value-of select="breed"/>, 
<xsl:value-of select="color"/>, "[www.google.com]" 
</xsl:for-each> 
{csv} 
</xsl:template> 
</xsl:stylesheet>
Info

In the given XSL code:

  • There is a CSV macro embedded with a wiki output format.

  • The CSV macro ensures that the XSL code reads data from the specified XML file and transforms it into wiki markup.

  • This markup is then displayed using the XSLT macro on the page.

  • The h2. Animals code is wiki markup that is outside the CSV macro contents. Thus, though you can directly provide wiki markup in the XSL code itself, it is recommended to use embedded macros with wiki output format to get the desired output.

Contents of XML file

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<animals>
    <animal>
        <type>dog</type>
        <name>King</name>
        <breed>Border Collie</breed>
        <color>black and white</color>
    </animal>
    <animal>
        <type>cat</type>
        <name>Irene</name>
        <breed>Long hair mix</breed>
        <color>mixed</color>
    </animal>
</animals>

Parameters set in the macro editor

...

Result

...

Anchor
html_57_tutl_wikiXslt_addlInfo
html_57_tutl_wikiXslt_addlInfo
Helpful resources