I have created a XSLT TBB, which I am using on a page template, and i`m looping over the component presentations, but in the documentation I cant see a function to render the individual component presentations.

In the DWT templates I noticed there is a function called RenderComponentPresentation() but can`t see the equivelent in XSLT documentation http://docs.sdl.com/LiveContent/content/en-US/SDL%20Tridion%20full%20documentation-v1/GUID-69A67594-A1E7-45AA-9401-84E24FBED74B

<!-- TemplateBeginRepeat name="Components" -->
  <!-- TemplateBeginIf cond="ComponentTemplate.Title='Article'" -->
  <!-- TemplateEndIf -->
<!-- TemplateEndRepeat -->

Even though Bjorn's answer seems hypothetical, it is almost completely correct. :-)

In general, so-called templating function sources (.NET classes which are exposing their methods to modular templates) are exposed in the XSLT mediator as extension functions in XML namespaces named as:


This applies to built-in functions, other configured function sources and function sources which are implemented in a .NET TBB referenced by the XsltMediator Processing Instruction.

RenderComponentPresentation is a built-in function which is in the "BuiltInFunctions" function source, so the XML namespace is:

  • That is a very useful piece of knowledge indeed! Thanks! – Bjørn van Dommelen Dec 3 '14 at 13:03
  • Are these documented anywhere? This is working well now BTW, except that I can`t get rid of the <tcdl:ComponentPresentation tags , i have tried adding the following "exclude-result-prefixes="xlink tcm msxsl script Builtin tcdl" but with no luck – Snow Queen Dec 3 '14 at 14:36

You will need to invoke the (globally available) function RenderComponentPresentation as explained here.

The builtin functions are found in Tridion.ContentManager.Templating.Expression.BuiltInFunctions but I have no idea if SDL attributed them with an XSLT namespace...

Assuming they did and that namespace was "http://www.sdltridion.com/ContentManager/BuiltinFunctions" you would declare an XML namespace on your stylesheet like

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 

and call the RenderComponentPresentation builtin function via

<xsl:value-of select="Builtin:RenderComponentPresentation($componentId,$templateId)" />

If they did not you will have to create your own assembly, put it in a TBB; load the TBB into the XSLT via

<?XsltMediator extensionsTbbId="tcm:193-34-2048"?>

at the top of your XSLT TBB.

Your assembly would just be passthrough functions for the builtin functions but the class would have the XSLT namespace attribute wired up as below:

public class BuiltinFunctionsXsltExposer : IFunctionSource

Give your functions the same name as the builtin functions and it should work.

Update: Thanks to Rick who has confirmed that builtin functions are available in XSLT if you use the right namespace declaration the following code should be correct:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:Builtin="http://www.sdltridion.com/ContentManager/FunctionSource/BuiltInFunctions">
  <xsl:template match="/">
     <xsl:value-of select="Builtin:RenderComponentPresentation('tcm:5-267','tcm:5-261-32')" disable-output-escaping="yes" />

You will need to pass in valid TCMIDs of the component and template of course!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.