Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > XSLT Transformations, proper usage View modes: 
User avatar
Member
Member
christian.nickel-nist - 10/21/2013 2:39:44 PM
   
XSLT Transformations, proper usage
Hello,

I am trying to display some simple content from an XML file using an XSL transform.

To start off, here is a sample of my XML (changed to protect content):

<?xml version="1.0" encoding="UTF-8"?>
<faq created="2013-09-20">
<section id="generalquestions" title="General Questions">
<entry id="aandb">
<question>What is the difference between A and B?</question>
<answer>Answer is the difference between A and B</answer>
</entry>
<entry id="aandbscores">
<question>How do we score A and B?</question>
<answer>Answer we score A and B</answer>
</entry>
</section>
<section id="descscoresotherthings" title="Questions about Descriptions, Scores, and Other Things">
<entry id="identified">
<question>What happens after A and B are identified?</question>
<answer>Something happens</answer>
</entry>
</section>
</faq>


Here is my XSLT:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="faq">
<span>
<h2>Questions</h2>
<p>
<xsl:for-each select="section">
<strong><a><xsl:attribute name="href">#<xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="@title"/></a></strong><br/>
<xsl:for-each select="entry">
<xsl:sort select="question"/>
<a><xsl:attribute name="href">#<xsl:value-of select="@id" /></xsl:attribute><xsl:value-of select="question"/></a><br/>
</xsl:for-each>
</xsl:for-each>
</p>
<hr/>
<h2>Answers</h2>
<xsl:for-each select="section">
<p>
<strong><xsl:value-of select="@title"/></strong>
<br/>
<xsl:for-each select="entry">
<xsl:sort select="question"/>
<a><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute></a>
<xsl:value-of select="answer"/>
<br />
</xsl:for-each>
</p>
</xsl:for-each>
</span>
</xsl:template>
</xsl:stylesheet>


In the design view of my page, I added an XML data source (named FaqXmlDataSource) whose XML URL points to the absolute URL of the FAQ file: http://exampledomain.com/faqtest.xml

Next I added a Basic repeater whose data source name is "FaqXmlDataSource", and uses a transform I created, Transformation type: XSLT. I pasted in the XSLT you see above.

Essentially Kentico is simply placing the XSLT onto the page, unchanged, almost like placing an Editable Text and placing the XSLT into the source.

I've also tried adding a "Table name" such as faq, section, or entry, this didn't change anything.

Again I have come across an issue for which I'm unable to find a solution searching the forum and googling (maybe I'm using the wrong search terms?). Maybe someone asked for this before and someone could help me find the solution?

Thanks,
Christian

User avatar
Member
Member
kentico_sandroj - 11/2/2013 7:20:24 PM
   
RE:XSLT Transformations, proper usage
Hello,

According to the documentation, XSLT transformation are not supported in Repeaters. You would have to use the XSLT viewer, Universal document viewer or a custom Web part in order to display the data. I apologize for the inconvenience. Please let me know if you have any questions.

Best Regards,
Sandro