Skip to content

Instantly share code, notes, and snippets.

@robvanoostenrijk
Last active August 29, 2015 14:07
Show Gist options
  • Save robvanoostenrijk/865af986dcf57c24116a to your computer and use it in GitHub Desktop.
Save robvanoostenrijk/865af986dcf57c24116a to your computer and use it in GitHub Desktop.
Tridion 2013 - XSLT Mediator

XSLT Mediator Usage

Transformation Configuration

Xslt mediator allows specifying special parameters which are used for the transformation process:

<?XsltMediator inputitemname="*package name*" outputitemname="*package name*" extensionsTbbId="*tcm:223-123123-2048*"?>

The output methods defined are:

  • XHTML
  • XML
  • HTML
  • Text

For Example:

    <xsl:stylesheet>
         <xsl:output method="xhtml" /> (or xml, html, text)
    </xsl:stylesheet>
Transformation Parameters

Available (auto-populated) parameters for use in transformation:

  • TEMPLATE_URI
  • tcm:Page
  • tcm:ComponentTemplate
  • tcm:Publication
  • tcm:ResolvedItem
  • tcm:ResolvedTemplate
  • tcm:XsltTemplate

For Example:

    <xsl:param name="TEMPLATE_URI" />
    <xsl:param name="tcm:Page" />
    <xsl:param name="tcm:ComponentTemplate" />
    <xsl:param name="tcm:Publication" />
    <xsl:param name="tcm:ResolvedItem" />
    <xsl:param name="tcm:ResolvedTemplate" />
    <xsl:param name="tcm:XsltTemplate" />

Additionally its possible to read package variables:

    <xsl:param name="*Package Name*" />

(Supports plain, html, xml package items) or

    <xsl:param name="${Indirect Name}" />

This allows specifying a package variable which in turn specifies the variable name to look up the actual value from.

Extensions
  • Default XsltTemplateHelper

  • String GetFormattedDate(string inputDate, string dateFormat)

  • XmlDocument GetListItems(String orgItemId)

  • XmlDocument GetMultimediaInfo(String id)

  • Adding IFunctionSource from Package.FunctionSources Configured through Tridion.ContentManager.config as per SDL Portal: Custom Functions

  • Add IFunctionSource exported through ExtensionTbbId (Defined as xslt processing instruction)

Namespace can be configured by implementing the Tridion.ContentManager.Templating.Xslt.XsltExtensionAttribute on the extension class.

    [XsltExtensionAttribute(Namespace = "http://www.company.com/tridion/xslt/functionsource")]
    public class Xslt : IFunctionSource
    {
    ....

Note that when no namespace is specified, the default namespace is: http://www.sdltridion.com/ContentManager/FunctionSource/ + typename

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment