Subject: Re: [xsl] position() counting by 2's From: Oleg Tkachenko <olegt@xxxxxxxxxxxxx> Date: Mon, 01 Apr 2002 20:46:42 +0200 |
<xsl:template match="NavigationMenu"> <xsl:apply-templates select="MajorNav"/> </xsl:template>
<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
-- Oleg Tkachenko Multiconn International, Israel
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] position() counting by 2', Michael Kay | Thread | [xsl] Re: RE: transforming a file w, Dimitre Novatchev |
RE: [xsl] XML string copying w/o d-, Michael Kay | Date | [xsl] Finding Unique Nodes, Brucato, Greg |
Month |