Searching nodes depending on 2 similar fields

Here should go questions about transforming XML with XSLT and FOP.
Woudie
Posts: 1
Joined: Tue Jan 03, 2006 12:50 pm

Searching nodes depending on 2 similar fields

Post by Woudie » Tue Jan 03, 2006 12:55 pm

Hi all,

I would like to collect 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)

So I want all E1EDL37/EXIDV fields for each E1EL24/POSNR equals E1EDL37/E1EDL44/POSNR..

This is my XSLT code:

Code: Select all


<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:

Code: Select all


<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>

My wanted output code:

Code: Select all


<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>
I hope someone can help me to solve this problem...
Thx in advance!

george
Site Admin
Posts: 2101
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Thu Jan 05, 2006 10:39 am

Sorry Woudie but your sample is too complex and it seems not complete, I tried a little then I gave up as I cannot see where your problem is. Try to cut down your problem to something easier to understand and we will look into that.

Best Regards,
George

Post Reply