RE: [xsl] How to sort this xml out

Subject: RE: [xsl] How to sort this xml out
From: Dan Diebolt <dandiebolt@xxxxxxxxx>
Date: Wed, 9 May 2001 07:57:46 -0700 (PDT)
The enclosed XML produces the following output:

Title
- first ReplyTitle
- Reply SecondTitle
Second Title

You may have to play with the <content> tag placement as I wasn't 
clear if you wanted one outer content or one for each message 
thread.

Regards,

Dan
-----------------
File: 9May2001Messages.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="9May2001Messages.xsl"?>

<Main> 
 <Message> 
  <id>15</id> 
  <parentID>0</parentID> 
  <title>Title</title> 
 </Message> 
 <Message> 
  <id>17</id> 
  <parentID>0</parentID> 
  <title>Second Title</title> 
 </Message> 
 <Reply> 
  <id>16</id> 
  <parentID>15</parentID> 
  <title>first ReplyTitle</title> 
 </Reply> 
 <Reply> 
  <id>18</id> 
  <parentID>15</parentID> 
  <title>Reply SecondTitle</title> 
 </Reply> 
</Main> 


File: 9May2001Messages.xsl
<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 <xsl:template match="/">
  <xsl:apply-templates select="Main"/>
 </xsl:template>

 <xsl:template match="Main">
  <content>
  <xsl:for-each select="Message[parentID='0']">
   <xsl:value-of select="title"/><br/>
    <xsl:variable name="ID" select="id"/>
    <xsl:for-each select="../Reply[parentID=$ID]">
    - <xsl:value-of select="title"/><br/>
   </xsl:for-each>     
  </xsl:for-each>
  </content>
 </xsl:template>
</xsl:stylesheet>

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread