May 28, 201411 yr Dear friends, Could someone check my XSL. I simply want to achieve following XML: <invoices> <invoice> <inv_id>280587</inv_id> <inv_number>274218</inv_number> <inv_date>20140401</inv_date> <inv_exclbtw>18.50</inv_exclbtw> <inv_btw>3.89</inv_btw> <inv_inclbtw>22.39</inv_inclbtw> <pdf>true</pdf> <invoiceprojects> <invoiceproject> <project>SOHS35629</project> <projectdescription>Locatie: zzzzz</projectdescription> <orderreference>SOHS35629</orderreference> <ordernumber>925402</ordernumber> <portal_id></portal_id> </invoiceproject> <invoiceproject> <project>SOHS35628</project> <projectdescription>Locatie:xxxxxx</projectdescription> <orderreference>SOHS35629</orderreference> <ordernumber>925402</ordernumber> <portal_id></portal_id> </invoiceproject> </invoiceprojects> </invoice> </invoices> I currently have following written down. But the Project nodes stay empty... <xsl:template match="/"> <invoices> <xsl:for-each select="fmp:FMPXMLRESULT/fmp:RESULTSET/fmp:ROW"> <invoice> <inv_id><xsl:value-of select="fmp:COL[1]/fmp:DATA"/></inv_id> <inv_number><xsl:value-of select="fmp:COL[2]/fmp:DATA"/></inv_number> <inv_date><xsl:value-of select="fmp:COL[3]/fmp:DATA"/></inv_date> <inv_exclbtw><xsl:value-of select="fmp:COL[4]/fmp:DATA"/></inv_exclbtw> <inv_btw><xsl:value-of select="fmp:COL[5]/fmp:DATA"/></inv_btw> <inv_inclbtw><xsl:value-of select="fmp:COL[6]/fmp:DATA"/></inv_inclbtw> <pdf><xsl:value-of select="fmp:COL[7]/fmp:DATA"/></pdf> <invoiceprojects> <xsl:for-each select="fmp:COL[8]/fmp:DATA"> <invoiceproject> <project><xsl:value-of select="fmp:COL[8]/fmp:DATA"/></project> <projectdescription><xsl:value-of select="fmp:COL[9]/fmp:DATA"/></projectdescription> <orderreference><xsl:value-of select="fmp:COL[10]/fmp:DATA"/></orderreference> <ordernumber><xsl:value-of select="fmp:COL[11]/fmp:DATA"/></ordernumber> <portal_id><xsl:value-of select="fmp:COL[12]/fmp:DATA"/></portal_id> </invoiceproject> </xsl:for-each> </invoiceprojects> </invoice> </xsl:for-each> </invoices> Can anybody help me with this... thanksl!!! Jeroen
May 28, 201411 yr Could you let us see the entire XSLT stylesheet, please? Best zip it and attach it to your post. Seeing the raw XML export would be helpful, too.
May 30, 201411 yr The problem here is that when you do: <invoiceprojects> <xsl:for-each select="fmp:COL[8]/fmp:DATA"> you move the context to fmp:COL[8]/fmp:DATA. Then, when you try to output: <project><xsl:value-of select="fmp:COL[8]/fmp:DATA"/></project> you output an empty project, because the context node fmp:COL[8]/fmp:DATA has no child node fmp:COL[8]/fmp:DATA. What you need to do is this: ... <invoiceprojects> <xsl:for-each select="fmp:COL[8]/fmp:DATA"> <invoiceproject> <xsl:variable name="pos" select="position()"/> <project><xsl:value-of select="."/></project> <projectdescription><xsl:value-of select="../../fmp:COL[9]/fmp:DATA[$pos]"/></projectdescription> <orderreference><xsl:value-of select="../../fmp:COL[10]/fmp:DATA[$pos]"/></orderreference> <ordernumber><xsl:value-of select="../../fmp:COL[11]/fmp:DATA[$pos]"/></ordernumber> <portal_id><xsl:value-of select="../../fmp:COL[12]/fmp:DATA[$pos]"/></portal_id> </invoiceproject> </xsl:for-each> </invoiceprojects> ... i.e. loop over the DATA elements of COL[8] and for each of these output first itself and then the corresponding DATA elements of the other columns originating in the child table.
Create an account or sign in to comment