Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - absolut beginner request help with xslt Write! [Thread Next] Re: absolut beginner request help with xslt Write!To: NULL Date: 10/11/2007 8:38:00 AM You haven't shown the structure of the XML but if the PAYMENTS is a child of the document element you're too high up the tree to access it by just using its name. You could change it to <xsl:for-each select="*/PAYMENTS">. Personally I would use apply-templates not for-each, it makes the code so much easier to read and maintain. If this is the full XML: <POLICY> <HEADER> some stuff here </HEADER> <PAYMENTS> <INSTALLMENT_PAYMENT> <POLICY_NUMBER>HMGW100289</POLICY_NUMBER> <START_DATE>20070810</START_DATE> <EXPIRY_DATE>20080810</EXPIRY_DATE> <RISK_STATE>NSW</RISK_STATE> <PAYMENT_DATE>20070712</PAYMENT_DATE> <BRANCH_ID>1519322</BRANCH_ID> <PREMIUM>-24.18</PREMIUM> <FEES> <FEE_DESCR>FSL</FEE_DESCR> <TOTAL_FEE_AMOUNT>-2.86</TOTAL_FEE_AMOUNT> </FEES> <FEES> <FEE_DESCR>GST</FEE_DESCR> <TOTAL_FEE_AMOUNT>-2.02</TOTAL_FEE_AMOUNT> </FEES> <FEES> <FEE_DESCR>SD</FEE_DESCR> <TOTAL_FEE_AMOUNT>-2</TOTAL_FEE_AMOUNT> </FEES> <COMMISSION>-3.46</COMMISSION> <AGENT_FEE>0</AGENT_FEE> <AGENT_FEE_GST>0</AGENT_FEE_GST> <CANCELLATION _FEE="">20</CANCELLATION> </INSTALLMENT_PAYMENT> </PAYMENTS> </POLICY> Then something like this, the tables don't seem right to me but I have followed your coding, shouldn't FEESW element be in a new row? <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <xsl:apply-templates select="POLICY" /> </body> </html> </xsl:template> <xsl:template match="POLICY"> <table width="100%" border="1" bgcolor="LemonChiffon"> <tr bgcolor="#9acd32"> <th align="left">POLICY_NUMBER</th> <th align="left">START_DATE</th> <th align="left">EXPIRY_DATE</th> <th align="left">RISK_STATE</th> <th align="left">PAYMENT_DATE</th> <th align="left">BRANCH_ID</th> <th align="left">PREMIUM</th> <th align="left">FLS</th> <th align="left">GST</th> <th align="left">SD</th> <th align="left">COM</th> <th align="left">AGENT_FEE</th> <th align="left">AGENT_FEE_GST</th> <th align="left">CANCELLATION_FEE</th> </tr> <xsl:apply-templates select="PAYMENTS" /> </table> </xsl:template> <xsl:template match="PAYMENTS"> <xsl:apply-templates select="INSTALLMENT_PAYMENT" /> </xsl:template> <xsl:template match="INSTALLMENT_PAYMENT"> <tr> <td> <xsl:value-of select="POLICY_NUMBER"/> </td> <td> <xsl:value-of select="START_DATE"/> </td> <td> <xsl:value-of select="EXPIRY_DATE"/> </td> <td> <xsl:value-of select="RISK_STATE"/> </td> <td> <xsl:value-of select="PAYMENT_DATE"/> </td> <td> <xsl:value-of select="BRANCH_ID"/> </td> <td> <xsl:value-of select="PREMIUM"/> </td> <xsl:apply-templates select="FEES" /> </tr> </xsl:template> <xsl:template match="FEES"> <td> <xsl:value-of select="TOTAL_FEE_AMOUNT"/> </td> <td> <xsl:value-of select="TOTAL_FEE_AMOUNT"/> </td> <td> <xsl:value-of select="TOTAL_FEE_AMOUNT"/> </td> </xsl:template> </xsl:stylesheet> -- Joe Fawcett (MVP - XML) http://joe.fawcett.name .googlegroups.com... > Hi there > I have an xml file, fo which I want to import the data to Access 2003. > As I amnot getting the format that I am looking for, I want to use > xslt to transform the data. The initial start got me to produce the > header out put format but not the rest. I was wondering weather > someone could hint me over the next hurdle? or point me to a site that > has some tutorial. any hints are wellcome > > here is what I have got; > <?xml version="1.0" encoding="utf-8"?> > > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > > <xsl:template match="/"> > <html> > <body> > <table width="100%" border="1" bgcolor="LemonChiffon"> > <tr bgcolor="#9acd32"> > <th align="left">POLICY_NUMBER</th> > <th align="left">START_DATE</th> > <th align="left">EXPIRY_DATE</th> > <th align="left">RISK_STATE</th> > <th align="left">PAYMENT_DATE</th> > <th align="left">BRANCH_ID</th> > <th align="left">PREMIUM</th> > <th align="left">FLS</th> > <th align="left">GST</th> > <th align="left">SD</th> > <th align="left">COM</th> > <th align="left">AGENT_FEE</th> > <th align="left">AGENT_FEE_GST</th> > <th align="left">CANCELLATION_FEE</th> > </tr> > <xsl:for-each select="PAYMENTS"> > <xsl:for-each select="INSTALLMENT_PAYMENT"> > <tr> > <td><xsl:value-of select="POLICY_NUMBER"/></td> > <td><xsl:value-of select="START_DATE"/></td> > <td><xsl:value-of select="EXPIRY_DATE"/></td> > <td><xsl:value-of select="RISK_STATE"/></td> > <td><xsl:value-of select="PAYMENT_DATE"/></td> > <td><xsl:value-of select="BRANCH_ID"/></td> > <td><xsl:value-of select="PREMIUM"/></td> > <xsl:for-each select="FEES"> > <td> > <xsl:value-of select="TOTAL_FEE_AMOUNT"/> > </td> > <td> > <xsl:value-of select="TOTAL_FEE_AMOUNT"/> > </td> > <td> > <xsl:value-of select="TOTAL_FEE_AMOUNT"/> > </td> > </xsl:for-each> > </tr> > </xsl:for-each> > </xsl:for-each> > </table> > </body> > </html> > </xsl:template> > </xsl:stylesheet> > > and her is the detail section of the xml file: > <HEADER> > some stuff here > </HEADER> > <PAYMENTS> > <INSTALLMENT_PAYMENT> > <POLICY_NUMBER>HMGW100289</POLICY_NUMBER> > <START_DATE>20070810</START_DATE> > <EXPIRY_DATE>20080810</EXPIRY_DATE> > <RISK_STATE>NSW</RISK_STATE> > <PAYMENT_DATE>20070712</PAYMENT_DATE> > <BRANCH_ID>1519322</BRANCH_ID> > <PREMIUM>-24.18</PREMIUM> > <FEES> > <FEE_DESCR>FSL</FEE_DESCR> > <TOTAL_FEE_AMOUNT>-2.86</TOTAL_FEE_AMOUNT> > </FEES> > <FEES> > <FEE_DESCR>GST</FEE_DESCR> > <TOTAL_FEE_AMOUNT>-2.02</TOTAL_FEE_AMOUNT> > </FEES> > <FEES> > <FEE_DESCR>SD</FEE_DESCR> > <TOTAL_FEE_AMOUNT>-2</TOTAL_FEE_AMOUNT> > </FEES> > <COMMISSION>-3.46</COMMISSION> > <AGENT_FEE>0</AGENT_FEE> > <AGENT_FEE_GST>0</AGENT_FEE_GST> > <CANCELLATION _FEE>20</CANCELLATION _FEE> > </INSTALLMENT_PAYMENT> > | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
