|
From: Prasanna K. <agp...@ho...> - 2003-02-07 09:11:04
|
Hi Josten, Thanks for the Reply. This solves my problem. But one addition to it. I don't know the depth the <TEXTELEMENT> can grow upto. Is there anyway by which we can render towards the leaf in a loop. Thanks Prasanna Kumar ----- Original Message ----- From: "Geert Josten" <Gee...@Da...> To: "Prasanna Kumar" <agp...@ho...> Cc: <xml...@li...> Sent: Friday, February 07, 2003 2:26 PM Subject: Re: Help on XSLT template logic! (Prasanna Kumar) > Hi there, > > How about something like: > > <xsl:stylesheet ...> > > <xsl:template match="COLUMNHEADER"> > <table> > <tr> > <xsl:apply-templates select="TEXTELEMENT" /> > </tr> > <tr> > <xsl:apply-templates select="*/TEXTELEMENT" /> > </tr> > <tr> > <xsl:apply-templates select="*/*/TEXTELEMENT" /> > </tr> > </table> > </xsl:template> > > <xsl:template match="TEXTELEMENT"> > <td><xsl:value-of select="@DISPLAYNAME" /></td> > </xsl:template> > > </xsl:stylesheet> > > > Message: 1 > > From: "Prasanna Kumar" <agp...@ho...> > > To: <XML...@ja...>, > > <xer...@xm...>, > > <xml...@li...>, > > <xml...@li...> > > Subject: Help on XSLT template logic! > > Date: Thu, 6 Feb 2003 18:26:54 +0530 > > > > Hi All, > > > > I have the Following XML : > > > > <COLUMNHEADER> > > <TEXTELEMENT DISPLAYNAME="T1"> > > <TEXTELEMENT DISPLAYNAME="T11"> > > <TEXTELEMENT > > DISPLAYNAME="T21"/> > > <TEXTELEMENT > > DISPLAYNAME="T22"/> > > </TEXTELEMENT> > > <TEXTELEMENT DISPLAYNAME="T12"> > > <TEXTELEMENT > > DISPLAYNAME="T23"/> > > </TEXTELEMENT> > > </TEXTELEMENT> > > <TEXTELEMENT DISPLAYNAME="T2"> > > <TEXTELEMENT DISPLAYNAME="T13"> > > <TEXTELEMENT > > DISPLAYNAME="T24"/> > > <TEXTELEMENT > > DISPLAYNAME="T25"/> > > </TEXTELEMENT> > > <TEXTELEMENT DISPLAYNAME="T14"> > > <TEXTELEMENT > > DISPLAYNAME="T26"/> > > </TEXTELEMENT> > > </TEXTELEMENT> > > </COLUMNHEADER> > > > > And I require the following HTML output: > > > > <table> > > <tr> > > <td>T1</td> > > <td>T2</td> > > </tr> > > <tr> > > <td>T11</td> > > <td>T12</td> > > <td>T13</td> > > <td>T14</td> > > </tr> > > <tr> > > <td>T21</td> > > <td>T22</td> > > <td>T23</td> > > <td>T24</td> > > <td>T25</td> > > <td>T26</td> > > </tr> > > > > My requirement is to loop through the elements recursively, from top level > > to the leaf node level and render them, > > > > how can I achieve this using xsl. what should be my template logic? > > > > Thanks in Advance, > > > > Prasanna Kumar > |