[英]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: 解码后,我有一个入站856,看起来像下面的样子:
<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#: 第一个脚本是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: 这是第二个脚本中的XSLT:
<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. 输出为856中的每个项目级别生成一个明细循环。但是我需要携带父订单级别的LIN03的值。 This version only seems to grab the first occurrence of the LIN03 at the order level.
这个版本似乎只在订单级别上抢占了LIN03的第一次出现。 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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.