Inspect Component Details with an XSLT Component Template

As a follow-up to an XSLT Component Template (CT) that displays publication info, here's a multipurpose XSLT CT.

I use it to preview a component's XML source or as a starter for a new template. If you have the XSLT Mediator, this could be a starting point for making your own set of XSLT TBBs.

Step 1 Create a new Component Template of type XSLT.
  • Call it something like: "Component Info (use on any component)"
  • Output format: XML Document or HTML Document (we're just previewing so either work)
  • Priority: any, but I chose "Never Link"
  • Component Presentations based on this Component Template will be:
    Published on a Page
  • If on a production system, also place in a folder that authors don't have permissions to

Step 2

Remove any text in the source tab and then Copy and Paste the following, making sure "XSLT" is selected as the template type:

<xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:generic="" xmlns:tcm="" xmlns:xlink="" exclude-result-prefixes="xsl tcm xlink generic">
 <xsl:output omit-xml-declaration="no" indent="yes" method="xml" cdata-section-elements="description" />
 <xsl:variable name="Content" select="/tcm:Component/tcm:Data/tcm:Content" />

 <xsl:template match="/">
  <h1>Source Below</h1>
  <h2>Component ID: <xsl:value-of select="tcm:Component/@ID" /></h2>
  <xsl:copy-of select="." />
  <xsl:apply-templates select="$Content/*" />

 <xsl:template match="*">
  <xsl:copy-of select="." />


Step 3 Preview

Right-click on the template in a publication that has components and preview any component to see its information information. Optionally set a specific schema as a linked schema (Linked Schema tab in the XSLT CT) to allow the preview to start from the components based on that schema. The XML outputted may look like a rendered component presentation, but this shouldn't work with SiteEdit out-of-the-box.

See the earlier XSLT CT post for caveats on a production system.

When working with SDL Tridion, you typically have several ways to accomplish the same task. Developers can easily think in code and may want to develop an extension to get this data. See the Item XML Display eXtension for how to start with that interests you.

The occasional Tridion developer or analyst may not have the ability to install extensions to the CME. Or it might easier to install the pre-built option or get functionality from a set of tools (see PowerTools).

Finally, don't forget the pure out-of-box functionality. Open a component and view its source! The difference with creating a template is that you can get the "wrapping" XML that the CME doesn't display. You can also pick-and-choose what you want. Just "viewing the source" isn't an easy task for everyone.

Do you have the equivalent, but in one of the other 6 places to add or retrieve markup? Anyone have an example in a Template Building Block?

No comments:

Post a Comment

Feel free to share your thoughts below.

Some HTML allowed including links such as: <a href="link">link text</a>.