xsl-list
[Top] [All Lists]

Re: [xsl] counter vs. functional counterpart

2009-07-21 09:04:40
On Mon, Jul 20, 2009 at 8:53 PM, Jeff
Shelley<jshelley(_at_)stuntmansoftware(_dot_)com> wrote:
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

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('&#xA;', 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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--