Subject: Re: [xsl] counter vs. functional counterpart From: Andrew Welch <andrew.j.welch@xxxxxxxxx> Date: Tue, 21 Jul 2009 09:21:01 +0100 |
2009/7/21 Jeff Shelley <jshelley@xxxxxxxxxxxxxxxxxxxx>: > Hello. > Does anybody know what xsl file can take this: > > <rows> > <row> > <name>John</name> > <otherName/> > </row> > <row> > <name>Paul</name> > <otherName/> > </row> > <row> > <name>Ringo</name> > <nickName>ClassCastException</nickName> > </row> > <row> > <name>George</name> > <otherName/> > </row> > </rows> > > > and turn it into this? > > 1-John > 2-Paul > 3-Ringo > 4-ClassCastException > 5-George > > Basically, I need the output number to keep incrementing and be continuous. > Everything I see about counters says "if you're implementing a counter > you're doing it wrong", but I have absolutely no idea how to do this. You just use xsl:number. In declarative programming, you say what you want rather than describe the steps involved (something that doesn't help at all when you are learning, but makes sense after :) <xsl:template match="row"> <xsl:number/> <xsl:value-of select="'-', (nickName, name)[1]" separator=""/> </xsl:template> -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] counter vs. functional co, Michael Kay | Thread | Re: [xsl] counter vs. functional co, Dimitre Novatchev |
RE: [xsl] counter vs. functional co, Michael Kay | Date | [xsl] Design Question: XSLT Configu, Matthias Müller |
Month |