Search code examples
xmlxsltektron

Why isn't the XSL displaying any data


I have the following XSL file:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template name="displayEventDetails" match="/">
        <div class="serviceHolder brClear">
            <xsl:for-each select="/root/Event">
                <h2 class="defaultHdrColor">
                    <xsl:value-of select="title" />
                </h2>
                <div class="hrHolder">
                    <hr class="hrDivider" />
                </div>
            </xsl:for-each>
        </div>
    </xsl:template>
</xsl:stylesheet>

XML:

<root>
    <Event>
        <title>Prepared Childbirth Classes </title>
        <speaker>Certified Instructor</speaker>
    </Event>
</root>

All it display is in the HTML source is:

<div class="serviceHolder brClear"></div>

I am calling from my ASP.net page:

<CMS:Collection ID="Collection2" runat="server" DynamicParameter="id" DisplayXslt="Workarea\CustomFiles\displayEventDetails.xsl" />

How do I resolve it?


Solution

  • <CMS:Collection ID="Collection2" runat="server" DynamicParameter="id" DisplayXslt="Workarea\CustomFiles\displayEventDetails.xsl" />
    

    changed to

    <CMS:ContentBlock ID="Collection2" runat="server" DynamicParameter="id" DisplayXslt="Workarea\CustomFiles\displayEventDetails.xsl" />
    

    Worked.

    Reason: I was not trying to read a collection (which holds two or more content blocks) but trying to read each content block separately, one at a time, which is why the XML format was different and showing up blank.