xslt-2.0workday-api

XSLT adding report name on output SOAP request


I am trying to read a report to generate an SOAP request using XSLT transformation. The XSLT keeps on adding report name on SOAP env.

Here is my XSLT :

<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wd="urn:com.workday.report/CR_INT433_Employee_Home_Address" >
    <xsl:template match="/">
        <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <env:Body>
                <xsl:for-each select="wd:Report_Data/wd:Report_Entry">
                    <bsvc:Maintain_Contact_Information_for_Person_Event_Request xmlns:bsvc="urn:com.workday/bsvc" bsvc:Add_Only="true" bsvc:version="v43.0">
                        <bsvc:Business_Process_Parameters>
                            <bsvc:Auto_Complete>true</bsvc:Auto_Complete>
                            <bsvc:Run_Now>true</bsvc:Run_Now>
                        </bsvc:Business_Process_Parameters>
                        <bsvc:Maintain_Contact_Information_Data>
                            <bsvc:Worker_Reference>
                                <bsvc:ID bsvc:type="Employee_ID">
                                    <xsl:value-of select="wd:Employee_ID"/>
                                </bsvc:ID>
                            </bsvc:Worker_Reference>
                            <bsvc:Effective_Date>
                                <xsl:value-of select="format-date(wd:Hire_Date, '[Y0001]-[M01]-[D01]')"/>
                            </bsvc:Effective_Date>
                            <bsvc:Worker_Contact_Information_Data>
                                <bsvc:Address_Data bsvc:Do_Not_Replace_All="true">
                                    <bsvc:Country_Reference>
                                        <bsvc:ID bsvc:type="ISO_3166-1_Alpha-3_Code">
                                            <xsl:value-of select="wd:Primary_Home_Address/wd:Country"/>
                                        </bsvc:ID>
                                    </bsvc:Country_Reference>
                                    <bsvc:Address_Line_Data bsvc:Type="ADDRESS_LINE_1">
                                        <xsl:value-of select="wd:Primary_Home_Address/wd:Address_Line_1"/>
                                    </bsvc:Address_Line_Data>
                                    <bsvc:Address_Line_Data bsvc:Type="ADDRESS_LINE_2">
                                        <xsl:value-of select="wd:Primary_Home_Address/wd:Address_Line_2"/>
                                    </bsvc:Address_Line_Data>
                                    <bsvc:Municipality>
                                        <xsl:value-of select="wd:Primary_Home_Address/wd:City"/>
                                    </bsvc:Municipality>
                                    <bsvc:Country_Region_Reference>
                                        <bsvc:ID bsvc:type="ISO_3166-2_Code">
                                            <xsl:value-of select="wd:Primary_Home_Address/wd:State"/>
                                        </bsvc:ID>
                                    </bsvc:Country_Region_Reference>
                                    <bsvc:Postal_Code>
                                        <xsl:value-of select="wd:Primary_Home_Address/wd:Postal"/>
                                    </bsvc:Postal_Code>
                                    <bsvc:Usage_Data bsvc:Public="0">
                                        <bsvc:Type_Data>
                                            <bsvc:Type_Reference bsvc:Primary="1">
                                                <bsvc:ID bsvc:type="WID">1f27f250dfaa4724ab1e1617174281e4</bsvc:ID>
                                                <bsvc:ID bsvc:type="Communication_Usage_Type_ID">WORK</bsvc:ID>
                                            </bsvc:Type_Reference>
                                        </bsvc:Type_Data>
                                    </bsvc:Usage_Data>
                                </bsvc:Address_Data>
                            </bsvc:Worker_Contact_Information_Data>
                        </bsvc:Maintain_Contact_Information_Data>
                    </bsvc:Maintain_Contact_Information_for_Person_Event_Request>
                </xsl:for-each>
            </env:Body>
        </env:Envelope>
    </xsl:template>
</xsl:stylesheet>

The output is :

<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wd="urn:com.workday.report/CR_INT433_Employee_Home_Address" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> env:Body

but the expectation is

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wd="urn:com.workday/bsvc"> env:Body

how can i get rid of xmlns:wd="urn:com.workday.report/CR_INT433_Employee_Home_Address" from envelope after transformation?


Solution

  • You have to tell the XSLT processor not to include the namespace in the output, if it is not used. Add the directive exclude-result-prefixes in the XSL header. I've changed your XSL accordingly and it seems to work now and not generating xmlns:wd="urn:com.workday.report/CR_INT433_Employee_Home_Address".

    <?xml version='1.0' encoding="UTF-8"?>
    <xsl:stylesheet version="2.0" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
        xmlns:wd="urn:com.workday.report/CR_INT433_Employee_Home_Address" 
        xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:bsvc="urn:com.workday/bsvc"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        exclude-result-prefixes="wd xsd">
    
        <xsl:template match="/">
        [...your remaining XSL transformation code...]  
    </xsl:stylesheet>