Question

I am working on a XSLT Template Building Blocks in SDL Tridion 2011 SP1 using the XSLT mediator.

I just wanted to know, how to get the Name of component, Version and its TCMID while rendering.

Can any one help how it can be done?

Was it helpful?

Solution

After clearly observing the output in the Template Builder, I got answer as

<xsl:element name="TCMID">
  <xsl:value-of select="tcm:Component/@ID"/>
</xsl:element>
<xsl:element name="name">
  <xsl:value-of select="tcm:Component/tcm:Data/tcm:Title"/>
</xsl:element>
<xsl:element name="Version">
  <xsl:value-of select="tcm:Component/tcm:Info/tcm:VersionInfo/tcm:Version"/>
</xsl:element>

OTHER TIPS

Probably not a complete answer to your question, but Package Items should be available as arguments to the template. So if you need to access a value that is not in the Component XML you could add it to the Package before you run the XSLT TBB.

Accessing non field values for a Component troubles lots of developers. This is not altogether surprising as there is no obvious way to view the complete XML of a Component from the UI. The source tab in the CME (The SDL Tridion CM User Interface) only shows the XML of the content node in the XML, and does not show the complete XML.

In order to see the complete XML (without loading it through the API), you have a number of options. Starting with the easiest these include:

  1. Use XSLT to write out the root node of the Component using something like <xsl:copy-of select="."/>. This will write the entire Component XML to the template output, which you can then save for reference when writing your XSLT.
  2. Access the Component XML using the protocol handler on the CMS server, by typing the URI into Internet Explorer, and it should display the complete XML.
  3. Install the SDL Tridion PowerTools which install a tab on the item views which displays the XML.

Once you can access the XML, it becomes very intuitive to find any property of any Tridion object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top