Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 18th, 2006, 06:25 PM
The alMIGHTY N
Guest
 
Posts: n/a
Default counting...

Hi, I'm trying to create essentially an ordered list of items.

<games>
<game>
<title>Legend of Zelda: Twilight Princess</title>
<system>Nintendo Wii</system>
</game>
<game>
<title>Metal Gear Solid 4</title>
<system>Sony Playstation 3</system>
</game>
<game>
<title>Elite Beat Agents</title>
<system>Nintendo DS</system>
</game>
<game>
<title>Gears of War</title>
<system>Microsoft Xbox 360</system>
</game>
<game>
<title>Grand Theft Auto: Vice City Stories</title>
<system>Sony PSP</system>
</game>
</games>

I want to produce:

<ul>
<li>1 - Legend of Zelda: Twilight Princess</li>
<li>2 - Metal Gear Solid 4</li>
<li>3 - Elite Beat Agents</li>
<li>4 - Gears of War</li>
<li>5 - Grand Theft Auto: Vice City Stories</li>
</ul>

I know I can just use <olinstead of <ulbut I'm trying to learn how
to do it functionally through XSL instead.

Thanks,

Nathaniel

  #2  
Old December 18th, 2006, 06:45 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: counting...

The alMIGHTY N wrote:
Quote:
Hi, I'm trying to create essentially an ordered list of items.
Quote:
I know I can just use <olinstead of <ulbut I'm trying to learn how
to do it functionally through XSL instead.
There are several ways, one is the position function e.g.
<xsl:template match="games">
<html>
<body>
<ul>
<xsl:apply-templates select="game"/>
</ul>
</body>
</html>
</xsl:template>

<xsl:template match="game">
<li>
<xsl:value-of select="concat(position(), ' - ')"/>
<xsl:apply-templates select="title"/>
</li>
</xsl:template>

<xsl:template match="title">
<xsl:value-of select="."/>
</xsl:template>

Or look into xsl:number <http://www.w3.org/TR/xslt#number>.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles