Jump to content

generate unique id in XSLT


karthikin
 Share

Recommended Posts

Hi Guys,I use XSLT function to generate a unique id for my xml file

 <xsl:value-of select="generate-id(.)"/>  

and the output is "N65539".Then I used the same function and run the XSLT processor in Firefox XUL for the same XML file, the output of the id is "id0x03bb5600" in this format.How can i specify certain type to generate a unique id?This function generate id for <Customer-ID> </Customer-ID> in my XML file. Output 1: <Customer-ID>N65539</Customer-ID>Output 2: <Customer-ID>id0x03bb5600</Customer-ID>Thanks for your support.

  • Like 1
Link to comment
Share on other sites

You can't. The idea of generate-id() isn't to generate IDs that would be used in the final document. It's meant for generating IDs to be used within the XSLT itself. In particular, about estabilishing "connections" between nodes, because generate-id() would always return the same ID for a certain node within the same transformation.Here's one example with grouping and generate-id().If you need to output a specific kind of ID, you should probably design yourself a custom template that generates it from something else... like the position within the document or something.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...