Subject: Re: [xsl] counter vs. functional counterpart From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Tue, 21 Jul 2009 06:04:11 -0700 |
On Mon, Jul 20, 2009 at 8:53 PM, Jeff Shelley<jshelley@xxxxxxxxxxxxxxxxxxxx> wrote: > Hello. > B Does anybody know what xsl file can take this: > > <rows> > B <row> > B B B <name>John</name> > B B B <otherName/> > B </row> > B <row> > B B B <name>Paul</name> > B B B <otherName/> > B </row> > B <row> > B B B <name>Ringo</name> > B B B <nickName>ClassCastException</nickName> > B </row> > B <row> > B B B <name>George</name> > B B B <otherName/> > B </row> > </rows> > > > and turn it into this? > > B B B B 1-John > B B B B 2-Paul > B B B B 3-Ringo > B B B B 4-ClassCastException > B B B B 5-George This problem is so simple, that it doesn't ever need <xsl:number/>: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:for-each select= "*/*/*[self::name or self::nickName]"> <xsl:value-of select= "concat('
', position(), '-', .)"/> </xsl:for-each> </xsl:template> </xsl:stylesheet> -- Cheers, Dimitre Novatchev --------------------------------------- Truly great madness cannot be achieved without significant intelligence. --------------------------------------- To invent, you need a good imagination and a pile of junk ------------------------------------- Never fight an inanimate object ------------------------------------- You've achieved success in your field when you don't know whether what you're doing is work or play
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] counter vs. functional co, Andrew Welch | Thread | Re: [xsl] counter vs. functional co, Jeff Shelley |
AW: [xsl] Design Question: XSLT Con, Matthias Müller | Date | Re: [xsl] counter vs. functional co, Jeff Shelley |
Month |