Re: AW: [xsl] simple conditional looping

Subject: Re: AW: [xsl] simple conditional looping
From: "Keyur K" <kkeyur@xxxxxxxxxxx>
Date: Mon, 16 Aug 2004 13:03:52 +0000
Hello David,

Thanks for replying. See my xml and xsl code below to get more idea and why I need conditional looping.

my xml code is as follows:
<orders>
<order id="1">ABC</order>
<order id="2">XYZ</order>
<order id="3">QWE</order>
</orders>

The orders tag will grow as and when new orders are added. Now in my stylesheet (PRINTER FRIENDLY) I need to display the orders as below.

ORDERS:
1. ABC
2. XYZ
3. QWE
4. ________
5. ________
6. ________
.
.
.
.
50. _______

In my printer friendly stylesheet I need to display minimum 50 lines. If there are less then 50 orders then all the remaining lines will be blank with an underline. The transformed page (this xml and xsl will be transformed using ASP.NET) will be printed and the blank lines will be filled manually with a pen and Signed.

So I think conditional looping will be required.

I used recursive templates to do this as suggested by fellow list members.

Regards,
Keyur



From: David Carlisle <davidc@xxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: AW: [xsl] simple conditional looping
Date: Mon, 16 Aug 2004 12:19:24 +0100

>
> maybe a silly question, but why exactly do you need the ()? something
> like //* with a predicate [] should be enough or not?

A predicate in an axis step just filters that step.

//*[position() &lt; 50]

is /descendent-or-self::node/child::*[position() &lt; 50]

so it gives you all element nodes in the document that have fewer than
49 older siblings.

On the other hand

(//*)[position() &lt; 50]


is (/descendent-or-self::node/child::*)[position() &lt; 50]


which gives you the first 49 element nodes in the document.

David





________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread