Integration

Get Involved. Join the Conversation.

Topic

    Raghavendra Manchigiah
    XSLT transformation
    Topic posted June 12, 2019 by Raghavendra ManchigiahBlue Ribbon: 750+ Points, tagged Cloud, Connection, Database, Integration, Mapping 
    67 Views, 3 Comments
    Title:
    XSLT transformation
    Summary:
    Select a distinct value from a DB resultset array
    Content:

    Hi Folks,

    Our requirement is to read data from a MS SQL server DB and transform to fusion FBDI templates to trigger an ESS job. Data that comes from SQL server will be the resultset from select statements . Is it possible to pick distinct elements in an array using the XSLT functions in OIC . Kindly share examples if available.

    E.G : Code[] array with multiple lines and columns might have lines with one column that has the same value . How do i pick the distinct value?

    909950031      
    909950031
    909950031
    998765432
    909950031
    123456789
    909950031

    I need the XSLT to return

    909950031

    009765432  

    123456789

    Regards,

    Raghvendra

    Inspirage

     

    Version:
    19

    Comment

     

    • Kunal Sonje

      Hi Raghvendra,

      Check current-grouping-key() function. Make sure function is prefixed with fn.

      You can check here for more details.

      Thanks,

      Kunal

    • Hemanth Lakkaraju

      There are no inbuilt functions, but you can write custom xslt to achieve this.

      Please provide a sample request xml and expected response xml to help you if needed.

    • Kanchankumar Khedkar

      you can achieve this in multiple ways 

      1. using distinct-values() functions. 

      <items>
         <xsl:for-each select="distinct-values(/code/id)">
              <item>
      <xsl:value-of select="." />
              </item>
          </xsl:for-each>
      </items>
       
      2. using xsl:for-each-group and then printing group key.
      <items>
         <xsl:for-each-group select="/code" group-by="id">
      <item>
      <xsl:value-of select="current-grouping-key()" />
              </item>
        </xsl:for-each-group>
      </items>
       
      One of these should help. 
      None of this is possible using oic mapper. You can write custom xslt and import it it should work.