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

RE: Assistance with for-each

Subject: RE: Assistance with for-each
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 5 Jul 2007 22:22:53 +0100
RE:  Assistance with for-each
<xsl:template match="reqpers">
  <table>
    <xsl:apply-templates select="person"/>
  </
</

<xsl:template match="person">
  <tr>
    <td><xsl:value-of select="@man"/></td>
    <td><xsl:value-of
select="following-sibling::perscat[1]/@category"/></td> 
    <td><xsl:value-of select="following-sibling::trade[1]"/></td>
  </
</

(And then fire the person who designed the XML)

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Maxine Pensyl-Johnson [mailto:Maxine.Pensyl-Johnson@xxxxxxx] 
> Sent: 04 July 2007 20:52
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Assistance with for-each
> 
> I'm trying to get my sample data to all appear on one table 
> row, but I'm unsuccessful. Any help you can provide is appreciated.
> 
> 
> XSLT 1.0   SAXON 6.5.5
> 
> Sample Data:
>                 <reqpers>
> 
>                     <person man="1"/>
> 
>                     <perscat category="Cook"/>
> 
>                     <trade>McDonalds Chef</trade>
> 
>                     <person man="1"/>
> 
>                     <perscat category="Staff"/>
> 
>                     <trade>Front Counter</trade>
> 
>                     <person man="4"/>
> 
>                     <perscat category="Janitor"/>
> 
>                     <trade>Clean up the mess left by others</trade>
> 
>                 </reqpers>
> 
>  
> 
> Desired Results
> 
> 1	 Cook	 McDonalds Chef
> 1	 Staff	 Front Counter
> 4	 Janitor Clean up the mess left by others
>   
> 
> Code:
> 
>         <xsl:for-each
> select="reqpers/person|reqpers/perscat|reqpers/trade">
> 
>             <tr>
> 
>                 <td valign="top"><xsl:value-of 
> select="person/@man"/></td>
> 
>                 <td valign="top"><xsl:value-of 
> select="perscat/@category"/></td>
> 
>                <td valign="top"><xsl:value-of 
> select="trade/text()"/></td>
> 
>             </tr>
> 
>         </xsl:for-each>

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.