Created
July 14, 2026 20:30
-
-
Save r4hulp/9daa5fe583c327917510bcb3db466a58 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <xsl:stylesheet version="1.0" | |
| xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
| xmlns:wd="urn:com.workday.report/CR_VS_NEW_HIRES" | |
| exclude-result-prefixes="wd"> | |
| <!-- Direct CSV/text output for Outbound EIB --> | |
| <xsl:output | |
| method="text" | |
| encoding="UTF-8" | |
| omit-xml-declaration="yes"/> | |
| <xsl:strip-space elements="*"/> | |
| <xsl:template match="/"> | |
| <!-- CSV header --> | |
| <xsl:text>Employee_ID,Legal_First_Name,Legal_Last_Name,Location_Country,Language,Work_Email,Home_Email,Job_Profile,Hire_Date,Termination_Date,Active,Worker_Type</xsl:text> | |
| <xsl:text> </xsl:text> | |
| <!-- One CSV row for each report entry --> | |
| <xsl:for-each select="wd:Report_Data/wd:Report_Entry"> | |
| <xsl:variable name="country" | |
| select="normalize-space(wd:Employee_s_Country_ISO_Code)"/> | |
| <xsl:variable name="hireDate" | |
| select="normalize-space(wd:Hire_Date)"/> | |
| <!-- Your XML alias uses lowercase termination_date --> | |
| <xsl:variable name="terminationDate" | |
| select="normalize-space(wd:termination_date)"/> | |
| <!-- Employee ID --> | |
| <xsl:call-template name="csv-field"> | |
| <xsl:with-param name="value" | |
| select="normalize-space(wd:Employee_ID)"/> | |
| </xsl:call-template> | |
| <xsl:text>,</xsl:text> | |
| <!-- Legal first name --> | |
| <xsl:call-template name="csv-field"> | |
| <xsl:with-param name="value" | |
| select="normalize-space(wd:Legal_First_Name)"/> | |
| </xsl:call-template> | |
| <xsl:text>,</xsl:text> | |
| <!-- Legal last name --> | |
| <xsl:call-template name="csv-field"> | |
| <xsl:with-param name="value" | |
| select="normalize-space(wd:Legal_Last_Name)"/> | |
| </xsl:call-template> | |
| <xsl:text>,</xsl:text> | |
| <!-- Location country, printed exactly as received --> | |
| <xsl:call-template name="csv-field"> | |
| <xsl:with-param name="value" select="$country"/> | |
| </xsl:call-template> | |
| <xsl:text>,</xsl:text> | |
| <!-- Language derived from country --> | |
| <xsl:variable name="language"> | |
| <xsl:choose> | |
| <xsl:when test="$country = 'US'">ENG</xsl:when> | |
| <xsl:when test="$country = 'NL'">DUT</xsl:when> | |
| <xsl:when test="$country = 'DE'">GER</xsl:when> | |
| <xsl:when test="$country = 'FR'">FRE</xsl:when> | |
| <xsl:otherwise>NA</xsl:otherwise> | |
| </xsl:choose> | |
| </xsl:variable> | |
| <xsl:call-template name="csv-field"> | |
| <xsl:with-param name="value" select="$language"/> | |
| </xsl:call-template> | |
| <xsl:text>,</xsl:text> | |
| <!-- Work email is in the Descriptor attribute --> | |
| <xsl:call-template name="csv-field"> | |
| <xsl:with-param name="value" | |
| select="normalize-space( | |
| wd:Email_-_Work/@wd:Descriptor | |
| )"/> | |
| </xsl:call-template> | |
| <xsl:text>,</xsl:text> | |
| <!-- Home email is in the Descriptor attribute --> | |
| <xsl:call-template name="csv-field"> | |
| <xsl:with-param name="value" | |
| select="normalize-space( | |
| wd:Email_-_Home/@wd:Descriptor | |
| )"/> | |
| </xsl:call-template> | |
| <xsl:text>,</xsl:text> | |
| <!-- Job profile --> | |
| <xsl:call-template name="csv-field"> | |
| <xsl:with-param name="value" | |
| select="normalize-space( | |
| wd:Job_Profile/@wd:Descriptor | |
| )"/> | |
| </xsl:call-template> | |
| <xsl:text>,</xsl:text> | |
| <!-- Hire date formatted as DDMMYYYY --> | |
| <xsl:variable name="formattedHireDate"> | |
| <xsl:call-template name="format-date"> | |
| <xsl:with-param name="date" select="$hireDate"/> | |
| </xsl:call-template> | |
| </xsl:variable> | |
| <xsl:call-template name="csv-field"> | |
| <xsl:with-param name="value" | |
| select="$formattedHireDate"/> | |
| </xsl:call-template> | |
| <xsl:text>,</xsl:text> | |
| <!-- Termination date formatted as DDMMYYYY --> | |
| <xsl:variable name="formattedTerminationDate"> | |
| <xsl:call-template name="format-date"> | |
| <xsl:with-param name="date" | |
| select="$terminationDate"/> | |
| </xsl:call-template> | |
| </xsl:variable> | |
| <xsl:call-template name="csv-field"> | |
| <xsl:with-param name="value" | |
| select="$formattedTerminationDate"/> | |
| </xsl:call-template> | |
| <xsl:text>,</xsl:text> | |
| <!-- Active converted to Boolean --> | |
| <xsl:choose> | |
| <xsl:when test=" | |
| translate( | |
| normalize-space(wd:Active), | |
| 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', | |
| 'abcdefghijklmnopqrstuvwxyz' | |
| ) = 'active' | |
| "> | |
| <xsl:text>true</xsl:text> | |
| </xsl:when> | |
| <xsl:otherwise> | |
| <xsl:text>false</xsl:text> | |
| </xsl:otherwise> | |
| </xsl:choose> | |
| <xsl:text>,</xsl:text> | |
| <!-- Worker type printed exactly as received --> | |
| <xsl:call-template name="csv-field"> | |
| <xsl:with-param name="value" | |
| select="normalize-space( | |
| wd:Worker_Type/@wd:Descriptor | |
| )"/> | |
| </xsl:call-template> | |
| <!-- End of this worker row --> | |
| <xsl:text> </xsl:text> | |
| </xsl:for-each> | |
| </xsl:template> | |
| <!-- | |
| Convert either: | |
| 2022-02-01 | |
| or | |
| 2022-02-01-08:00 | |
| into: | |
| 01022022 | |
| --> | |
| <xsl:template name="format-date"> | |
| <xsl:param name="date"/> | |
| <xsl:choose> | |
| <xsl:when test=" | |
| string-length(normalize-space($date)) >= 10 | |
| and substring($date, 5, 1) = '-' | |
| and substring($date, 8, 1) = '-' | |
| "> | |
| <xsl:value-of select="substring($date, 9, 2)"/> | |
| <xsl:value-of select="substring($date, 6, 2)"/> | |
| <xsl:value-of select="substring($date, 1, 4)"/> | |
| </xsl:when> | |
| <!-- Missing or invalid date becomes blank --> | |
| <xsl:otherwise/> | |
| </xsl:choose> | |
| </xsl:template> | |
| <!-- | |
| Surround every field with quotation marks. | |
| Missing values become "". | |
| --> | |
| <xsl:template name="csv-field"> | |
| <xsl:param name="value"/> | |
| <xsl:text>"</xsl:text> | |
| <xsl:call-template name="escape-quotes"> | |
| <xsl:with-param name="value" | |
| select="string($value)"/> | |
| </xsl:call-template> | |
| <xsl:text>"</xsl:text> | |
| </xsl:template> | |
| <!-- | |
| Escape embedded quotation marks for CSV: | |
| " becomes "" | |
| --> | |
| <xsl:template name="escape-quotes"> | |
| <xsl:param name="value"/> | |
| <xsl:choose> | |
| <xsl:when test="contains($value, '"')"> | |
| <xsl:value-of | |
| select="substring-before($value, '"')"/> | |
| <xsl:text>""</xsl:text> | |
| <xsl:call-template name="escape-quotes"> | |
| <xsl:with-param name="value" | |
| select="substring-after( | |
| $value, | |
| '"' | |
| )"/> | |
| </xsl:call-template> | |
| </xsl:when> | |
| <xsl:otherwise> | |
| <xsl:value-of select="$value"/> | |
| </xsl:otherwise> | |
| </xsl:choose> | |
| </xsl:template> | |
| </xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment