473,396 Members | 1,779 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,396 software developers and data experts.

Looping with XSLT

tom
Hi all

The next thing I'm trying to do here at www.guitarmidi.co.uk is show how
many results a query returns above a table displaying those results. Doing
this willl eventually lead to showing links to pages of the table as well

Whats happening here is the first <xsl:for-each select> in the code loops
and counts the results, I know this will work because the 'x' is displayed
however many results there are.

I know there has to be some sort of counter were the 'x' is and some code to
output the text after the <xsl:for-each select> but I'm not to sure how to
implement it.

Any ideas?


<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="ISO-8859-1" />

<xsl:param name="text0" />
<xsl:param name="text1" />
<xsl:param name="text2" />
<xsl:param name="text3" />
<xsl:param name="text4" />

<xsl:template match="/">

<html>

<head>

<link rel="stylesheet" type="text/css" href="mystyle.css" />
<title>Results</title>
</head>

<body>

<xsl:for-each select="(cat/links[(contains(artist, $text0) or contains(song,
$text0)) and
(contains(artist, $text1) or contains(song, $text1)) and
(contains(artist, $text2) or contains(song, $text2)) and
(contains(artist, $text3) or contains(song, $text3)) and
(contains(artist, $text4) or contains(song, $text4))])">
x
</xsl:for-each>

<table class="three">

<col width="40%"/>
<col width="40%"/>
<col width="10%"/>
<col width="10%"/>

<tr>
<th class="head">Artist</th>
<th class="head">Song</th>
<th class="head"></th>
<th class="head"></th>
</tr>
<xsl:for-each select="(cat/links[(contains(artist, $text0) or contains(song,
$text0)) and
(contains(artist, $text1) or contains(song, $text1)) and
(contains(artist, $text2) or contains(song, $text2)) and
(contains(artist, $text3) or contains(song, $text3)) and
(contains(artist, $text4) or contains(song, $text4))])">

<tr>
<td class="one"><xsl:apply-templates select="./artist"/></td>
<td class="one"><xsl:apply-templates select="./song"/></td>
<xsl:variable name="path1"><xsl:apply-templates
select="./path"/></xsl:variable>
<td><a href="javascript:newWindow1('media/{$path1}.txt')"><img
src="images/tab.gif" border="0"/></a></td>
<td><a href="javascript:newWindow2('media/{$path1}.mid')"><img
src="images/play.gif" border="0"/></a></td>
</tr>

</xsl:for-each>

</table>

</body>

</html>

</xsl:template>

</xsl:stylesheet>
Apr 20 '06 #1
1 1308
Is this the sort of thing you're looking for?

<xsl:for-each select="(cat/links[(contains(artist, $text0) or
contains(song,
$text0)) and
(contains(artist, $text1) or contains(song, $text1)) and
(contains(artist, $text2) or contains(song, $text2)) and
(contains(artist, $text3) or contains(song, $text3)) and
(contains(artist, $text4) or contains(song, $text4))])">
<xsl:value-of select="position()"/>
<xsl:text> of </xsl:text>
<xsl:value-of select="last()"/>
<xsl:text>: </xsl:text>
<xsl:value-of select="."/>
<xsl:text> </xsl:text>
</xsl:for-each>

See also http://www.w3.org/TR/1999/REC-xslt-19991116#number

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Apr 20 '06 #2

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

Similar topics

2
by: ted | last post by:
Was wondering if XSLT alone is appropriate for the following situation. From XML, I'm creating a small website (around 50 pages) with pages that link to each other through a nav menu and a...
1
by: Mohit | last post by:
Hi Friends I have to call 1 of the 2 child XSLT files from the Main XSLT file based on some criteria. I want one child XSLT file will be executed by version 1 of XSLT processor and the other by...
3
by: Tjerk Wolterink | last post by:
Hello, I want to create m elements in this form: <element index="n"/> Where n = 1 2 .. m Can is do this with an xsl:for loop?? And if so how
3
by: Teksure | last post by:
Hi group, searching in the Internet I found two products for XML which incorporate a very robust debugger for XSL/XSLT, I would like you to see these products and then, give me your opinion about...
4
by: Eric | last post by:
Hello, I've found syntax documentation on the document XSLT function, but I haven't found a good resource yet on how to properly use it. As stripped down example, I have XML files that are...
1
by: Sergey Dubinets | last post by:
In effort to prioritize our goals we composed the list of random features each of them may add value to set of XSLT tools offered from Microsoft. 1. XSLTc (Compiler for XSLT...
4
by: jimmygoogle | last post by:
i have an xml file with links to websites but my output only prints the 1st website from each tag - any ideas why? i have an an xml file that looks sort of like this: <?xml version="1.0"...
1
by: tkahn6 | last post by:
Hi! Ok so im having a very very rookie (i assume) problem. I want to take this: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="xslTest.xsl"?> <dataTree> ...
2
by: li72 | last post by:
Hi. guys The following xslt stylesheet supposed to loop through the xml doc visiting each node, read and write its name and their attributes (userid, password). Actually it visits the only the first...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.