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

for-each question

Subject: for-each question
From: Holmberg Rick-ra0119 <Rick.Holmberg@xxxxxxxxxxxx>
Date: Mon, 12 Aug 2002 16:56:44 -0700
 for-each question
I am new to Xsl and am trying to parse a xml document into a html doc.  I would like to have a heading above several elements but don't want that heading to show up above each element.  I am sure this is simple but I can't seem to quite get it.  Here is what I have.
 
If my xml file looks like this
<?xml version="1.0" encoding="UTF-8"?>
<test>
<id>TestId</id>
<book>ABC123</book>
<book>ABC456</book>
<book>ABC789</book>
</test>
 
I would like the html to read
The Books are:
ABC123
ABC456
ABC789
 
My Stylesheet segment is:
 
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>             
<xsl:output method="html"/>
 
<xsl:template match="/">
    <xsl:copy>
      <xsl:apply-templates/>
    </xsl:copy>
</xsl:template>
 
<xsl:template match="book">
<I>
The Books are:
<xsl:apply-templates select="book" />
<xsl:apply-templates/>
</I>
</xsl:template>
 
 
With this XSL file I am getting the 'The Books are:' printed 3 times.  I only need it once.  I figure I have to use a for-each but I can't seem to get that to work correctly.  Can anyone help here?
 
Thanks,
Rick



 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.