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

RE: How to sort this xml out

Subject: RE: How to sort this xml out
From: Dan Diebolt <dandiebolt@xxxxxxxxx>
Date: Wed, 9 May 2001 07:57:46 -0700 (PDT)
sort in xml
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

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.