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

Splitting data into smaller groups for HTML output.

Subject: Splitting data into smaller groups for HTML output.
From: Mike Rumble <mike.rumble@xxxxxxxxx>
Date: Mon, 31 Oct 2005 18:34:19 +0000
html output data
Hello,

I'm fairly new to XSL and despite picking things up quickly I've hit a
problem with a template I'm trying to create.

I have an XML file which is structured like this:

<sources>
    <source>
        <title>Title 1</title>
        <url>http://url1.com/</url>
    </source>
    <source>
        <title>Title 2</title>
        <url>http://url2.com/</url>
    </source>
    <source>
        <title>Title 3</title>
        <url>http://url3.com/</url>
    </source>
    <source>
        <title>Title 4</title>
        <url>http://url3.com/</url>
    </source>
</sources>

...and so on. The XML file is dynamically generated by PHP and there
are usually around 10 - 25 <source> nodes and only ever one <sources>
node.

What I've been trying to do is use a template to output these
<sources> in to an HTML file, but and here's the rub - splitting the
<sources> into two or more groups within the HTML. It'd be easier to
show an example...

<div>
  <a href="http://url1.com/">Title 1</a><br />
  <a href="http://url2.com/">Title 2</a><br />
</div>
<div>
  <a href="http://url3.com/">Title 3</a><br />
  <a href="http://url4.com/">Title 4</a><br />
</div>

The best I can achieve, using <xsl:for-each> is:

<div>
  <a href="http://url1.com/">Title 1</a><br />
  <a href="http://url2.com/">Title 2</a><br />
  <a href="http://url3.com/">Title 3</a><br />
  <a href="http://url4.com/">Title 4</a><br />
</div>


Doing something like this is pretty straightforward using PHP, with
counter variables and what-not. I realise that XSL works differently
in this respect and was hoping that someone might have some advice for
me on how I can achieve the desired results.

Thanks in advance!

Mike.

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.