XSLT XML转XML映射在Outbound EIB中多XPath字段失效求助
It looks like your XSLT works perfectly in your local studio but breaks when deployed to Workday's Outbound EIB—specifically, fields relying on multi-part XPath queries are coming up empty (even causing malformed closing tags in your output, which is likely a side effect of missing content). Let’s break down the likely causes and fix this step by step.
Key Observations
Your output shows empty <wd:Descriptor>, <wd:WID>, and <wd:Position_Time_Type> elements, which means the XPath expressions targeting these values aren’t resolving correctly in the EIB environment. This is almost always tied to environment-specific processing differences between your local studio and Workday’s EIB runtime.
Common Causes & Fixes
1. XSLT Version Compatibility
Workday’s EIB typically uses an XSLT 1.0 processor, but your stylesheet specifies version="2.0". Even though your code doesn’t use 2.0-specific features, this version mismatch can lead to unexpected behavior in strict 1.0 processors.
Fix: Downgrade your stylesheet to XSLT 1.0:
<xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:wd="urn:com.workday.report/Job_Requisition_Details" version="1.0" <!-- Updated from 2.0 --> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
2. Replace xsl:for-each with Template Matching
Nested xsl:for-each blocks can introduce context resolution issues in different processing environments. Template matching is more robust, aligns with XSLT’s declarative design, and reduces dependency on runtime context.
Rewritten Stylesheet with Templates:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:wd="urn:com.workday.report/Job_Requisition_Details" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:strip-space elements="*"/> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <body> <xsl:apply-templates select="wd:Report_Data/wd:Report_Entry"/> </body> </xsl:template> <xsl:template match="wd:Report_Entry"> <wd:Job_ID> <xsl:value-of select="wd:Job_ID"/> </wd:Job_ID> <wd:Job_Title> <xsl:value-of select="wd:Job_Title"/> </wd:Job_Title> <wd:Time_Type> <xsl:apply-templates select="wd:Time_Type"/> </wd:Time_Type> </xsl:template> <xsl:template match="wd:Time_Type"> <wd:Descriptor> <xsl:value-of select="@wd:Descriptor"/> </wd:Descriptor> <wd:WID> <xsl:value-of select="wd:ID[@wd:type='WID']"/> </wd:WID> <wd:Position_Time_Type> <xsl:value-of select="wd:ID[@wd:type='Position_Time_Type_ID']"/> </wd:Position_Time_Type> </xsl:template> </xsl:stylesheet>
3. Work Around Namespace Prefix Quirks
Occasionally, EIB processors have quirks with namespace prefix resolution. If the above fix doesn’t work, try namespace-agnostic XPath expressions that rely on local-name() and namespace-uri() to avoid prefix dependency:
Example for Attribute Selection:
<!-- Instead of @wd:Descriptor --> <xsl:value-of select="@*[local-name()='Descriptor' and namespace-uri()='urn:com.workday.report/Job_Requisition_Details']"/>
Example for Filtered ID Elements:
<!-- Instead of wd:ID[@wd:type='WID'] --> <xsl:value-of select="*[local-name()='ID' and namespace-uri()='urn:com.workday.report/Job_Requisition_Details'] [@*[local-name()='type' and namespace-uri()='urn:com.workday.report/Job_Requisition_Details']='WID']"/>
4. Verify Input XML Structure in EIB
Workday EIB sometimes wraps input XML in additional nodes (e.g., <Integration_Request>) that change the root path. Enable EIB logging to inspect the actual input XML being processed, then adjust your XPath expressions to match the real structure.
5. Double-Check EIB Configuration
Ensure:
- Your XSLT is correctly attached to the Outbound EIB transformation step.
- No pre-processing filters or steps are modifying the input XML before transformation.
- The
wdnamespace prefix is correctly mapped tourn:com.workday.report/Job_Requisition_Detailsin the EIB’s configuration settings.
Final Notes
Start with downgrading the XSLT version and switching to template matching—these are the most common fixes for EIB-specific XSLT issues. If the problem persists, use the namespace-agnostic XPath syntax or verify the input structure via EIB logs to confirm your paths are correct.
内容的提问来源于stack exchange,提问作者Jauvy Mahabague

