On Thu, 2022-11-03 at 15:00 -0400, Graydon Saunders wrote: > Hello -- > > You can (I think) test if some attribute value is an RFC 4122 UUID by > using > a regular expression: > > let $regexp as xs:string := > '^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-5][0-9a-fA-F]{3}-[089abAB][0-9a- > fA-F]{3}-[0-9a-fA-F]{12}$'
You could also split this up into strings, maybe using a helper function: let $hexdigit := '[0-9a-f]', $n := function($n as xs:integer) { $hexdigit || '{' || $n || '}' }, $matchuuid := '^' || $n(8) || '-' || $n(4) || '-' || '[0-5]' || $n($3) || '-' || '[098ab]' || $n{3} || '-' || $n{12} and use it with the case insensitive "i" flag. However, this isn't very clear. Mike Kay gives a solution [1], translate($in, '0123456789abcdefABCDEF', '000000000000000000000000') = '00000000-0000-0000-0000-000000000000' which is probably enough in practice. If you need to check further, see RFC 4122 for the components. Your regexp limits the UUID value space https://datatracker.ietf.org/doc/html/rfc4122#page-5 [1] https://p2p.wrox.com/xslt/68464-validate-guid-uuid.html -- Liam Quin, https://www.delightfulcomputing.com/ Available for XML/Document/Information Architecture/XSLT/ XSL/XQuery/Web/Text Processing/A11Y training, work & consulting. Barefoot Web-slave, antique illustrations: http://www.fromoldbooks.org