[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: generate-id() problem

Subject: Re: generate-id() problem
From: "Nima Kaviani" <nkaviani@xxxxxx>
Date: Fri, 24 Nov 2006 01:59:31 -0800
generate id problems
ok sorry about the confusion I made. what I need to do is to generate
a unique identifier for different nodes. so I need to generate an XML
of the form below

<rule:foo rdf:ID="rule_N2320">
   <rule:bar rdf:resource="constraint_N3456"/>
</rule:foo>

<constraint:test rdf:ID="constraint_N3456">
  <t1/>
  <t2/>
<constraint:tes>

ok so as it is obvious in the code above, I need to generate two
unique values, here "N2320" and "N3456", using a funciton and attach
them to my terms, "rule" and "constraint".

I need to generate these two numbers at the same time in my xslt
template as I need to keep track of the generated elements and their
ids later in the code. I thought of generate-id() as the suitable
function for my purpose. In one of the tutorials I read on XSLT it
says that generate-id() can be used to generate a unique string for a
node, so based on this single line hint, I thought that would be what
I need but apparantly it isn't.

thanks in advance for the help,
-Nima



On 11/24/06, Michael Kay <mike@xxxxxxxxxxxx> wrote:

generate-id() with no parameters is equivalent to generate-id(.) - it returns the identifier of the context node. If you call it twice with the same argument, it is guaranteed to return the same answer.

You seem to be in need of a completely different function, so you need to
explain what you are trying to do.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: nima.kaviani@xxxxxxxxx [mailto:nima.kaviani@xxxxxxxxx]
> On Behalf Of Nima Kaviani
> Sent: 24 November 2006 08:38
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  generate-id() problem
>
> Hi all,
>
> I have a problem with using generate-id()
>
> apparantly, as I see it in my code, generate-id is dependent
> to the context and the current location in the xml document.
> that is, when I use generate-id() twice and in the same
> context it returns the same value though I need two different values!
>
> however, when I use generate-id(../..) or generate-id(/) it
> returns some other values to me!
>
> is there anything wrong with my settings and assumptions? do
> I have any way around it?
>
> thanks,
> -Nima

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.