Subject: Re: Managing Groups of Elements?
From: Edd Dumbill <edd@xxxxxxxxxxxxx>
Date: Sat, 3 Jul 1999 10:46:05 +0000
|
On Fri, Jul 02, 1999 at 10:31:44AM +0100, Nigel Byrnes wrote:
> Considering the following DTD:
>
> <!ELEMENT news (title, newsItem*)>
> <!ELEMENT title (#PCDATA)>
>
> <!ELEMENT newsItem (headline, strapline, link)>
> <!ELEMENT headline (#PCDATA)>
> <!ELEMENT strapline (#PCDATA)>
> <!ELEMENT link (#PCDATA)>
> The problem is that the number of newsItems may be too large to fit on
> one screen. Indeed I have a requirement to fit no more than four
> newsItems on one page. In cases where there are more than four, a link
> should be present at the bottom of the page to navigate to the next
> page.
I suggest using something like these fragments to match your newsItems.
The first case is the normal case, the second case deals with adding
the link in when there's more than 4 elements, and the third case
simply ensures that the surplus elements aren't displayed.
<xsl:template match="news/newsItem[position() < 5]">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="news/newsItem[position()=5]">
<a href="more.html">Click here for more</a>
</xsl:template>
<xsl:template match="news/newsItem[position() > 5]">
</xsl:template>
You can make a similar stylesheet for the second page following
this pattern. The mental jump I find one needs to make is away
from trying to count out your elements and concentrate on
matching them instead. I've tested this with XT, by the way.
regards
--
Edd Dumbill | Director, Useful Information Co. & Pharmalicensing Ltd
tel: +44 (0) 702-093-6870 | edd@xxxxxxxxxxxxx | http://usefulinc.com
fax: +44 (0) 870-164-0230 | pgp: http://usefulinc.com/edd/pubkey.asc
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|