Subject: [xsl] Conditional output and separators From: "Tim Gaunt" <info@xxxxxxxxxxxxxxxxxxx> Date: Sat, 10 Nov 2007 19:01:05 -0000 |
Hi, I had hoped to introduce myself without a question but sadly the question got here first! I'm currently investigating Umbraco which is an open source ASP.Net CMS that uses XSLT heavily so I'm also having to brush up on it quickly! I've got stuck on the following scenario, I'm trying to list portfolio items on a homepage, the theory being that first 3 are banners, the second 3 are thumbnails. The html is as follows: <ul> <!-Banners x 3 inserted here --> </ul> <ul class="hlist"> <!-Thumbnails x 3 inserted here --> </ul> Now I've got it to list the 6 items but I'm not sure how to write in the: </ul> <ul class="hlist"> Without it throwing a wobbly. Could someone offer some insight please? Would it be nested templates or something? TIA Tim The XSLT I have so far: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:Stylesheet [ <!ENTITY nbsp " "> ]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:Schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" exclude-result-prefixes="msxml umbraco.library"> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:variable name="Banners"> <xsl:choose> <xsl:when test="/macro/Banners != ''"><xsl:value-of select="/macro/Banners" /></xsl:when> <xsl:otherwise>3</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="Thumbs"> <xsl:choose> <xsl:when test="/macro/Thumbs != ''"><xsl:value-of select="/macro/Thumbs" /></xsl:when> <xsl:otherwise>3</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:param name="currentPage"/> <xsl:template match="/"> <ul class="portList"> <xsl:for-each select="$currentPage/ancestor-or-self::node[@level=1]/descendant::node [@nodeTypeAlias = 'PortfolioItemPage' and string(data [@alias='umbracoNaviHide']) != '1']"> <xsl:sort select="@sortOrder" data-type="number" order="ascending" /> <xsl:choose> <xsl:when test="position() <= number($Banners) and ./data [@alias='ProjectImage'] != ''"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:attribute name="title"><xsl:value-of select="data [@alias = 'MenuText']" /></xsl:attribute> <img src="{data [@alias='ProjectBanner']}" width="520" height="120" alt="{data [@alias = 'MenuText']}" /><br /> <h3><xsl:value-of select="data [@alias = 'MenuText']"/></h3> <p><xsl:value-of select="data [@alias = 'Intro']" disable-output-escaping="yes"/></p> </a> </li> </xsl:when> <xsl:when test="position() > number($Banners) and position() <= number($Banners + $Thumbs) and ./data [@alias='ProjectImage'] != ''"> <li> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:attribute name="title"><xsl:value-of select="data [@alias = 'MenuText']" /></xsl:attribute> <img src="{data [@alias='ProjectImage']}" width="88" height="88" alt="{data [@alias = 'MenuText']}" /> </a> </li> </xsl:when> </xsl:choose> </xsl:for-each> </ul> </xsl:template> </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] problem for extracting in, David Carlisle | Thread | [xsl] [Fwd: fo:inline within fo:bas, Khaled Aly |
[xsl] problem for extracting inform, Miren Urkixo | Date | [xsl] [Fwd: fo:inline within fo:bas, Khaled Aly |
Month |