Subject: Re: Question about creating 2 output nodes from 1 input node From: Phil Lanch <phil@xxxxxxxxxxxxxxx> Date: Tue, 23 Nov 1999 19:10:53 +0000 |
Yannick Nicolas wrote: > > My original document is a set of paragraphs, and each of them has a title, > which is tagged by <title id="...."> blahblah </title>. > The <title> tag has an "id" attribute as you can see. > > ---------- > > <title id="chapter-1">1st title</title> > <p>blahblahblah</p> > > <title id="chapter-2">2nd title</title> > <p>blahblahblah</p> > > <title id="chapter-3">3rd title</title> > <p>blahblahblah</p> > > ---------- > > My final document contains the same structure: a set of paragraphs that > have each one a title which is tagged in another way : each title has > an anchorage that links to the bottom of the document, where I can find > the list of all the titles. > > ---------- > > <a href="#chapter-1">1st title</a> > <p>blahblahblah</p> > > <a href="#chapter-2">1st title</a> > <p>blahblahblah</p> > > <a href="#chapter-3">1st title</a> > <p>blahblahblah</p> > > <list> > <p><a name="chapter-1"></a>1st title</p> > <p><a name="chapter-1"></a>2nd title</p> > <p><a name="chapter-1"></a>3rd title</p> > </list> > > ---------- > > I know what rules to write to output the first part of the output tree > (the paragraphs and their titles), but I don't understand how I can add > the list of nodes that contains the information that are already used > to make the 1st part of the output tree. > > I hope you understand what I mean!!! Try adding some code to the end of your top-level template, something like: <xsl:template match="/"> <xsl:apply-templates/> <!-- ... or however you do the first part --> <list> <xsl:for-each select="//title"> <p><a name="{@id}"></a><xsl:value-of select="."/></p> </xsl:for-each> </list> </xsl:template> The for-each loop is gone round for every title element in the document - that's what "//title" selects. This is just one way of using information more than once in XSLT - which is one of the reasons it is such a powerful language. -- cheers phil '"having more of a life is one of the earliest and subtlest signs of mediocrity"' --- Musil XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Question about creating 2 outpu, David Carlisle | Thread | Question about running XSL and IE50, Rick Cannon |
Stylesheets from lisp anyone?, Dave Pawson | Date | Re: xsl:key support (was RE: Simple, Denys Duchier |
Month |