incrementing

Discussion in 'XML' started by David Schwartz, Jul 1, 2008.

  1. I need to create unique id's for DIVs for each instance of <foo>
    within each instance of <bar> as follows. I iterate through both the
    bars and foos via <apply-templates/>. I've tried to use position() but
    that reflects the current <bar>, not the current <foo>.

    ========= sample xml ================
    <!-- note the there may be other peer elements to the FOOs -->
    <root>
    <bar>
    <foo>blah, blah, blah</foo>
    <foo>bebop, smooth, cool, swing, super cool</foo>
    </bar>
    <bar>
    <foo>baroque, classical, modern</foo>
    <foo>chicago, delta</foo>
    </bar>
    </root>
    ==================================

    ========= sample html ================
    page generated for the first <bar> instance:
    <html>
    <body>
    <div id="foo1">blah, blah, blah</div>
    <div id="foo2">bebop, smooth, cool, swing, super cool</div>
    </body>
    </html>

    page generated for the second <bar> instance:
    <html>
    <body>
    <div id="foo1">baroque, classical, modern</div>
    <div id="foo2">chicago, delta</div>
    </body>
    </html>
    =================================
     
    David Schwartz, Jul 1, 2008
    #1
    1. Advertising

  2. In article <>,
    David Schwartz <> wrote:
    >I need to create unique id's for DIVs for each instance of <foo>
    >within each instance of <bar> as follows.


    Use generate-id().

    If you really need the position of <foo> within the whole document,
    you could use count(preceding::foo), but it will be potentially
    very slow.

    -- Richard
    --
    Please remember to mention me / in tapes you leave behind.
     
    Richard Tobin, Jul 1, 2008
    #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. Josh Graham
    Replies:
    3
    Views:
    23,291
    Nicolas Matringe
    Apr 7, 2004
  2. Salman

    Incrementing value test

    Salman, Apr 13, 2005, in forum: VHDL
    Replies:
    2
    Views:
    641
    Engineering Guy
    Apr 13, 2005
  3. Mothra
    Replies:
    3
    Views:
    438
  4. Ron
    Replies:
    0
    Views:
    316
  5. =?Utf-8?B?bWVraW0=?=

    Incrementing Assembly Version?

    =?Utf-8?B?bWVraW0=?=, Oct 28, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    7,340
    Saravana
    Oct 29, 2004
Loading...

Share This Page