[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Embedded xsl:for-each
Hi Mark, Try <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="root"> <xsl:for-each select="data/Table1"> <xsl:text> Sum value =</xsl:text> <xsl:value-of select="SUM"/> <xsl:for-each select="Table2/TablePolicy_No"> <xsl:text> Policy No= </xsl:text> <xsl:value-of select="."/> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet> I havent added the xsl:fo tags, but this should give you the logic regards Vasu ----- Original Message ----- From: "Mark Williams" <mark@xxxxxxxxxxx> To: "XSL-List" <XSL-List@xxxxxxxxxxxxxxxxxxxxxx> Sent: Tuesday, December 30, 2003 5:39 AM Subject: Embedded xsl:for-each > Hi, > > I'm trying to embed for-each statements within each other, but I am having > problems. Take as an example the following XML file > > <root> > <data> > <Table1> > <SUM>123.00</SUM> > <Table2> > <TablePolicy_No>123456</TablePolicy_No> > <TablePolicy_No>789101112</TablePolicy_No> > </Table2> > </Table1> > <Table1> > <SUM>12.25</SUM> > <Table2> > <TablePolicy_No>12</TablePolicy_No> > <TablePolicy_No>789</TablePolicy_No> > </Table2> > </Table1> > </data> > </root> > > > and the following excerpt from a fo file: > > <xsl:for-each select="data/Table1"> > > <xsl:for-each select="Table2"> > > <fo:block font-family="Times-Roman" font-size="12pt" text-align="justify" > space-after="0.05pt"> > > <xsl:if test="position() = 1">Sum value = <xsl:value-of > select="SUM"/></xsl:if> > > Policy No= <xsl:value-of select="TablePolicy_No"/> > > </fo:block> > > </xsl:for-each> > > </xsl:for-each> > > > > I was expecting this to produce the following: > > > > Sum value = 123.00 Policy No = 123456 > > Policy No = 789101112 > > Sum value = 12.25 Policy No = 12 > > Policy No = 789 > > > > Instead it is producing > > Sum value = Policy No =123456 > > Sum Value = 12.25 Policy No = 12 > > > > I can understand why the sum value is not generated as it is looking for SUM > as a child of Table2 when in fact it is a child of Table1. How do I obtain > the value of SUM in this situation. > > > > I don't understand why I am only getting 1 policy no value for each > repetition of Table1 with its nested repetition of Table2. > > > > Any help would be appreciated. > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|