473,569 Members | 2,664 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 5712
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
2746
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...
5
4972
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
1410
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
1562
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...
6
3682
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...
2
1819
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
2695
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
1397
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...
2
1512
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...
0
7924
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. ...
0
8122
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7673
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5219
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...
0
3653
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...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
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...

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.