Skip to main content
Question

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

  • October 25, 2017
  • 6 replies
  • 501 views

Forum|alt.badge.img

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

david_r
Celebrity
  • October 25, 2017

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)

redgeographics
Celebrity
Forum|alt.badge.img+49

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...


david_r
Celebrity
  • October 25, 2017
redgeographics wrote:

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).

redgeographics
Celebrity
Forum|alt.badge.img+49
redgeographics wrote:

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...

 

 


mark2atsafe
Safer
Forum|alt.badge.img+44
  • Safer
  • October 25, 2017
david_r wrote:

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.

 


mark2atsafe
Safer
Forum|alt.badge.img+44
  • Safer
  • October 25, 2017
david_r wrote:
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.

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings