Showing posts with label Custom Transformation. Show all posts
Showing posts with label Custom Transformation. Show all posts

Monday, July 25

XSLT Functions with Examples

 XSLT Functions with Examples


Always remember while you are coding XSL Transformation, your input for your xsl is XML. 
i.e. your XSL code is based on the XML.

Below are most commonly used XSLT coding functions and methods. This is not an exhaustive list though.

How to Declare a variable:

<xsl:variable name="Newline" select="'&#xa;'"/>
<xsl:variable name="Tab" select="'&#9;'"/>
                <xsl:variable name="NumberFormat" select="'0.00'"/>
                <xsl:variable name="DateFormat" select="'[M01]/[D01]/[Y0001]'"/>
                <xsl:variable name="Pipe" select="'|'"/>
                <xsl:variable name="SplChar" select="'$@!%^&*()- '"/>
                <xsl:variable name="FillerZeros" select="'0000000000000000000000'"/>


How to use the variable which was declared: [Use $]

          <xsl:value-of select="$Newline"/>


Simple Text:
    <xsl:text>Test</xsl:text>


Concat Function:

   Example1:    <xsl:value-of select="concat(wd:Email,$Pipe)"/>
   Example2: <xsl:value-of select="concat('Y',$Pipe)"/>


Translate Function: [Use when you want to replace something]

       <xsl:value-of select="translate(wd:phone, '+().- ', '')" />


Sort Usage:

        <xsl:sort select="wd:Location"/>  


String-length Function:

         <xsl:when test="string-length(wd: Zip) = 8">  
Your Values Here
         </xsl:when>


Exists Function:

           <xsl:when test="exists(wd:Primary_Email)">   
Your Values Here
           </xsl:when>


Count Function:

   Example 1:        <xsl:value-of select="count(//wd:Report_Entry)"/>
   Example 2:        <xsl:value-of select= "count (//wd:Report_Entry[wd:Benefits/wd:Coverage='Family']/wd:Dependents)"/>


Format Date Function:

     Example 1:   <xsl:value-of select="format-date(current-date(),'[Y0001]-[M01]-[D01]')"/>
     Example 2:   <xsl:value-of select="format-date(wd:DateOfBirth,'[Y0001][M01][D01]')"/>


Format Number Function:

    <xsl:value-of select="format-number(wd:amount,$numberFormat)"/>


Substring Function:

         <xsl:value-of select="substring(wd:Work_Phone,3,10)"/>


Substring Before Function:

        <xsl:value-of select="substring-before(wd:Division/@wd:Descriptor,':')"/>


If Condition:

    <xsl:if test="wd:Gender = 'M'">
             .
             .            
            Your code here
             .
             .
    </xsl:if>


Choose and When Function:

  <xsl:choose> 
             <xsl:when test="(wd:Worker_Status = 'On Leave')"> 
                     <xsl:value-of select="'L'"/> 
             </xsl:when>
             <xsl:otherwise> 
                     <xsl:value-of select="'A'"/> 
             </xsl:otherwise> 
 </xsl:choose>


'For' Loop Function:

    Example 1:

   <xsl:for-each select="wd:Report_Data/wd:Report_Entry">
             .
             .            
            Your code here
             .
             .
       </xsl:for-each> 

    Example 2: [Using Group-by]

        <xsl:for-each-group select="wd:Report_Data/wd:Report_Entry" group-by="wd:Location">
             .
             .            
            Your code here
             .
             .
       </xsl:for-each> 


Other Text conditions in When Fuction:

Condition 1:
          <xsl:when test="(wd:Class_Item = '001' or wd:Class_Item = '002')">     
Your Values Here
  </xsl:when>

Condition 2:
         <xsl:when test="(wd:Benefits[1]/wd:Enrolment_Date) != ''">
Your Values Here
         </xsl:when> 

Condition 3:
         <xsl:when test="(wd:Class_Item = '002' and wd:Benefit_Changes[1]/wd:SubType ='T')">    
Your Values Here
         </xsl:when>


Template Declaration and Usage:

Calling Templates -

    <xsl:template match="/">
        <xsl:call-template name="HeaderRecord"/>
        <xsl:call-template name="DetailRecords"/>
    </xsl:template>

Defining Template -

    <xsl:template name="HeaderRecord">
             .
             .            
            Your code here
             .
             .
    </xsl:template>

Friday, April 17

Integrations: Workday XSL Coding Tips

Workday XSL Coding Tips


Using Variables (Declaration) :


<xsl:variable name="NEWLINE" select="'&#xa;'"/>
<xsl:variable name="PIPE" select="'|'"/>   [Use the delimiter that you would like to see in the output. Examples: Comma(,), Tab (    ), Pipe(|), SemiColon(;) ]
               <xsl:variable name="Record1" select="'C'"/>
               <xsl:variable name="Record2" select="'S'"/>

Using your Variable: (for above)


              <xsl:value-of select="$NEWLINE"/> [This takes the cursor to next line]
              <xsl:value-of select="$PIPE"/>  [This prints | ]
      <xsl:value-of select="$Record1"/>     [This prints C]
      <xsl:value-of select="$Record2"/>     [This prints S]


Using Fillers (Declaration):

    <xsl:variable name="Filler_Blank" select="'                                                                                                                            '"/>
            <xsl:variable name="Filler_Zeros" select="'0000000000000000000000'"/>


Using your Fillers and Substring Function: (for above)

             <xsl:value-of select="substring($Filler,1,10)"/>           [This prints 10 spaces, if you say 15 then it will print 15 spaces ]
             <xsl:value-of select="substring($Filler_Zeros,1,4)"/>  [This prints 0000 as you said 4]


Using Plain Text:


<xsl:value-of select="'TEST'"/>

Using Comment:


<!--  Your Comment Here  -->  

Using Choose:


    <xsl:choose>
<xsl:when test=" wd:Gender = 'Male' ">
   <xsl:value-of select="'M'"/>
        </xsl:when>
<xsl:when test=" wd:Gender = 'Female' ">
   <xsl:value-of select="'F'"/>
        </xsl:when>
        <xsl:otherwise>
                  <xsl:value-of select="'U'"/>
        </xsl:otherwise>
    </xsl:choose>

Using For:


<xsl:for-each select="wd:Report_Data/wd:Report_Entry">

          <Your Lines of code here>

        </xsl:for-each>

Using Templates:


    <xsl:template match="/">
        <xsl:call-template name="HeaderRecord"/>
        <xsl:call-template name="DetailRecords"/>
        <xsl:call-template name="TrailerRecord"/>
    </xsl:template>

    <xsl:template name="HeaderRecord">
          <Your Lines of code here>
    </xsl:template>

    <xsl:template name="DetailRecords">
          <Your Lines of code here>
    </xsl:template>

    <xsl:template name="TrailerRecord">
          <Your Lines of code here>
    </xsl:template>


Wednesday, April 15

Integrations: Workday XML - XSLT Sample codes

Use the below sample code to start with your XSLT journey. I made it as simple as possible for you to understand and get going.

xml Sample:


<?xml version="1.0" encoding="UTF-8"?>
<wd:Report_Data xmlns:wd="urn:com.workday.report/WD_Sample_Report">
  <wd:Report_Entry>
    <wd:Employee_ID>1234</wd:Employee_ID>
    <wd:firstName>Steve</wd:firstName>
    <wd:lastName>Morgan</wd:lastName>
    <wd:Age>56</wd:Age>
  </wd:Report_Entry>
  <wd:Report_Entry>
    <wd:Employee_ID>1235</wd:Employee_ID>
    <wd:firstName>Logan</wd:firstName>
    <wd:lastName>McNeil</wd:lastName>
    <wd:Age>40</wd:Age>
  </wd:Report_Entry>
  <wd:Report_Entry>
    <wd:Employee_ID>1236</wd:Employee_ID>
    <wd:firstName>Joy</wd:firstName>
    <wd:lastName>Banks</wd:lastName>
    <wd:Age>42</wd:Age>
  </wd:Report_Entry>
</wd:Report_Data>

xslt Sample:


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:wd="urn:com.workday.report/WD_Sample_Report" version="2.0">

<xsl:output method="text" indent="no"/>
<xsl:strip-space elements="*"/>

<xsl:variable name="NEWLINE" select="'&#xa;'"/>
<xsl:variable name="PIPE" select="'|'"/>

<xsl:template match="/">
    <!-- Header Record --> 
    <xsl:text>Employee ID</xsl:text>
        <xsl:value-of select="$PIPE"/>
<xsl:text>First Name</xsl:text>
        <xsl:value-of select="$PIPE"/>
<xsl:text>Last Name</xsl:text>
        <xsl:value-of select="$PIPE"/>
<xsl:text>Age</xsl:text>
<xsl:value-of select="$NEWLINE"/> 
<xsl:for-each select="wd:Report_Data/wd:Report_Entry">
    <!-- Detail Record --> 
        <xsl:value-of select="wd:Employee_ID"/>
                <xsl:value-of select="$PIPE"/>
    <xsl:value-of select="wd:firstName"/>
                <xsl:value-of select="$PIPE"/>
    <xsl:value-of select="wd:lastName"/>
        <xsl:value-of select="$PIPE"/>
    <xsl:value-of select="wd:Age"/>
        <xsl:value-of select="$NEWLINE"/>
</xsl:for-each>

    <!-- Trailer Record --> 
<xsl:text>End of Records</xsl:text>
 
</xsl:template>
</xsl:stylesheet>

Test

Use XLS Transformer to test the above code.

Result:


Employee ID|First Name|Last Name|Age| 1234|Steve|Morgan|56 1235|Logan|McNeil|40 1235|Joy|Banks|42 End of Records

Tuesday, April 14

Integrations: XML - XSL Tranformation - Free online Formatter

Workday XML - XSL Tranformation

Abbrevations:

XML Stands for eXtensible Markup Language
XSL Stand for eXtensible Stylesheet Language (Styling language for XML)
XSLT stands for XSL Transformations.


If you do not have any xsl transformers installed on your local machine,  I suggest you to use online free formatter to test your xml to xslt conversion and see how your end data looks like after applying your transformation code.

Follow the below three steps, to transform your xml.
  1. XML input - Copy Paste / Attach your generated workday xml code.
  2. XSL input  - Copy Paste / Attach your own custom code in relation to your xml.
  3. Transform XML - Click this to see the result.
Click the below link to format your code.


Just a word of caution: Make sure, you avoid any confidential data in your xml file while using free online formatters

Monday, June 17

Workday EIB - Inbound

EIB - Inbound


The Workday Enterprise Interface Builder (EIB) tool provides an easy-to-use graphical and guided interface to define inbound and outbound integrations without requiring any programming. 

There are two types of EIBs - Inbound and Outbound. I encourage you to first read EIB Outbound. Here we will discuss about EIB Inbound.

The Inbound EIB is just like an Outbound EIB but the way of doing is just a mirror-image. When you want to load the data into Workday from different sources then you would use Inbound EIB. Bulk loads can be done through this EIB Inbounds.

Workday generates a default spreadsheet for the most common set of bulk update operations. These operations include mass payroll, time off, benefit adjustments, etc.

We need to download the generated spreadsheet, add data to it, and then use EIB to import it to the system and update all the records. If your data spreadsheet that you have loaded have any issues, it will notify you of any errors in the load process, and will even highlight which data in the input spreadsheet caused the issue.

Here are the three steps / phases involved in creating an Inbound EIB:

Inbound EIB

1. Get Data

Here in Get Data you define how you retrieve the data. This means how you input the data to workday. This Phase is very important as this defines how your transform and delivery phases are going to be, like what defaults it will pass on.

Below are the different formats that Workday accepts : Attach File at Launch, Amazon Simple Storage Service, FTP/SSL, REST URL, SFTP.

It is important to select the Web Service operation as to where exactly you want to load the data within Workday. For example if you are updating personal information or emergency contacts or one-time payments etc.,
Also there are different file types available to use
  • Web Service Spreadsheet Template (Most commonly used), 
  • Custom Object Spreadsheet Template (Used when loading the data for Custom Objects), 
  • Predefined Template (less likely used)

2. Transform

Transform will be like using the default options, as this section depends up on the Get Data file type selection.

Custom Object Transformation - By Default and only option when selected Custom Object Spreadsheet Template in Get Data.
Template Model - By Default and only option when selected Web Service Spreadsheet Template in Get Data.

3. Deliver

Workday Web Service Operation is the default Delivery method for Web Services.
Custom Object is the default Delivery Method for Custom Objects.
Use the defaults and proceed.
---
Once you configure your EIB, its time to generate the spreadsheet template.

Go to Related Actions >> Template Model >> Generate Spreadsheet Template.  -- This will generate the excel sheet for the Web Service that you have selected.

These delivered spreadsheets can also be customized so that you can specifically identify the columns you need, hide irrelevant fields, etc. Use the Edit and View options in the Template model to edit your spreadsheet template. Once you have your data ready in the spreadsheet, you can launch your integration with below navigation.

Go to Related Actions >> Integration >> Launch / Schedule >> Integration Attachment 
Value Type: Specify Value
Value: Create Integration Attachment -- Here you will attach your data spreadsheet


Configuration of a Sample Inbound EIB:


Create EIB Task



Guided Path:


Get Data


Set Web Service Operation in Get data



 Transform


Deliver


Generate Spreadsheet from Template Model


Additional Reads

Sunday, June 16

Workday EIB - Outbound

EIB Outbound


The Workday Enterprise Interface Builder (EIB) tool provides an easy-to-use graphical and guided interface to define inbound and outbound integrations without requiring any programming. 

There are two types of EIBs - Inbound and Outbound. Here we will discuss about EIB Outbound.

Outbound EIBs are used to extract data from the Workday system and send it to external system that could be a third party, vendor, legacy system or just a simple attachment. Mostly they are used to send a file to an external destination via ftp. 

Here are the three steps / phases involved in creating an Outbound EIB:


Outbound EIB


1. Get Data

In "Get Data" Phase, we will identify the data source. In 90% of the cases, this is will be a custom report and it should be an advanced report which acts as Report as a Service (RaaS). 

If you are specifying a Report Data Source, you can choose the format in which the report results can be delivered. 

Below are the different output formats: XML, simplified XML, CSV, JSON, GData, or RSS

You can also use Workday Web Service endpoint as the data source for an EIB.

2. Transform

This is used to transform the data from one format to other. You can either choose from the set of predefined (XSL) transforms, or specify a new one that you will define. The out-of-the-box options include transforms to CSV and Excel formats.This is an optional step if you do not want to transform anything. By default your EIB will produce an XML format.

When you use Custom Report as your Data source, you can make use of the Delivered Transformation or Custom Transformation. And when you use Web Service on the other hand, you will have only one option Custom Transformation.
Like said above, you can use None option if you don't want to transform.

New Custom Report Transformation: This is the delivered one's, it will allow you to use it for the first time, it will automatically create the transformation for your EIB. One you select this option, you will not see this later, It will become Custom Report Transformation.

Custom Report Transformation: Same as above. 

Custom Transformation: This is the custom transformation where you will write a XSLT for your XML and upload the same.

3. Deliver

The output resulting from executing the EIB can either be attached back to your tenant, or alternatively delivered to an external endpoint. 

Supported Delivery Methods are: Workday Attachment, FTP, HTTP/SSL, FTP/SSL, FTP, Email, AS2 

You can configure multiple delivery options for different tenants, For example - for production you may configure PGP Production Key and for non production tenants you may configure PGP non-Production Key. Additionally you can use Workday attachment to be delivered to the local tenant where the EIB is ran.

Configuration of a Sample Outbound EIB:


Create EIB task


Guided Path


Get Data


Transform


Deliver


Additional Reads: