[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Question about creating 2 output nodes from 1 input node

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
cannon lanch
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.