Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > incrementing

Thread Tools


David Schwartz
Posts: n/a
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 -->
<foo>blah, blah, blah</foo>
<foo>bebop, smooth, cool, swing, super cool</foo>
<foo>baroque, classical, modern</foo>
<foo>chicago, delta</foo>

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

page generated for the second <bar> instance:
<div id="foo1">baroque, classical, modern</div>
<div id="foo2">chicago, delta</div>
Reply With Quote
Richard Tobin
Posts: n/a
In article <(E-Mail Removed)>,
David Schwartz <(E-Mail Removed)> 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.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Incrementing value test Salman VHDL 2 04-13-2005 04:52 PM
Incrementing Assembly Version? =?Utf-8?B?bWVraW0=?= ASP .Net 5 10-29-2004 01:08 PM
Incrementing VHDL FOR loop constant by a value other than 1 Josh Graham VHDL 3 04-07-2004 07:03 AM
looping/incrementing problem... Mothra Perl 3 12-10-2003 02:01 AM
Incrementing Datagrid Value -- Simple Question Ron ASP .Net 0 06-30-2003 04:37 PM