I think I would solve this by running a transformation that creates a
version of your flashcards file with id attributes added. You can then
use this augmented file as the base file for the interactive
To add the ids, you can do:
You can't use generate-id directly in the interactive application
because (a) there is no way of finding a node given its generated id,
and (b) the results of generate-id are not guaranteed to be stable from
one transformation to the next.
> -----Original Message-----
> From: Edward Tanguay [mailto:edward80133@h...]
> Sent: 26 June 2002 08:39
> To: P2P_XSLT
> Subject: [xslt] how to uniquely identify elements in XSLT for
> parameter passing?
> 1. I have an XML file with hundreds of flashcards in it:
> <flashcard question="What is XML?" answer="XML is..."/>
> 2. I want to create an XSLT file which lists out the
> questions as hyperlinks
> and when the user clicks on the hyperlink, a new window opens
> with the
> 3. The problem is, how do I IDENTIFY each record so that I
> can pass this id
> as a parameter into the next window which then looks up that
> element? If I
> were using a database I would have the "id" field which is
> auto-increment, I
> can pass the id as a parameter no problem. But my flashcard
> elements do not
> have an ID attribute that uniquely identifies them.
> a. Can I use position() somehow?
> b. Is there some kind of auto-increment function in XSLT that
> I can use? Do
> I need to
> c. Do I need to run an XSLT transformation which adds ID
> fields to my tags
> based on position() perhaps?
> I'm sure this is a common problem for those who are using XML
> files as
> databases and need to implement this primary key function to
> identify their
> How does one solve this problem in XSLT?
> Edward Tanguay
> Get your FREE download of MSN Explorer at
> Change your mail
> options at