Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

incrementing

Question posted by: David Schwartz (Guest) on July 1st, 2008 04:25 AM
I need to create unique id's for DIVs for each instance of <foo>
within each instance of <baras 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 <barinstance:
<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 <barinstance:
<html>
<body>
<div id="foo1">baroque, classical, modern</div>
<div id="foo2">chicago, delta</div>
</body>
</html>
=================================
Richard Tobin's Avatar
Richard Tobin
Guest
n/a Posts
July 1st, 2008
08:25 AM
#2

Re: incrementing
In article <8ccc86ed-3d14-444e-918b-e9376649556e@w5g2000prd.googlegroups.com>,
David Schwartz <davids58@gmail.comwrote:
Quote:
>I need to create unique id's for DIVs for each instance of <foo>
>within each instance of <baras follows.


Use generate-id().

If you really need the position of <foowithin 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.

 
Not the answer you were looking for? Post your question . . .
189,873 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors