Jump to content

Show all nodes depending 2 equal fields


Woudie
 Share

Recommended Posts

Hi all,I would like to select all items for which the position number is equal to 000010 or 000020 for example. There are several items for each position number (field POSNR)But how can I make my variable dynamic so I can check for POSNR 000010, 000020, 000030 and so on...This is my XSLT code:

<xsl:template name="E1EDL24_PackageIdentification">  <xsl:for-each select="//E1EDL20/E1EDL24[POSNR < 900000]">  	<xsl:variable name="ItemPosNr">    <xsl:value-of select="//E1EDL20/E1EDL24/POSNR"/>  	</xsl:variable>  	<xsl:for-each select="//E1EDL20/E1EDL37/E1EDL44[POSNR=$ItemPosNr]">    <xsl:element name="PackageIdentification">    	<xsl:element name="PackageID">      <xsl:value-of select="//E1EDL20/E1EDL37/EXIDV"/>    	</xsl:element>    	<xsl:element name="PackageIDType">ODETT</xsl:element>    	<xsl:if test="//E1EDL20/E1EDL37/E1EDL44/VEMNG!=''">      <xsl:element name="Quantity">      	<xsl:element name="QuantityType">QPP</xsl:element>      	<xsl:element name="Amount">        <xsl:variable name="Amount">        	<xsl:value-of select="format-number(//E1EDL20/E1EDL37/E1EDL44/VEMNG,'000.000','point')"/>        </xsl:variable>        <xsl:if test="$Amount!='NaN'">        	<xsl:value-of select="$Amount"/>        </xsl:if>      	</xsl:element>      	<xsl:element name="UnitOfMeasure">        <xsl:value-of select="//E1EDL20/E1EDL37/E1EDL44/VEMEH"/>      	</xsl:element>      </xsl:element>    	</xsl:if>    </xsl:element>  	</xsl:for-each>  </xsl:for-each>	</xsl:template>

My source xml code:<E1EDL24 SEGMENT="1"> <POSNR>000020</POSNR> <MATNR>CAT</MATNR> <MATWA>CAT</MATWA> <ARKTX>264-7684-1</ARKTX> <WERKS>P010</WERKS> <LGORT>0003</LGORT> <KDMAT>05020°54232</KDMAT> <LFIMG>10.000</LFIMG> <VRKME>PCE</VRKME> <LGMNG>10.000</LGMNG> <MEINS>PCE</MEINS> <NTGEW>300.000</NTGEW> <BRGEW>350.000</BRGEW> <GEWEI>KGM</GEWEI> <VOLUM>0.000</VOLUM> <LADGR>0001</LADGR> <TRAGR>0001</TRAGR> <VKBUR>K010</VKBUR> <VTWEG>01</VTWEG> <SPART>01</SPART> <GRKOR>000</GRKOR> <AESKD>V 001</AESKD></E1EDL24><E1EDL37 SEGMENT="1"> <EXIDV>00000000001000002985</EXIDV> <GWEIT>KGM</GWEIT> <BRGEW>70.000</BRGEW> <NTGEW>70.000</NTGEW> <GWEIM>KGM</GWEIM> <VHILM>EURO</VHILM> <VHILM_KU>V 284E0</VHILM_KU> <VEBEZ>EUROPALLET</VEBEZ> <SMGKN>S</SMGKN> <E1EDL38 SEGMENT="1"> <VHART_BEZ>Algemene verpakking</VHART_BEZ> <VEBEZ>EUROPALLET</VEBEZ> </E1EDL38> <E1EDL44 SEGMENT="1"> <VELIN>1</VELIN> <VBELN>0080000857</VBELN> <POSNR>000020</POSNR> <VEMNG>2.000</VEMNG> <VEMEH>PCE</VEMEH> </E1EDL44></E1EDL37><E1EDL37 SEGMENT="1"> <EXIDV>00000000001000002986</EXIDV> <GWEIT>KGM</GWEIT> <BRGEW>70.000</BRGEW> <NTGEW>70.000</NTGEW> <GWEIM>KGM</GWEIM> <VHILM>EURO</VHILM> <VHILM_KU>V 284E0</VHILM_KU> <VEBEZ>EUROPALLET</VEBEZ> <SMGKN>S</SMGKN> <E1EDL38 SEGMENT="1"> <VHART_BEZ>Algemene verpakking</VHART_BEZ> <VEBEZ>EUROPALLET</VEBEZ> </E1EDL38> <E1EDL44 SEGMENT="1"> <VELIN>1</VELIN> <VBELN>0080000857</VBELN> <POSNR>000020</POSNR> <VEMNG>2.000</VEMNG> <VEMEH>PCE</VEMEH> </E1EDL44></E1EDL37>[/code]My wanted output code:<DesadvItem> <LineItemNumber>1</LineItemNumber> <BuyerArticleNumber>960908766</BuyerArticleNumber> <CountryOfOrigin>BE</CountryOfOrigin> <Quantities> <Quantity> <QuantityType>DSP</QuantityType> <Amount>008.000</Amount> <UnitOfMeasure>PCE</UnitOfMeasure> </Quantity> </Quantities> <PackageIdentifications> <PackageIdentification> <PackageID>00000000001000002985</PackageID> <PackageIDType>ODETT</PackageIDType> <Quantity> <QuantityType>QPP</QuantityType> <Amount>002.000</Amount> <UnitOfMeasure>PCE</UnitOfMeasure> </Quantity> </PackageIdentification> <PackageIdentification> <PackageID>00000000001000002986</PackageID> <PackageIDType>ODETT</PackageIDType> <Quantity> <QuantityType>QPP</QuantityType> <Amount>002.000</Amount> <UnitOfMeasure>PCE</UnitOfMeasure> </Quantity> </PackageIdentification></DesadvItem>

Link to comment
Share on other sites

Your XML looks horrible :) ! I'm sorry, but I won't waste time understanding it. Instead I'll just give you an XPath expression that should do the trick :) . You (or someone else) decide where it's place should be:

//E1EDL20/E1EDL24[POSNR ≡ 000010 or POSNR ≡ 000020]

This is true if the POSNR is 000010 or 000020. False if anything else.Note: True means selected and False means not selcted.

Link to comment
Share on other sites

Thx for reply but POSNR is variable, i need to select all values for POSNR=000010 but also for POSNR=000020, POSNR=000030 and so on...So I want all E1EDL37/EXIDV fields for each E1EL24/POSNR equals E1EDL37/E1EDL44/POSNRI've tried with a variable but a variable can't change apparently.. :sAnybody an idea?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...