Subject: RE: [xsl] How many levels of nodes can we nest in a xsl:template? From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Sun, 9 Sep 2007 22:12:44 +0100 |
This problem has nothing to do with the level of nesting. The data is output twice because you have asked it to be output twice: <xsl:choose> <xsl:when test="./@type ='speech' "> "<xsl:value-of select="."/>" </xsl:when> <xsl:when test="./@type = 'thought' "> <i> <xsl:value-of select="."/> </i> </xsl:when> </xsl:choose> <xsl:apply-templates select="p"/> It's written the first time when you do <xsl:value-of select="."/>, and it's written the second time when you do <xsl:apply-templates select="p"/>. I can't really advise you how to correct this because I don't understand your data or your desired output well enough. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Alice Wei [mailto:ajwei@xxxxxxxxxxx] > Sent: 09 September 2007 20:47 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] How many levels of nodes can we nest in a xsl:template? > > Hi, > > This is my first time trying to put in several layers of > nodes within a template, and the XML is found below: > > > <panelGroup> > <panel n="1" characters="margo damian ike"> > <balloon who="ike" type="speech"> > <p>My <emph rend="bold">every</emph> > instinct led me to the <emph > rend="bold">right</emph> > passages, Doctor Damian! </p> > <p> I'll record it on film for you, > right now!</p> > </balloon> > </panel> ........(more data) > </panelGroup> > > > <xsl:template match="panelGroup"> > > <table id="main" align="center" valign="middle"> > <tr> > <td> > <xsl:apply-templates select="figure"/> > </td> > <td> > <xsl:apply-templates select="panel"/> > </td> > </tr> > </table> > </xsl:template> > > <xsl:template match="panel"> > <xsl:apply-templates/> > </xsl:template> > <xsl:template match="balloon"> > <p> > <b> > <xsl:value-of select="./@who"/> > </b> > <xsl:choose> > <xsl:when test="./@type ='speech' "> > "<xsl:value-of select="."/>" </xsl:when> > <xsl:when test="./@type = 'thought' "> > <i> > <xsl:value-of select="."/> > </i> > </xsl:when> > </xsl:choose> > <xsl:apply-templates select="p"/> > </p> > </xsl:template> > > <xsl:template match="p"> > <xsl:apply-templates/> > </xsl:template> > > However, when I transform the data, the data appears twice. > The first line that appears is the line that does not have > any other formatting(bold or italics), and then the second > line would show the proper format. The problem is that when I > took out the <xsl:apply-templates/> line from the balloon > template, none of the bold print would show, although text > would be only appeared once. Is this because I have nested > too many levels of nodes within my "main template"? If so, > how many templates am I allowed to have to produce proper results? > > A Newbie to xsl:templates nesting > > Alice Wei > MIS 2008 > School of Library and Information Science
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How many levels of nodes can , Alice Wei | Thread | [xsl] Detecting and replacing "Spac, Buddhi Dananjaya |
Re: [xsl] XML structure to HTML uno, Abel Braaksma | Date | Re: [xsl] Fwd: level grouping probl, Maria Shvedova |
Month |