AnsweredAssumed Answered

How to create a working loop in XSLT

Question asked by user2148598 on Feb 5, 2019
Latest reply on Feb 5, 2019 by user2148598

Hi,

I have a generated XML with filemaker and need to convert this. I use therefor this XSLT. Unfortunately the wastelines remains empty in the target XML. What am I doing wrong?

 

my XSLT:

 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fmp="http://www.filemaker.com/fmpxmlresult"
    exclude-result-prefixes="fmp"
    xmlns="http://webservices.portofrotterdam.com/hamis/exchange/emainotification/v0/">
   
   
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
   
   
<xsl:template match="fmp:FMPXMLRESULT">
       
<EmaiNotificationRequest xmlns="http://webservices.portofrotterdam.com/hamis/exchange/emainotification/v0/">
           
           
<xsl:for-each select="fmp:RESULTSET/fmp:ROW">
               
<MessageId></MessageId>
               
<EmaiType></EmaiType>
               
<VIHBNumber><xsl:value-of select="fmp:COL[1]/fmp:DATA"/></VIHBNumber>
               
<Snumber><xsl:value-of select="fmp:COL[2]/fmp:DATA" /></Snumber>
               
<UniqueCallReferenceNumber></UniqueCallReferenceNumber>
               
<DateTimeStart></DateTimeStart>
               
<DateTimeEnd></DateTimeEnd>
               
<DateTimeMessageCreated></DateTimeMessageCreated>
               
<AgentName><xsl:value-of select="fmp:COL[3]/fmp:DATA" /></AgentName>
               
<VesselName><xsl:value-of select="fmp:COL[4]/fmp:DATA" /></VesselName>
               
<PortName></PortName>
               
<Berth></Berth>
               
<Remarks><xsl:value-of select="fmp:COL[6]/fmp:DATA" /></Remarks>
               
<PaymentType></PaymentType>
               
<MainEngineCapacity></MainEngineCapacity>
               
<WasteCollector><xsl:value-of select="fmp:COL[7]/fmp:DATA" /></WasteCollector>
               
<AmountFixedFee></AmountFixedFee>
               
<xsl:call-template name="wasteline"/>
           
</xsl:for-each>
       
</EmaiNotificationRequest> 
   
</xsl:template>
   
   
<xsl:template name="wasteline">
       
<xsl:for-each select="fmp:COL[8]/fmp:DATA"> <!-- as often as DATA occurs at COL[8]  -->
           
<xsl:variable name="i" select="position()"/>
           
<WasteCollectionMaterial>
               
<EuralCode><xsl:value-of select="fmp:COL[8]/fmp:DATA[$i]" /></EuralCode>
               
<AfvalCode><xsl:value-of select="fmp:COL[9]/fmp:DATA[$i]" /></AfvalCode>
               
<AfvalNaam><xsl:value-of select="fmp:COL[10]/fmp:DATA[$i]" /></AfvalNaam>
           
</WasteCollectionMaterial>
       
</xsl:for-each>
   
</xsl:template>

</xsl:stylesheet>

Outcomes