Question

How to modify the UUIDGenerator so that the ID starts with a letter

  • 25 October 2017
  • 6 replies
  • 76 views

Badge

I have to create an UUID and wanted to use the UUIDGenerator. My XSD File has defined the UUID as an ID which may not start with a number. The UUIDGenerator put a number at the front though and I see no way of modifying it. Why is this? and how should I best generator an ID otherwise?


6 replies

Userlevel 4

Your XSD is wrong ;-) A GUID starting with any hexadecimal digit [0-9a-z] is perfectly valid.

You can't modify the UUIDGenerator, but you can use e.g. an AttributeCreator with the following expression to replace the first character with an 'a':

a@Substring(@Value(_uuid),1,35)
Userlevel 4
Badge +25

In addition to @david_r 's comment:

It's possible if you're Doctor Who (or have access to a TARDIS or other form of time travel). The first part of a UUID is timestamp-based...

Userlevel 4

In addition to @david_r 's comment:

It's possible if you're Doctor Who (or have access to a TARDIS or other form of time travel). The first part of a UUID is timestamp-based...

It depends on the implementation. For example, the Python uuid module supports 4 different ways of generating a GUID, of which only uuid1() is based on a timestamp (well, a clock sequence at least).
Userlevel 4
Badge +25

In addition to @david_r 's comment:

It's possible if you're Doctor Who (or have access to a TARDIS or other form of time travel). The first part of a UUID is timestamp-based...

Actually, I take that back, some UUID variants are indeed timestamp based, but there's others where time is not a factor. I can't seem to find which variant FME uses.

 

However, a UUID can still start with a number and be valid...

 

 

Userlevel 4
Badge +25

Your XSD is wrong ;-) A GUID starting with any hexadecimal digit [0-9a-z] is perfectly valid.

You can't modify the UUIDGenerator, but you can use e.g. an AttributeCreator with the following expression to replace the first character with an 'a':

a@Substring(@Value(_uuid),1,35)
Or I guess he could take the first 8 digits off and attached them at the back of the string. The second set of digits look like they begin with a letter. I'll investigate as well, see if I can find what method of generation we use.

 

Userlevel 4
Badge +25
It depends on the implementation. For example, the Python uuid module supports 4 different ways of generating a GUID, of which only uuid1() is based on a timestamp (well, a clock sequence at least).
The @UUID help says: " The identifier is created from a combination of the computer's hardware characteristics, the current time, and a sequence number." - not sure which variation uses those three items. Can't find anything else with a quick look through our internal systems.

 

Reply