473,320 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

XSL for-each loop but..

Hello all,

i have a xsl:for-each loop like this:

<xsl:for-each select="xc:agendapunt[xc:datum/xc:year &gt; $time_year or (xc:datum/xc:year=$time_year and xc:datum/xc:month &gt; $time_month) or (xc:datum/xc:year=$time_year and xc:datum/xc:month=$time_month and xc:datum/xc:day &gt; $time_day)]">
<xsl:sort select="xc:datum/xc:year" data-type="number"/>
<xsl:sort select="xc:datum/xc:month" data-type="number"/>
<xsl:sort select="xc:datum/xc:day" data-type="number"/>
<xsl:if test="position(.) &lt; 10">
<li><xsl:value-of select="xc:datum/xc:display"/>: <xsl:value-of select="xc:titel"/>
<page:button-edit-delete module="agenda" id="{./xc:id}" multiple="agendapunt"/>
</li>
</xsl:if>
</xsl:for-each>
But this does not work. What i want to is that if there are more than 10 xc:agendapunt items
in the loop the loop should stop. How is this possible?? In someway is must count
the number of loops alreadty taken and only if that number is less than 10 is hould show
the output between the xsl:if
Jul 20 '05 #1
4 5381


Tjerk Wolterink wrote:

i have a xsl:for-each loop like this:

<xsl:for-each select="xc:agendapunt[xc:datum/xc:year &gt; $time_year or
(xc:datum/xc:year=$time_year and xc:datum/xc:month &gt; $time_month) or
(xc:datum/xc:year=$time_year and xc:datum/xc:month=$time_month and
xc:datum/xc:day &gt; $time_day)]">
<xsl:sort select="xc:datum/xc:year" data-type="number"/>
<xsl:sort select="xc:datum/xc:month" data-type="number"/>
<xsl:sort select="xc:datum/xc:day" data-type="number"/>
<xsl:if test="position(.) &lt; 10">
The position function doesn't take an argument.
<li><xsl:value-of select="xc:datum/xc:display"/>: <xsl:value-of
select="xc:titel"/>
<page:button-edit-delete module="agenda" id="{./xc:id}"
multiple="agendapunt"/>
</li>
</xsl:if>
</xsl:for-each>
But this does not work. What i want to is that if there are more than 10
xc:agendapunt items
in the loop the loop should stop. How is this possible??


Can't you simply make sure the for-each only enumerates over 10 elements
e.g.
<xsl:for-each select="xc:agendapunt[...][positon() &lt; 11]">


--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
Martin Honnen wrote:


Tjerk Wolterink wrote:

i have a xsl:for-each loop like this:

<xsl:for-each select="xc:agendapunt[xc:datum/xc:year &gt; $time_year
or (xc:datum/xc:year=$time_year and xc:datum/xc:month &gt;
$time_month) or (xc:datum/xc:year=$time_year and
xc:datum/xc:month=$time_month and xc:datum/xc:day &gt; $time_day)]">
<xsl:sort select="xc:datum/xc:year" data-type="number"/>
<xsl:sort select="xc:datum/xc:month" data-type="number"/>
<xsl:sort select="xc:datum/xc:day" data-type="number"/>
<xsl:if test="position(.) &lt; 10">

The position function doesn't take an argument.
<li><xsl:value-of select="xc:datum/xc:display"/>:
<xsl:value-of select="xc:titel"/>
<page:button-edit-delete module="agenda" id="{./xc:id}"
multiple="agendapunt"/>
</li>
</xsl:if>
</xsl:for-each>
But this does not work. What i want to is that if there are more than
10 xc:agendapunt items
in the loop the loop should stop. How is this possible??

Can't you simply make sure the for-each only enumerates over 10 elements
e.g.
<xsl:for-each select="xc:agendapunt[...][positon() &lt; 11]">


ok but position() is that the current position in the loop or the position of the xc:agendapunt element in the source document?
Jul 20 '05 #3


Tjerk Wolterink wrote:

but position() is that the current position in the loop or the
position of the xc:agendapunt element in the source document?


position is defined here:
<http://www.w3.org/TR/xpath#function-position>
and says "returns a number equal to the context position from the
expression evaluation context."
Each XPath expression is evaluated within a context, a predicate like I
used e.g. [position() < 11] makes sure that the position refers to each
node in the nodeset selected before the predicate.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #4

position() does not take an argument so position(.) is a syntax error
(your xslt processor should have reported that, and stopped)

remove the . and you should be fine.

David
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Xerxes | last post by:
Hi, is there any script to authenticate an email address entered in a form field? I used the php mail() function, using the following (where my email field on the form is called "email"): ...
4
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as...
0
by: Verizon | last post by:
Has anybody ever heard of support for the book: "Secure PHP Development" by: Mohammed J. Kabir I'm trying to run one of his PHP solutions called "Web Forms Manager" I haven't been able to...
0
by: panic | last post by:
If you are not familiar with the palm DB apps I am refering to, they are applications that allow you to graphically create a db by adding fields(columns) and then creats a form so you can enter the...
0
by: Robert Freund | last post by:
I've been looking for a good and free code beautifier that runs on linux. About the only ones I found where Trita (www.trita.com), which costs money and only runs on windows. The other one was...
33
by: Frank | last post by:
What is the best IDE for developing PHP applications? What do you use and why? Thanks.
4
by: john Q | last post by:
I found a PHP based email obfuscator for use in websites, where the source HTML (PHP, actually) file doesn't contain the actual email address in the Mailto tag, but generates it and that...
0
by: Mr.Bogi | last post by:
Is anyone aware of an open source report generation library for php/mysql? Basically a freeware/opensource alternative to Crystal Reports. thanks
0
by: Alex | last post by:
Bottom line: would like to get a weblog and bulletin board going. Would like to use phpBB2 and movabletype. I have movabletype working using mysql. Apache and php were on my linux red hat 7.2...
5
by: ChronicFatigue | last post by:
Hello My current host has register_globals switched on in their php.ini file. Would it be prudent for me to design code which works when register_globals is switched off in case I switch hosts...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.