[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: Tobias Reif <tobiasreif@xxxxxxxxx>
Date: Wed, 7 Feb 2001 14:42:18 -0800 (PST)
ben tobias
Ben and all,

sure; in most cases, the transformation is dealing
with the structure of the source-doc: this is what
XSLT is designed for; in most of those cases,
context-sensitive  operations/expressions/functions
are the most elegant and most appropriate. No doubt.

But in some exceptional cases, context-independant
operations are appropriate, to save code.

If I have three elements "ruler", and want to output
one ruler with a hundred lines for each I could:
1) code the ruler as a template, and output one for
each element "ruler"
- makes 100 line-elements to code
or
2) generate the ruler with a loop, and run that loop
for each element "ruler"
- makes 1 line-element to code

The case in my email was just a basic example, where
position() would have been appropriate.
I just couldn't figure out how to create a
context-independant loop; it's good to know that XSLT
is capable of doing this.

Many thanks to all for your emails; this is my first
day in this list and I really feel at home; this list
is *awesome* !

Thanks,
Tobi

> It works, yes, but I'm not sure that this is the way
> you should be doing it.
> I only use this when I need to do a for loop which
> bears no resemblance at
> all to the input XML... for example, drawing a grid
> of set size no matter
> what the input is.
> 
> Your input has 12 list items - if you need a generic
> way of doing this, then
> position() should be enough.
> 
> Try something like:
> 
> <xsl:template match="/">
> <svg>
> 	<xsl:for-each select="/list/li">
> 		<rect x="{position() * 10}" y="10" width="6"
> height="4"/>
> 	</xsl:for-each>
> </svg>
> </xsl:template>
> 
> which should do the same thing, but be completely
> dependant on the number of
> <li> elements in the input (and is a lot quicker to
> type *grin*).
> 
> Hope this helps,
> 
> Ben

=====
Tobias Reif  http://www.pinkjuice.com/svg/  http://www.pinkjuice.com/
       _/  /      
     /    /    _   /   _  /   _  /  /   /   _  /   _  /   _  /
     _/  /    /   /  /   /  /   /  /   /  /   /  /   /  /   /
   /   _ _/ _ _ _/   _ _/   _ _/ _ _  /   _ _/   _ _/   _ _/
 _/                /      /     _ _ _/  /             /

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/

 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.