473,595 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSL prob.

Hi

I have an XSL stylesheet:

<xsl:for-each select="TRACKS/TRACK">
<tr class="TDL">
<td width="90%"><xs l:number value="position ()" format="1" /> -
<xsl:value-of select="TRACKTI TLE"/></td>
<td width="10%" align="center"> <a href="{TRACKURL }"
target="_blank" >More info!</a></td>
</tr>
</xsl:for-each>
I wan't to make every second <tr class> aligned to TDU, which I have in the
CSS. How is this possible?

Regards,
Kenneth
Jul 20 '05 #1
29 5725
Hi Kenneth,

Try one of the following (all do the same - in a slightly different way)...

<xsl:for-each select="TRACKS/TRACK">
<tr class="TDL">
<xsl:if test="position( ) mod 2 = 0">
<xsl:attribut e name="class">TD U</xsl:attribute>
</xsl:if>
<td width="90%">
<xsl:number value="position ()" format="1" /> -
<xsl:value-of select="TRACKTI TLE"/>
</td>
<td width="10%" align="center">
<a href="{TRACKURL }" target="_blank" >More info!</a>
</td>
</tr>
</xsl:for-each>

<xsl:for-each select="TRACKS/TRACK">
<tr>
<xsl:attribut e name="class">
<xsl:choose>
<xsl:when test="position( ) mod 2 = 1">
<xsl:text>TDL </xsl:text>
</xsl:when>
<xsl:otherwis e>
<xsl:text>TDU </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<td width="90%">
<xsl:number value="position ()" format="1" /> -
<xsl:value-of select="TRACKTI TLE"/>
</td>
<td width="10%" align="center">
<a href="{TRACKURL }" target="_blank" >More info!</a>
</td>
</tr>
</xsl:for-each>

<xsl:for-each select="TRACKS/TRACK">
<tr class="{substri ng('TDUTDL',((p osition() mod 2) * 3) + 1,3)}">
<td width="90%">
<xsl:number value="position ()" format="1" /> -
<xsl:value-of select="TRACKTI TLE"/>
</td>
<td width="10%" align="center">
<a href="{TRACKURL }" target="_blank" >More info!</a>
</td>
</tr>
</xsl:for-each>

Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Thomas" <ridder_dk@SLET _DETTEhotmail.c om> wrote in message
news:Q_******** **************@ news010.worldon line.dk...
Hi

I have an XSL stylesheet:

<xsl:for-each select="TRACKS/TRACK">
<tr class="TDL">
<td width="90%"><xs l:number value="position ()" format="1" /> -
<xsl:value-of select="TRACKTI TLE"/></td>
<td width="10%" align="center"> <a href="{TRACKURL }"
target="_blank" >More info!</a></td>
</tr>
</xsl:for-each>
I wan't to make every second <tr class> aligned to TDU, which I have in the CSS. How is this possible?

Regards,
Kenneth

Jul 20 '05 #2
Hi Marrow.

Damn! You nailed it, thanks.

"Marrow" <marrow-NO-@-SPAM-marrowsoft.com> wrote in message
news:UF******** ******@newsfep1-gui.server.ntli .net...
Hi Kenneth,

Try one of the following (all do the same - in a slightly different way)...
<xsl:for-each select="TRACKS/TRACK">
<tr class="TDL">
<xsl:if test="position( ) mod 2 = 0">
<xsl:attribut e name="class">TD U</xsl:attribute>
</xsl:if>
<td width="90%">
<xsl:number value="position ()" format="1" /> -
<xsl:value-of select="TRACKTI TLE"/>
</td>
<td width="10%" align="center">
<a href="{TRACKURL }" target="_blank" >More info!</a>
</td>
</tr>
</xsl:for-each>

<xsl:for-each select="TRACKS/TRACK">
<tr>
<xsl:attribut e name="class">
<xsl:choose>
<xsl:when test="position( ) mod 2 = 1">
<xsl:text>TDL </xsl:text>
</xsl:when>
<xsl:otherwis e>
<xsl:text>TDU </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<td width="90%">
<xsl:number value="position ()" format="1" /> -
<xsl:value-of select="TRACKTI TLE"/>
</td>
<td width="10%" align="center">
<a href="{TRACKURL }" target="_blank" >More info!</a>
</td>
</tr>
</xsl:for-each>

<xsl:for-each select="TRACKS/TRACK">
<tr class="{substri ng('TDUTDL',((p osition() mod 2) * 3) + 1,3)}">
<td width="90%">
<xsl:number value="position ()" format="1" /> -
<xsl:value-of select="TRACKTI TLE"/>
</td>
<td width="10%" align="center">
<a href="{TRACKURL }" target="_blank" >More info!</a>
</td>
</tr>
</xsl:for-each>

Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Thomas" <ridder_dk@SLET _DETTEhotmail.c om> wrote in message
news:Q_******** **************@ news010.worldon line.dk...
Hi

I have an XSL stylesheet:

<xsl:for-each select="TRACKS/TRACK">
<tr class="TDL">
<td width="90%"><xs l:number value="position ()" format="1" /> -
<xsl:value-of select="TRACKTI TLE"/></td>
<td width="10%" align="center"> <a href="{TRACKURL }"
target="_blank" >More info!</a></td>
</tr>
</xsl:for-each>
I wan't to make every second <tr class> aligned to TDU, which I have in

the
CSS. How is this possible?

Regards,
Kenneth


Jul 20 '05 #3
Hi

I have another prob. Is it possible to convert a unix timestamp to a
readable date with XSL?

