Managing Groups of Elements?

Subject: Managing Groups of Elements?
From: Nigel Byrnes <byrnes@xxxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 02 Jul 1999 10:31:44 +0100
Hi all XSL-ers

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)>

For an example of what the XML document might look, check out Listing
One at the foot of the mail.

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.

My current progress on this problem is shown in Listing Two. I have
managed to create a template which creates a HTML page but without any
management of the newsItem elements.

Any help on this problem will be appreciated. Thanks in advance,

Nigel

============== Listing One: ======================
<?XML version="1.0" encoding="UTF-8"?>
<news>
 <title>Todays Top Stories</title>
 <newsItem>
  <headline>House Prices Still On The Rise</headline>
  <newsItem>The latest property market survey released by the Halifax
found the increase in house prices continued through June, with the
average up 1.8% to £76,877.</newsItem>

<link>http://www.yahoo.co.uk/headlines/19990702/news/930904700-4-1.html</link>

 </newsItem>

 <newsItem>
   ...
 </newsItem>
</news>

============= Listing Two: =========================

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0";>

<xsl:template match="NEWS">
 <html>
 <head>
  <title>Nigel's Yahoo News Content Negotiation Demonstration</title>
 </head>
 <body>
  <h1><xsl:value-of select=".//TITLE"/></h1>
   <xsl:for-each select=".//NEWSITEM">
  <h2><xsl:value-of select=".//HEADLINE"/></h2>
   <p>
   <xsl:value-of select=".//STRAPLINE"/>
   <br/>
   <xsl:element name="a">
   <xsl:attribute name="href">
    <xsl:value-of select=".//LINK"/></xsl:attribute>
More...</xsl:element>
   </p>
  </xsl:for-each>
 </body>
 </html>
</xsl:template>

</xsl:stylesheet>


begin:          vcard
fn:             Nigel Byrnes
n:              Byrnes;Nigel
org:            Philips Research
email;internet: byrnes@xxxxxxxxxxxxxxxxxxxxxxxx
title:          Research Scientist
note:           <BR>Software Engineering and Appications Group<BR>Philips Research Labs<BR> Cross Oak Lane<BR>Redhill<BR>Surrey<BR>RH1 5LA<BR>UK<P>Phone: +44 (0) 1293 815 578<BR>Fax: +44 (0) 1293 815 500<BR>GSM: 07899 940 391
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
version:        2.1
end:            vcard

Current Thread