Home Ask Login Register

Developers Planet

Your answer is one click away!

Dejan February 2016

XSLT generate random ID ( letters or numbers or both)

This is my code which is working, it seems it uses version 1.0 but I am not sure if some other version can be used also? Now I need to add just one more element which will have some unique ID sent below the STATUS element, for example CORRELATIONID. How to add it in most simple way? I read something similar for version 2.0 but I am not sure if this is applicable to my code so please tell me what should I do? I am using solely XSLT not with C# or anything similar. Thank you

<?xml version='1.0'?> 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:max="http://www.ibm.com/maximo"> 
  <xsl:template match="/"> 
    <max:SyncMXWO Destination="SCCD" Action="urn:processDocument"> 
        <xsl:apply-templates select="UpdateTaskAssignmentEx/Task" />
  <xsl:template match="Task"> 
    <max:WONUM><xsl:value-of select="CallID"/></max:WONUM> 


Martin Honnen February 2016

I think using

  <xsl:template match="Task"> 
    <max:WONUM><xsl:value-of select="CallID"/></max:WONUM> 
    <CORRELATIONID><xsl:value-of select="generate-id()"/></CORRELATIONID>

should suffice to generate a unique id for each Task element you process in a single run of your XSLT stylesheet.

Post Status

Asked in February 2016
Viewed 2,522 times
Voted 7
Answered 1 times


Leave an answer

Quote of the day: live life