I need to generate a GUID with XSLT and if needed C#, does anyone know how to best do this?
It is to generate unique IDs for HTML items.
The XSLT generate-id
function returns a string that uniquely identifies a node in the document. Note these warnings from the spec:
An implementation is under no obligation to generate the same identifiers each time a document is transformed. There is no guarantee that a generated unique identifier will be distinct from any unique IDs specified in the source document.
However, if all you need is to uniquely identify each element in your output, then generate-id
is sufficient.
C# provides a handy Guid.NewGuid() static method. I'd expect any XSLT implementation would heavily leverage some system-specific component since Guids are often generated in part based on hardware/MAC address/etc. on the underlying machine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With