XSLT numbering by attribute

Discussion in 'XML' started by James Merdan, Sep 24, 2003.

  1. James Merdan

    James Merdan Guest

    Hi,
    I'm having an issue I was hoping someone could help me with. I have
    a number of tags which have an attribute 'type' like this:
    <data file="file1.jpg" type="image"/>
    <data file="file2.jpg" type="image"/>
    <data file="file3.jpg" type="image"/>
    <data file="file1.txt" type="text"/>
    <data file="file2.txt" type="text"/>
    <data file="file1.bin" type="binary"/>

    etc...

    Now I can get a total count by data/@type like this:
    image : 3
    text : 2
    binary : 1

    But what I want to be able to do is get a running total like this:
    file1.jpg image 1 of 3
    file2.jpg image 2 of 3
    file3.jpg image 3 of 3
    ...

    I'm stuck with the XML coming in the way it is, so is there a way to
    do this with XSL?

    Thanks,
    James
    James Merdan, Sep 24, 2003
    #1
    1. Advertising

  2. This is a grouping problem -- for a description of the Muenchian method for
    grouping see:

    http://www.topxml.com/code/default.asp?p=3&id=v20010129150851

    and

    http://jenitennison.com/xslt/grouping/index.html


    =====
    Cheers,

    Dimitre Novatchev.
    http://fxsl.sourceforge.net/ -- the home of FXSL



    "James Merdan" <> wrote in message
    news:...
    > Hi,
    > I'm having an issue I was hoping someone could help me with. I have
    > a number of tags which have an attribute 'type' like this:
    > <data file="file1.jpg" type="image"/>
    > <data file="file2.jpg" type="image"/>
    > <data file="file3.jpg" type="image"/>
    > <data file="file1.txt" type="text"/>
    > <data file="file2.txt" type="text"/>
    > <data file="file1.bin" type="binary"/>
    >
    > etc...
    >
    > Now I can get a total count by data/@type like this:
    > image : 3
    > text : 2
    > binary : 1
    >
    > But what I want to be able to do is get a running total like this:
    > file1.jpg image 1 of 3
    > file2.jpg image 2 of 3
    > file3.jpg image 3 of 3
    > ...
    >
    > I'm stuck with the XML coming in the way it is, so is there a way to
    > do this with XSL?
    >
    > Thanks,
    > James
    Dimitre Novatchev, Sep 24, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bostonasian
    Replies:
    1
    Views:
    817
    Joris Gillis
    Sep 18, 2005
  2. bprimuslevy
    Replies:
    1
    Views:
    438
    Soren Kuula
    Aug 23, 2006
  3. pstachy

    sort and numbering - xslt

    pstachy, Nov 26, 2006, in forum: XML
    Replies:
    7
    Views:
    563
  4. Michael Doubez
    Replies:
    1
    Views:
    528
    Peter Flynn
    Jan 27, 2007
  5. Liam
    Replies:
    1
    Views:
    737
    Pavel Lepin
    Jul 17, 2007
Loading...

Share This Page