0

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'?> 
<xsl:stylesheet  
  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"> 
      <max:MXWOSet>
      <max:WORKORDER>
        <xsl:apply-templates select="UpdateTaskAssignmentEx/Task" />
      </max:WORKORDER>
      </max:MXWOSet> 
    </max:SyncMXWO> 
  </xsl:template> 
  <xsl:template match="Task"> 
    <max:WONUM><xsl:value-of select="CallID"/></max:WONUM> 
    <max:STATUS>COMPLETE</max:STATUS>
  </xsl:template> 
</xsl:stylesheet>
Veljko
  • 1,708
  • 12
  • 40
  • 80
  • Which XSLT processor are you using? If you don't know, find out - see here how: http://stackoverflow.com/questions/25244370/how-can-i-check-which-xslt-processor-is-being-used-in-solr/25245033#25245033 – michael.hor257k Feb 08 '16 at 22:22
  • hi michael it is not maybe version 1.0 like it is written at the head on the XSLT message? – Veljko Feb 08 '16 at 22:24
  • No, that doesn't mean anything about what your processor **can** do. -- Besides, there's no random function in XSLT 1.0 or 2.0. You will need to use an extension function - if your processor supports extensions. – michael.hor257k Feb 08 '16 at 22:26
  • Hi Michael result is Microsoft and 1. Please help me what should I do since I am not so experienced with XSLT – Veljko Feb 08 '16 at 22:35
  • You will need to use one of the languages that Microsoft supports as an extension - see: https://msdn.microsoft.com/en-us/library/533texsx%28v=vs.110%29.aspx – michael.hor257k Feb 08 '16 at 22:44
  • michael I am really not so skilled I do not know what shol I do can you please give me example how guid should be implemented? if you can please? – Veljko Feb 08 '16 at 22:48
  • I am afraid I don't know any more about it than what I wrote. – michael.hor257k Feb 08 '16 at 22:51

1 Answers1

0

I think using

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

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

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
  • I don't know about that. This question is tagged `guid`. The IDs generated here will be unique only within the scope of a single transformation - certainly not globally. – michael.hor257k Feb 09 '16 at 13:20
  • I did not see that tag, I only went by the text asking for a random id, letters or numbers or both. Let's see what the original poster says, generating guids is certainly not done by `generate-id()`. – Martin Honnen Feb 09 '16 at 14:34
  • Hi Martin and Michael thank you for your involvment. this message is sent toward the external system through the ESB integration. ESB system expects message where unique ID will be generated for that message which will be sent and we use XSLT to define the message. We need for example in that CORRELATIONID to send unique ID (regardles if it contains only letters or only numbers or both but the main point is that ESB system should not receive message with same CORRELATIONID value so we need some ID value which will not be repeated in short time interval I know in other languages it is possible – Veljko Feb 09 '16 at 16:52
  • Which XSLT processor from Microsoft is that, is it .NET based (`XslCompiledTransform` or `XslTransform`) or COM based (a version of MSXML)? And you say `I am using solely XSLT not with C# or anything similar`, does that mean you don't call the XSLT processor with .NET code? – Martin Honnen Feb 09 '16 at 18:52