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

RE: context-independent counter

Subject: RE: context-independent counter
From: Linda van den Brink <lvdbrink@xxxxxxx>
Date: Wed, 7 Feb 2001 15:57:41 +0100
RE:  context-independent counter
> 
> <list>
> 	<li>text</li>
> 	<li>text</li>
> 	<li>text</li>
> 	<li>text</li>
> 	<li>text</li>
> 	<li>text</li>
> 	<li>text</li>
> 	<li>text</li>
> 	<li>text</li>
> 	<li>text</li>
> 	<li>text</li>
> 	<li>text</li>
> </list>
> 
> [through:]
> 
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 	<xsl:variable name="counter" select="10"/>
> 	<xsl:output method="xml" version="1.0"
> encoding="UTF-8" indent="yes"/>
> 	<xsl:template match="/">
> 		<svg>
> 			<xsl:for-each select="/list/child::li">
> 				<rect x="{$counter}" y="10" 
> width="6" height="4"/>
> 				<xsl:variable name="counter"
> select="$counter+10"/>
> 			</xsl:for-each>
> 		</svg>
> 	</xsl:template>
> </xsl:stylesheet>

You don't say exactly what output you want but looking at your code I think
you want a series of rectangles, the first with x=10, the second with x=20,
etc. In that case: you don't need a counter. The XSLT processor already
counts the nodes in a node set. Each node has a number you can access. So
all you need to do is get the position number of each li element and
multiply it by ten... 

<rect x="{position() * 10}" y="10" width="6" height="4"/>

Linda

 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.