Last active
July 17, 2026 12:14
-
-
Save r4hulp/90dbed8b11dfb4eeaf2dbe55dd47e7d8 to your computer and use it in GitHub Desktop.
clean-xslt-emp-fixedwidth-txt
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="2.0" | |
| xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
| xmlns:ws="urn:com.workday/workersync" | |
| xmlns:xtt="urn:com.workday/xtt" | |
| exclude-result-prefixes="xsl ws"> | |
| <xsl:output | |
| method="xml" | |
| encoding="UTF-8" | |
| omit-xml-declaration="yes"/> | |
| <xsl:template match="/"> | |
| <!-- Each Record becomes one line in the TXT file --> | |
| <File xtt:separator=" "> | |
| <xsl:for-each select="/ws:Worker_Sync/ws:Worker"> | |
| <!-- | |
| Employee ID becomes the target shown against | |
| warnings in the Integration Event. | |
| --> | |
| <Record | |
| xtt:target="{normalize-space( | |
| ws:Summary/ws:Employee_ID | |
| )}"> | |
| <!-- ================================================= | |
| 1. Employee ID – length 10 | |
| Standard XTT truncation warning | |
| ================================================= --> | |
| <Employee_ID | |
| xtt:fixedLength="10" | |
| xtt:align="left" | |
| xtt:paddingCharacter=" " | |
| xtt:reportTruncation="warning"> | |
| <xsl:value-of | |
| select="normalize-space( | |
| ws:Summary/ws:Employee_ID | |
| )"/> | |
| </Employee_ID> | |
| <!-- ================================================= | |
| 2. Legal First Name – length 20 | |
| Standard XTT truncation warning | |
| ================================================= --> | |
| <Legal_First_Name | |
| xtt:fixedLength="20" | |
| xtt:align="left" | |
| xtt:paddingCharacter=" " | |
| xtt:reportTruncation="warning"> | |
| <xsl:value-of | |
| select="normalize-space( | |
| ws:Personal/ | |
| ws:Name_Data/ | |
| ws:First_Name | |
| )"/> | |
| </Legal_First_Name> | |
| <!-- ================================================= | |
| 3. Legal Last Name – length 20 | |
| Standard XTT truncation warning | |
| ================================================= --> | |
| <Legal_Last_Name | |
| xtt:fixedLength="20" | |
| xtt:align="left" | |
| xtt:paddingCharacter=" " | |
| xtt:reportTruncation="warning"> | |
| <xsl:value-of | |
| select="normalize-space( | |
| ws:Personal/ | |
| ws:Name_Data/ | |
| ws:Last_Name | |
| )"/> | |
| </Legal_Last_Name> | |
| <!-- ================================================= | |
| 4. Date of Birth | |
| Input: YYYY-MM-DD | |
| Output: DDMMYYYY | |
| Fixed length: 10 | |
| Two spaces are added after the 8-character date. | |
| Standard XTT truncation warning. | |
| ================================================= --> | |
| <Date_of_Birth | |
| xtt:dateFormat="ddMMyyyy" | |
| xtt:fixedLength="10" | |
| xtt:align="left" | |
| xtt:paddingCharacter=" " | |
| xtt:reportTruncation="warning"> | |
| <xsl:value-of | |
| select="normalize-space( | |
| ws:Personal/ws:Birth_Date | |
| )"/> | |
| </Date_of_Birth> | |
| <!-- ================================================= | |
| 5. Home Address Country – length 2 | |
| Standard XTT truncation warning | |
| ================================================= --> | |
| <Home_Address_Country | |
| xtt:fixedLength="2" | |
| xtt:align="left" | |
| xtt:paddingCharacter=" " | |
| xtt:reportTruncation="warning"> | |
| <xsl:value-of | |
| select="normalize-space( | |
| ws:Personal/ | |
| ws:Address_Data/ | |
| ws:Country | |
| )"/> | |
| </Home_Address_Country> | |
| <!-- ================================================= | |
| 6. Work Location Country – length 2 | |
| Standard XTT truncation warning | |
| ================================================= --> | |
| <Work_Location_Country | |
| xtt:fixedLength="2" | |
| xtt:align="left" | |
| xtt:paddingCharacter=" " | |
| xtt:reportTruncation="warning"> | |
| <xsl:value-of | |
| select="normalize-space( | |
| ws:Position/ | |
| ws:Business_Site_Country | |
| )"/> | |
| </Work_Location_Country> | |
| <!-- ================================================= | |
| 7. Job Profile – length 15 | |
| Standard XTT truncation warning | |
| ================================================= --> | |
| <Job_Profile | |
| xtt:fixedLength="15" | |
| xtt:align="left" | |
| xtt:paddingCharacter=" " | |
| xtt:reportTruncation="warning"> | |
| <xsl:value-of | |
| select="normalize-space( | |
| ws:Position/ws:Job_Profile | |
| )"/> | |
| </Job_Profile> | |
| <!-- ================================================= | |
| 8. Hire Date | |
| Input: YYYY-MM-DD | |
| Output: DDMMYYYY | |
| Fixed length: 8 | |
| Standard XTT truncation warning | |
| ================================================= --> | |
| <Hire_Date | |
| xtt:dateFormat="ddMMyyyy" | |
| xtt:fixedLength="8" | |
| xtt:align="left" | |
| xtt:paddingCharacter=" " | |
| xtt:reportTruncation="warning"> | |
| <xsl:value-of | |
| select="normalize-space( | |
| ws:Status/ws:Hire_Date | |
| )"/> | |
| </Hire_Date> | |
| <!-- ================================================= | |
| 9. Manager ID – length 10 | |
| Standard XTT truncation warning | |
| ================================================= --> | |
| <Manager_ID | |
| xtt:fixedLength="10" | |
| xtt:align="left" | |
| xtt:paddingCharacter=" " | |
| xtt:reportTruncation="warning"> | |
| <xsl:value-of | |
| select="normalize-space( | |
| ws:Position/ | |
| ws:Supervisor/ | |
| ws:Supervisor_ID | |
| )"/> | |
| </Manager_ID> | |
| <!-- ================================================= | |
| 10. Custom Cost Center warning | |
| This warning is created only when the original | |
| Cost Center value exceeds 10 characters. | |
| xtt:omit prevents this helper element from being | |
| written into the TXT output. | |
| ================================================= --> | |
| <xsl:if test=" | |
| string-length( | |
| normalize-space( | |
| ws:Position/ | |
| ws:Organization_Data/ | |
| ws:Organization_Name | |
| ) | |
| ) > 10 | |
| "> | |
| <Cost_Center_Warning | |
| xtt:omit="true" | |
| xtt:severity="warning" | |
| xtt:target="{normalize-space( | |
| ws:Summary/ws:Employee_ID | |
| )}" | |
| xtt:message="Employee {normalize-space( | |
| ws:Summary/ws:Employee_ID | |
| )}: Cost Center exceeds the maximum length of 10 characters. Value truncated."> | |
| <xsl:value-of | |
| select="normalize-space( | |
| ws:Position/ | |
| ws:Organization_Data/ | |
| ws:Organization_Name | |
| )"/> | |
| </Cost_Center_Warning> | |
| </xsl:if> | |
| <!-- ================================================= | |
| 10. Cost Center output – length 10 | |
| No reportTruncation attribute here because the | |
| custom warning above replaces the standard warning. | |
| XTT fixedLength performs the truncation. | |
| ================================================= --> | |
| <Cost_Center | |
| xtt:fixedLength="10" | |
| xtt:align="left" | |
| xtt:paddingCharacter=" "> | |
| <xsl:value-of | |
| select="normalize-space( | |
| ws:Position/ | |
| ws:Organization_Data/ | |
| ws:Organization_Name | |
| )"/> | |
| </Cost_Center> | |
| </Record> | |
| </xsl:for-each> | |
| </File> | |
| </xsl:template> | |
| </xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment