Subject: Re: [xsl] Generate N elements and attribute values From: "Kenny Bogoe (BogoeMD)" <kenny@xxxxxxxxx> Date: Sun, 18 Jul 2004 20:23:08 +0200 |
Hi Wendell, Yes, you are absolutely right - I create the tr elements inside the template that creates the td elements, but I am not so sure exactly what to do with your example template, though it makes sense to do as you suggest. Btw...where do you define the max-count param? This is my recursive template (tr) with the inside recursive template (td): <xsl:template name="tr"> <xsl:param name="x"/> <xsl:param name="y"/> <tr no="{$y}"> <xsl:call-template name="td"> <xsl:with-param name="x" select="//Tabel/@cols"/> <xsl:with-param name="y" select="0"/> </xsl:call-template> </tr> <xsl:if test="$x > 1"> <xsl:call-template name="tr"> <xsl:with-param name="x" select="$x - 1"/> <xsl:with-param name="y" select="$y + 1"/> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template name="td"> <xsl:param name="x"/> <xsl:param name="y"/> <xsl:element name="td"> <xsl:attribute name="name"><!--this is where I need the values as specified--></xsl:attribute> </xsl:element> <xsl:if test="$x > 1"> <xsl:call-template name="td"> <xsl:with-param name="x" select="$x - 1"/> <xsl:with-param name="y" select="$y + 1"/> </xsl:call-template> </xsl:if> </xsl:template> Hope you can help me a bit more...Thanks in advance. Kenny > Hi Kenny, > > Presumably the recursive template that creates the three td elements is > inside the template that creates the tr elements. (I don't know how else > you'd do it. ;-) > > If so, each time the "inner" template is called (by an iteration of the > "outer" template), you can pass a parameter through to carry the count of > the outer iteration. > > Does that make sense? > > <xsl:template name="outer"> > <xsl:param name="count" select="0"/> > .... > <xsl:call-template name="inner"> > <xsl:with-param name="outer-count" select="$count"/> > </xsl:call-template> > <xsl:if test="$count < $max-count)"> > <xsl:call-template name="outer"> > <xsl:with-param name="count" select="$count + 1"/> > </xsl:call-template> > </xsl:if> > </xsl:template> > > I hope I understood the question.... > > Cheers, > Wendell > > At 02:50 PM 7/16/2004, you wrote: >> I have already posted a question on how to generate dynamic attribute values >> within a recursive template, but I have to admit that I got a bit confused >> when reading my own posting, so I retry with a simplified version of my >> problem. >> >> A recursive template is generating N=4 <tr> and another inline recursive >> template is generating n=3 <td> and so far I have no problems. But when it >> comes to the attribute values of <td name="?"/> I really do not know what to >> do since the @name of <td> is generated on the fly and after all <tr> are >> generated. As shown in the result tree below the @name of <td> always >> follows the @no of <tr>. >> >> So my simple question is how to generate @name values on the fly? >> >> >> This is the result tree I need: >> >> <tr no="0"> >> <td name="0"/> >> <td name="0"/> >> <td name="0"/> >> </tr> >> <tr no="1"> >> <td name="1"/> >> <td name="1"/> >> <td name="1"/> >> </tr> >> <tr no="2"> >> <td name="2"/> >> <td name="2"/> >> <td name="2"/> >> </tr> >> <tr no="3"> >> <td name="3"/> >> <td name="3"/> >> <td name="3"/> >> </tr> >> >> >> Thanks, >> Kenny Bogoe > > > ====================================================================== > Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx > Mulberry Technologies, Inc. http://www.mulberrytech.com > 17 West Jefferson Street Direct Phone: 301/315-9635 > Suite 207 Phone: 301/315-9631 > Rockville, MD 20850 Fax: 301/315-8285 > ---------------------------------------------------------------------- > Mulberry Technologies: A Consultancy Specializing in SGML and XML > ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Generate N elements and a, Wendell Piez | Thread | Re: [xsl] Generate N elements and a, Mukul Gandhi |
RE: [xsl] Retaining value of a Glob, Wendell Piez | Date | [xsl] samples/Trace/Trace.java comp, Jun Yuan |
Month |