on 2024 Jul 17 12:51 PM
Hi All,
Hope someone has encountered this before in MAG as it seems Integration Advisor is not as straightforward as using generic XSLT or XPATH.
Sample Input:
I am trying to figure out an XSLT function to get value of E1EDL24/EAN11 if E1EDL24/POSNR = E1EDL44/POSNR. I've tried the following ways below already but nothing works:
a. <xsl:value-of select="$nodes_in/E1EDL24[POSNR = $nodes_in/POSNR]/EAN11"/>
--No error but just blank.
b. <xsl:value-of select="/DELVRY07/E1EDL20/E1EDL24/E1EDL24[POSNR='$nodes_in/POSNR']/EAN11"/>
--ERROR: Failed to simulate MAG: Leading '/' selects nothing: the context item is absent
c. <xsl:key name="eanbyposnr" match="$nodes_in/E1EDL24" use="POSNR"/>
<xsl:value-of select="key('eanbyposnr', $nodes_in/POSNR)/EAN11"/>
--ERROR: Failed to simulate MAG: An xsl:function element must not contain an xsl:key element, Element xsl:key must be top-level (a child of xsl:stylesheet, xsl:transform, or xsl:package)
d. Using template, but it's not allowed at xslt function.
I got it worked already referencing @dharamverma's post in using the node position. Thanks.
<xsl:variable name="vPOSNR" select="$nodes_in/POSNR24"/>
<xsl:variable name="vEAN11" select="$nodes_in/EAN11"/>
<xsl:for-each select="$nodes_in/POSNR24">
<xsl:variable name="vPOS" select="position()" />
<xsl:if test="$vPOSNR[$vPOS] = $nodes_in/POSNR44">
<xsl:value-of select="$vEAN11[$vPOS]"/>
</xsl:if>
</xsl:for-each>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
8 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.