Generate Unique Id with 8 Character d1e24262

Having trouble installing Oxygen? Got a bug to report? Post it all here.
idak
Posts: 16
Joined: Mon Mar 18, 2013 6:29 pm

Generate Unique Id with 8 Character d1e24262

Post by idak »

Hi,
I want to assign a unique Id to T0X Tag: something like <T0X id = “d1e24262”>
I’m using String id = GenerateIDElementsInfo.generateID("${uuid}", selectedNodeName), but the id generated it’s : d1e26994-8cf0-11bd-b23e-10b96e4ef00d
What pattern id I can use to generate an id with 8 Character

Regards,
Idak
Radu
Posts: 9448
Joined: Fri Jul 09, 2004 5:18 pm

Re: Generate Unique Id with 8 Character d1e24262

Post by Radu »

Hi,

We also have a smaller generated ID value using ${id} like:

Code: Select all

GenerateIDElementsInfo.generateID("${id}", selectedNodeName)
which generates a sequence of about 10 characters and/or numbers.
Or you can take only the first part (before the first "-") from the UUID, of course it would not be guaranteed anymore to be unique.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
idak
Posts: 16
Joined: Mon Mar 18, 2013 6:29 pm

Re: Generate Unique Id with 8 Character d1e24262

Post by idak »

Hi Radu,

I already try both cases and I have a validation error:
E [Xerces] cvc-attribute.3: The value '6d696d14' of attribute 'id' on element 'T0X' is not valid with respect to its type, 'ID'.
Other Ids are generated by xsl (id=${uuid})

Regards,
Idak
Radu
Posts: 9448
Joined: Fri Jul 09, 2004 5:18 pm

Re: Generate Unique Id with 8 Character d1e24262

Post by Radu »

Hi Idak,

Just prepend some character value to it in order to be sure that the value does not start with a number like:

"id_6d696d14"

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
idak
Posts: 16
Joined: Mon Mar 18, 2013 6:29 pm

Re: Generate Unique Id with 8 Character d1e24262

Post by idak »

Hi,
it works thank you.
Post Reply