[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

position() counting by 2's

Subject: position() counting by 2's
From: Jim Freeman <jim@xxxxxxxxxxxxxxxx>
Date: Mon, 01 Apr 2002 09:25:57 -0800
counting by 2 s
<warning>Novice question</warning>

It appears that position() is counting by twos. In the below example, I am using the position() function
to number my output. I would like to number starting from 0.


The values that $NavNumber takes on are (1, 3, 5) and $CorrectedNavNumber are (0, 1, 3)

XML, XSL, HTML and output are included below.

Any help??

XML:
<?xml version="1.0" encoding="UTF-8"?>
<NavigationMenu title=" Platform Administration" target="_blank">
<MajorNav text="System Management" href="#i">
<MinorNav text="Settings" href="admn_sys_settings.cgi"/>
<MinorNav text="User Accounts" href="manage_users.cgi"/>
</MajorNav>
<MajorNav text="System Status" href="#">
<MinorNav text="View Jobs" href="view_jobs.cgi"/>
<MinorNav text="Job performance statistics" href="job_stats_csv.cgi"/>
</MajorNav>
<MajorNav text="Other" href="#">
<MinorNav text="Home" href="index.cgi"/>
<MinorNav text="Logout" href="logout.cgi"/>
</MajorNav>
</NavigationMenu>


XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output omit-xml-declaration="yes" indent="no"/>
<xsl:template match="/">
<html>
<head/>
<body marginleft="0" marginheight="0">
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="NavigationMenu">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="NavigationMenu/MajorNav">
<xsl:variable name="NavNumber" select="position() - 1"/>
<xsl:variable name="CorrectedNavNumber" select="(position() div 2) - 1"/>
<xsl:value-of select="$CorrectedNavNumber"/>(<xsl:value-of select="$NavNumber"/>) <xsl:value-of select="@text"/>
<ul>
<xsl:apply-templates/>
</ul>
</xsl:template>
<xsl:template match="NavigationMenu/MajorNav/MinorNav">
<li>
<a>
<xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>
<xsl:attribute name="target"><xsl:value-of select="../../@target"/></xsl:attribute>
<xsl:value-of select="@text"/>
</a>
<br/>
<xsl:apply-templates/>
</li>
</xsl:template>
</xsl:stylesheet>


HTML:
<html xmlns:fo="http://www.w3.org/1999/XSL/Format">
<head></head>
<body marginleft="0" marginheight="0">
0(1) System Management<ul>
<li><a href="admn_sys_settings.cgi" target="_blank">Settings</a><br></li>
<li><a href="manage_users.cgi" target="_blank">User Accounts</a><br></li>
</ul>
1(3) System Status<ul>
<li><a href="view_jobs.cgi" target="_blank">View Jobs</a><br></li>
<li><a href="job_stats_csv.cgi" target="_blank">Job performance statistics</a><br></li>
</ul>
2(5) Other<ul>
<li><a href="index.cgi" target="_blank">Home</a><br></li>
<li><a href="logout.cgi" target="_blank">Logout</a><br></li>
</ul>
</body></html>


Formatted HTML:
0(1) System Management
Settings

User Accounts

1(3) System Status
View Jobs

Job performance statistics

2(5) Other
Home

Logout



James C. Freeman
mailto:jim@xxxxxxxxxxxxxxxx
Voice: 415 971 6541
Fax: 413 622 8955


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.