简体   繁体   中英

I have a problem with addressing a specific EDI 856 HL level in XSLT with Azure integration tools

I have an inbound 856 that looks like the following when decoded:

<X12_00401_856>
    <ST>
        <ST01>856</ST01>
        <ST02>0339</ST02>
    </ST>
    <BSN>
        <BSN01>00</BSN01>
        <BSN02>N975092</BSN02>
        <BSN03>20180911</BSN03>
        <BSN04>125200</BSN04>
    </BSN>
    <DTM>
        <DTM01>011</DTM01>
        <DTM02>20180911</DTM02>
    </DTM>
    <HLLoop1>
        <HL>
            <HL01>1</HL01>
            <HL03>S</HL03>
            <HL04>1</HL04>
        </HL>
        <N1Loop1>
            <N1>
                <N101>ST</N101>
                <N103>1</N103>
                <N104>123456789</N104>
            </N1>
        </N1Loop1>
    </HLLoop1>
    <HLLoop1>
        <HL>
            <HL01>2</HL01>
            <HL02>1</HL02>
            <HL03>O</HL03>
            <HL04>1</HL04>
        </HL>
        <LIN>
            <LIN02>VO</LIN02>
            <LIN03>123456</LIN03>
        </LIN>
    </HLLoop1>
    <HLLoop1>
        <HL>
            <HL01>3</HL01>
            <HL02>2</HL02>
            <HL03>I</HL03>
            <HL04>0</HL04>
        </HL>
        <LIN>
            <LIN02>HN</LIN02>
            <LIN03>NH1802</LIN03>
        </LIN>
    </HLLoop1>
    <HLLoop1>
        <HL>
            <HL01>4</HL01>
            <HL02>1</HL02>
            <HL03>O</HL03>
            <HL04>1</HL04>
        </HL>
        <LIN>
            <LIN02>VO</LIN02>
            <LIN03>654321</LIN03>
        </LIN>
    </HLLoop1>
    <HLLoop1>
        <HL>
            <HL01>5</HL01>
            <HL02>4</HL02>
            <HL03>I</HL03>
            <HL04>0</HL04>
        </HL>
        <LIN>
            <LIN02>HN</LIN02>
            <LIN03>NH1803</LIN03>
        </LIN>
    </HLLoop1>
    <HLLoop1>
        <HL>
            <HL01>6</HL01>
            <HL02>4</HL02>
            <HL03>I</HL03>
            <HL04>0</HL04>
        </HL>
        <LIN>
            <LIN02>HN</LIN02>
            <LIN03>NH1803</LIN03>
        </LIN>
    </HLLoop1>
    <CTT>
        <CTT01>3</CTT01>
    </CTT>
    <SE>
        <SE01>71</SE01>
        <SE02>0339</SE02>
    </SE>
</X12_00401_856>

Here is a screenshot of my map:

在此处输入图片说明

The first script is C#:

public int hlIndex = 0;

public int returnHLOIndex(int hl01, string hl03)
        {
            if(hl03 == "O")
            {
                hlIndex = hl01;
            }
            return hlIndex;
        }

Here is the XSLT in the second script:

<xsl:template name="X12_00401_856_To_ASN">

    <xsl:variable name="BOL" select="//BSN/BSN02"/>
    <xsl:variable name="accountNumber"><xsl:value-of select="//HLLoop1[HL/HL03='S']/N1Loop1/N1[N101='ST']/N104"/></xsl:variable>

    <xsl:variable name="NetWeight" select="//TD1/TD107"/>

    <xsl:element name="EDIFile_Staging_ASNHeader">
        <xsl:element name="AccountNumber"><xsl:value-of select="$accountNumber"/></xsl:element>
        <!--        -->
        <xsl:for-each select="//HLLoop1[HL/HL03='I']">

            <xsl:variable name="hloIndex"><xsl:value-of select="userCSharp:returnHLOIndex"/></xsl:variable>
            <xsl:variable name="orderNumber"><xsl:value-of select="//HLLoop1[$hloIndex]/LIN/LIN03"/></xsl:variable>

            <xsl:element name="EDIFile_Staging_ASNLines">
                <xsl:element name="lineNumber"><xsl:value-of select="position()"/></xsl:element>
                <xsl:element name="AdvanceShipmentNoteDocuNum"><xsl:value-of select="$BOL"/></xsl:element>
                <xsl:element name="AccountNumber"><xsl:value-of select="$accountNumber"/></xsl:element>
                <xsl:element name="ASNNumber"><xsl:value-of select="$BOL"/></xsl:element>
                <xsl:element name="OrderNumber"><xsl:value-of select="$orderNumber"/></xsl:element>

            </xsl:element>
        </xsl:for-each>
    </xsl:element>
</xsl:template>

The output generates one detail loop for each item level in the 856. But I need to carry the value of the LIN03 from the parent Order level. This version only seems to grab the first occurrence of the LIN03 at the order level. How can I correctly address those order level values?

I read one of the comments and he is right, you should add parameters.

 <xsl:variable name="hloIndex"> <xsl:value-of select="userCSharp:returnHLOIndex(string((HL/HL01/text()), string(HL/HL03/text()))"/> </xsl:variable> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM