Skip to end of banner
Go to start of banner

How to render wiki from XML or XSL files

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 3 Next »

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.

Before you begin

  • Ensure that the URLs for the XML and XSL files are in the raw format. 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 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. 

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

For this example, let's consider that the XML and XSL files are attached to a page in the same space. Here, a profile is not specified and direct URLs are specified in the Location parameters. However, you can specify a profile and provide the relative paths to the XML and XSL files as well. For more information, visit the links in the Helpful resources section.

Define these parameters/values

Transformed output format

wiki
Location of XML codeHome^animals.xml
Location of XSL code
<!-- <?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>

Parameters set in the macro editor

Macro added to the page

Result

Helpful resources

  • No labels