Kenneth
Jul 20 '05 #4
Can you give an example of a "Unix timestamp" and a "readable date"?
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
"Thomas" <ridder_dk@SLET _DETTEhotmail.c om> wrote in message
news:vx******** **************@ news010.worldon line.dk...
Hi

I have another prob. Is it possible to convert a unix timestamp to a
readable date with XSL?

Kenneth

Jul 20 '05 #5
> Can you give an example of a "Unix timestamp" and a "readable date"?

Unix timestamp: 875996580
Readable converted date/time: 1997-10-04 22:23:00'

Kenneth
Jul 20 '05 #6
> > Can you give an example of a "Unix timestamp" and a "readable date"?

Unix timestamp: 875996580
Readable converted date/time: 1997-10-04 22:23:00'


And what's its meaning (e.g. number of seconds after some date)?
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
Jul 20 '05 #7
> And what's its meaning (e.g. number of seconds after some date)?

Source: http://www.mysql.com/doc/en/Date_and...functions.html

It would be a lot easier if they pull the data out of the database as a
readable date instead of unix timestamp, but they don't. :(

Regards,

Kenneth
Jul 20 '05 #8
"Thomas" <ridder_dk@SLET _DETTEhotmail.c om> writes:
I have another prob. Is it possible to convert a unix timestamp to a
readable date with XSL?


Yes, because XSLT is Turing complete. However, you'll have to roll
your own conversion because there's neither an XSLT nor XPath function
that'll do the job for you.

Cheers

Jens
Jul 20 '05 #9
"Thomas" <ridder_dk@SLET _DETTEhotmail.c om> wrote in message
news:7R******** **************@ news010.worldon line.dk
And what's its meaning (e.g. number of seconds after some date)?


Source: http://www.mysql.com/doc/en/Date_and...functions.html

It would be a lot easier if they pull the data out of the database as
a readable date instead of unix timestamp, but they don't. :(


Since a UNIX timestamp is the number of seconds since midnight, 1st
January 1970, it would be an "easy" addition of seconds to a date. But
XSL is not capable of that, AFAICS.

What you could do - write a web page accepting a timestamp as GET
parameter and let it return a small XML file to your XSL processor.

Given a return XML like:
<?xml version="1.0"?>
<formatted>19 97-10-04 22:23:00</formatted>

then I would think of:
<xsl:value-of
select="documen t(concat('http://localhost/convert.php&amp ;timestamp=',
$timestamp))/formatted" />

This would return the contents of the XML document's "formatted"
element, or what ever you'd like to call it.
PHP does contain date and time functions capable of converting
timestamps, so the implementation on the PHP side should be quite
straightforward .

You could even improve performance by handing all timestamps in your
document over to PHP simultaneously, as a seperated list of values
(build that by recursive call-template's). So you will need to use
document() only once per processed XML file.

just an idea,

Martin
Jul 20 '05 #10

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

Similar topics

6
2748
by: josephrthomas | last post by:
hi..i am trying to make a login page and i am using access table.. when the user enters his userid and password i want to check the password from the table.. if any user with the userID that is entered exists i want to find the correspoding password for him else i want to throw an error saying no such user exists.. i know how to access the MS Access table and stuff..but
5
4974
by: David Sobey | last post by:
Hi Sorry bout this basic prob. Got a file called file.obj. tryna read the first line from it as a string and print it to the screen. getting errors: #include "stdafx.h" #include <stdio.h> #include <fstream.h> #include <iostream.h> #include <string>
2
1412
by: Dishan Fernando | last post by:
Hi my prob is like this.. ----------------------------- create table ax( i int , j int ) create table ay( i int ,
15
1565
by: Raj | last post by:
Hello all: We have a table with about 2400 cells. Our requirement is to highlight the cells in the table whose data has changed, every 5 seconds. Our script behaves relatively ok in Firefox, but the performance in IE really bad. Have attached a simple html which simulates the prob. Any inputs on how to improve the perf in IE are greatly appreciated. Thanks, Raj
6
3684
by: skubik | last post by:
Hi everyone. I'm attempting to write a Javascript that will create a form within a brand-new document in a specific frame of a frameset. The problem is that I can create the form and input element using createElement(), but when I go to append the form element into the new document, the script halts and I get the following error in my Javascript Console (Firefox 1.0): __tmp_newDoc.body has no properties.
2
1821
by: Wilhelm Kutting | last post by:
hi, i like to solve a code-prob: tidy is bitching about <...> proprietary attribute "type" <...> lacks "action" attribute how can i make this nice? this is my code
28
2706
by: Vishal Naidu | last post by:
i m new to the C world... i ve been told by my instructors not to use goto stmt.. but no one could give me a satisfactory answer as to why it is so.. plz help me out of this dilemma, coz i use a lot of goto in my codes....
0
1399
Savage
by: Savage | last post by:
I'm making for fun a simple program which format a input file.Input file sustain of person name,lastname and date of birth.Output file si supposed to be forammted as following: NAME LASTNAME DATE OF BIRTH And i finished it but there is little prob: it don't output date of birth! I thinkt about the prob and can't figure out why is that happening. To output data i used function: void output(void),i have...
2
1513
by: mnacw | last post by:
Can anybody help me to resolve this prob. i have installed Visual Studio 2005 Professional edition. I am working in VB.Net. When I tried to connect to database it is connected but when i make some changes in table and try to update it does not work. It does not give any error. It seems like all fine. but when I retrieve the data via application menas data grid control on form. shows only previous data. no updates. i am using acess...
0
7883
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8262
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
6675
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5839
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5421
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3875
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3915
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1491
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1226
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.