[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 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 text="System Status" href="#">
<MinorNav text="View Jobs" href="view_jobs.cgi"/>
<MinorNav text="Job performance statistics" href="job_stats_csv.cgi"/>
<MajorNav text="Other" href="#">
<MinorNav text="Home" href="index.cgi"/>
<MinorNav text="Logout" href="logout.cgi"/>

<?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="/">
<body marginleft="0" marginheight="0">
<xsl:template match="NavigationMenu">
<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"/>
<xsl:template match="NavigationMenu/MajorNav/MinorNav">
<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"/>

<html xmlns:fo="http://www.w3.org/1999/XSL/Format">
<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>
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>
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>

Formatted HTML:
0(1) System Management

User Accounts

1(3) System Status
View Jobs

Job performance statistics

2(5) Other


James C. Freeman
Voice: 415 971 6541
Fax: 413 622 8955

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

Current Thread


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.
First Name
Last Name
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.