[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] How to display XML data partially


Subject: Re: [xsl] How to display XML data partially
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 21 Mar 2001 17:56:06 +0000

Hi Davut,

> I want to display those devices in an HTML page BUT 10 DEVICES AT A
> TIME.

The first issue is how you are generating the HTML pages.  There are
two ways that you could do it:

  * create the pages dynamically - pass the stylesheet the index of
    the first device to occur on the page, and get it to create the
    HTML page for the 10 devices starting from that one
    
  * create the pages statically - create all the pages in one big
    transform, with each page holding 10 devices

I don't know which method you're using (dynamic transformation on
request or static/batch transformation).  But whichever you use,
you'll probably want to apply templates to only the first device to
appear on a particular page, and then have a template that does
something with that device and the next 9.

Given a device element as the current node, you can get the 10 devices
starting from that one with:

  . | following-sibling::device[position() &lt; 10]

In other words, make a node set that consists of this node (.) and the
following sibling device elements whose position (within the list of
following sibling device elements) is less than 10.

So the template for a device should probably look something like:

<!-- only applied to the first device in a page -->
<xsl:template match="device">
   <xsl:for-each select=". | following-sibling::device
                                [position() &lt; 10]">
      <!-- whatever output you want for the devices -->
   </xsl:for-each>
</xsl:template>

Then it comes down to how you choose the device to apply templates to,
which depends on how you're generating the page.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



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



Current Thread