I am working on XSLT TBB in SDL Tridion 2011 SP1. I am using XSLT mediator downloaded from Tridion site.
I have created a TBB to retrieve the image as follows:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:simple="uuid:c5e80ef4-9afd-421a-9205-d5af4c9f2c5c"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcm="http://www.tridion.com/ContentManager/5.0"
xmlns:tcmse=”http://www.tridion.com/ContentManager/5.1/TcmScriptAssistant”
exclude-result-prefixes="msxsl simple">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:template match="/">
<xsl:element name="p">
<xsl:apply-templates select="tcm:Component/tcm:Data/tcm:Content/simple:Content"/>
</xsl:element>
</xsl:template>
<xsl:template match="simple:Content">
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="tcmse:PublishBinary(string(simple:photo/@xlink:href)))"/>
</xsl:attribute>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
I am getting error as
[CDATA[Unable to retrieve rendered data from Component Presentation.]]>
</tcm:Line>
<tcm:Line ErrorCode="80040000" Cause="true">
<![CDATA[
Cannot find a script or an extension object associated with namespace
'http://www.tridion.com/ContentManager/5.1/TcmScriptAssistant'.]]
I understood that problem is due to 'http://www.tridion.com/ContentManager/5.1/TcmScriptAssistant'.
Can any one suggest the modifications needed to overcome it?
DO I need to change any thing in TBB or Component Template.
Thank you.
The XSLT Mediator allows you to add new methods to the XSLT Extension object, you can find it in the 'XSLT Template Helper' class available in the XSLT Mediator package.
In order to use it you will need to add the "http://www.sdltridion.com/ps/XSLTHelper" namespace in your XSLT template like xmlns:ext="http://www.sdltridion.com/ps/XSLTHelper".
A sample of how a PublishBinary method would is shown below.
public string PublishBinary(string tcmUri)
{
Component mComponent = new Component(new TcmUri(tcmUri), session);
Binary binary = engine.PublishingContext.RenderedItem.AddBinary(mComponent);
return binary.Url;
}
public string PublishBinary(string tcmUri, string sgTcmUri)
{
Component mComponent = new Component(new TcmUri(tcmUri), session);
StructureGroup sg = new StructureGroup(new TcmUri(sgTcmUri), session);
Binary binary = engine.PublishingContext.RenderedItem.AddBinary(mComponent,sg);
return binary.Url;
}
you can use those methods like this.
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="ext:PublishBinary(string(@xlink:href))" />
</xsl:attribute>
</xsl:element>