[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Unique headers

Subject: Re: Unique headers
From: tcn@xxxxxxxxxxxxx (Trevor Nash)
Date: Thu, 05 Apr 2001 14:23:11 GMT
Re:  Unique headers
Kanthi,

The following produces the output you specify, using Saxon 6.2.2.  It
differs from your XSL only in that
  - the grpTypes string must start with a space, or the 'Mystery'
titles appear without a heading.
  - I have added a space before the first
    <xsl:value-of select="../Title"/> to get the required indent.

You seem to have either
  * a bug in your XSLT processor which gets the test involving
'preceeding' wrong
  * what you posted is not what you are running
  * there is another template matching "Type" elsewhere in your
stylesheet which is preventing this one being triggered.

Perhaps you are over-simplifying your problem?  I am guessing that you
may in fact want to do grouping/sorting on XML which is not in the
required order, i.e. the 'Horror' titles do not in fact appear
consecutively.

Stylesheet:

<xsl:variable name="grpTypes" select="' Mystery Horror'"/>
<xsl:template match="text()"/>
 <xsl:template match="Type">
   <xsl:choose>
     <xsl:when test="contains($grpTypes, concat(' ', .))">
       <xsl:if test="not(. = preceding::Type)">
         <xsl:value-of select="concat(., '&#xA;')"/>
       </xsl:if>
       <xsl:text> </xsl:text><xsl:value-of select="../Title"/>
     </xsl:when>
     <xsl:otherwise>
       <xsl:value-of select="../Title"/>
     </xsl:otherwise>
   </xsl:choose>
  <xsl:text>&#xA;</xsl:text>
 </xsl:template>

Output:
Chocolat
Billy
Mystery
 Ellen Brokovich
 Pelican Brief
Horror
 Nightmare on Elm Street
 Blair Witch Project
The Emperor's Groove
Toy Story

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.