Showing posts with label XSL. Show all posts
Showing posts with label XSL. Show all posts

Friday, December 12, 2008

DwTemplateTags in XSLT templates

Well, to find out which template tags are availiable when working with XSLT templates in Dynamicweb CMS you need to insert this:

<xsl:text disable-output-escaping="yes"><![CDATA[<!--@DwTemplateTags-->]]></xsl:text>

Monday, July 7, 2008

Simulating SQL "DISTINCT" in XSLT

If you have a list of elements from which you only want one occurance of each unique value, in SQL you would just add "DISTINCT" infront of the column. You can do something in XSLT which gives you the same functionality. Take a look at this example:
//Product[Hight][not(Hight=preceding-sibling::Product/Hight)]
This example will do just that with Product elements with a subnode called Hight. So only one occurance of each Hight!

Monday, March 17, 2008

Save the XML navigation data

When working with XSLT based menues in Dynamicweb you will need to see the actual XML document which your XSLT works with - you can extend the URL with: "SaveXml=True" and a XML document will be saved in "Templates\Navigation". A dynamic name will be applied - for example: "TestNavigationData137.xml".

You may read about this here: http://www.dynamicweb.dk/Developer-forum-25346.aspx?action=ShowThread&ThreadID=163

Wednesday, November 14, 2007

Return the XML input document

This XSLT document will return a copy of the input, usefull if you do not know the structure of the XML which you need to transform:


<?xml version="1.0" encoding="UTF-8"?>
<?xml:namespace prefix = xsl /><xsl:stylesheet fo="http://www.w3.org/1999/XSL/Format" xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output declaration="yes" encoding="utf-8" indent="yes" method="html">
<xsl:template match="/">
<xsl:apply-templates select="*@*node()comment()processing-instruction()">
</xsl:template>
<xsl:template match="*@*node()comment()processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="*@*node()comment()processing-instruction()">
</xsl:copy>
</xsl:template>
</xsl:stylesheet></p>
</xsl:apply-templates></xsl:apply-templates></xsl:output>

Friday, July 6, 2007

XSL: A "showAll" template - unpacking XML node

This XSL template "showAll" will show the contents of a node.

Call it this way:
<xsl:call-template name="showAll">
<xsl:with-param name="showText" select="1" />
</xsl:call-template>

Where the param "showText" decides if you wish to see the text contents from
the nodes.

Here is the template:


<xsl:template name="showAll">
<xsl:param name="showText" />
<div style="padding-left: 10px; border-left: dotted 1px #e0e0e0;">
<xsl:for-each select="*">
<div style="padding-left: 10px;">
&lt;<xsl:value-of select="name(.)"/>
<xsl:for-each select="@*">
&#160;<xsl:value-of select="name(.)"/>="<xsl:value-of select="."/>"
</xsl:for-each>&gt;
<xsl:if test="$showText=1">
<xsl:value-of select="text()"/>
</xsl:if>
<xsl:if test ="count(*)>0">
<br />
<xsl:call-template name="showAll">
<xsl:with-param name="showText" select="$showText" />
</xsl:call-template>
</xsl:if>
<xsl:if test ="string-length(.)=0
and $showText!=1">
/&gt;<br />
</xsl:if>
<xsl:if test ="string-length(.)>0">
&lt;/<xsl:value-of select="name(.)" />&gt;<br />
</xsl:if>
</div>
</xsl:for-each>
</div>
</xsl:template>