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

Urgent Help Needed in XSLT

Subject: Urgent Help Needed in XSLT
From: "Kong, Yan" <KongY@xxxxxxxxxxx>
Date: Fri, 20 Sep 2002 16:44:29 -0400
llnode
Hi XSLT Professionals,

I'm a beginner of XSLT.  I have following XML that used by a discussion group:

<?xml version="1.0" encoding="ISO-8859-1"?>
<livelink applanguage='USA' appversion='9.1.0' dtdversion='1.2'>
	<llnode created='2002-09-19T14:42:37' name='1st Topic' objname='Topic' size='0'>
		<message>1st Topic in Char</message>
	</llnode>
	<llnode created='2002-09-19T14:42:50' name='2nd Topic' objname='Topic' size='0'>
		<message>2nd Topic in Char</message>
	</llnode>
	<llnode created='2002-09-19T14:43:01' name='3rd Topic' objname='Topic' size='0'>
		<message>3rd Topic</message>
	</llnode>
	<llnode created='2002-09-19T14:43:09' name='4th Topic' objname='Topic' size='0'>
		<message>4th Topic</message>
	</llnode>
	<llnode created='2002-09-19T14:43:18'  name='5th Topic' objname='Topic' size='2'>
		<message>5th Topic</message>
		<llnode created='2002-09-19T14:44:47' name='1st Reply'  objname='Reply' size='1'>
			<message>1st Reply</message>
			<llnode created='2002-09-19T14:47:59' name='reply'  objname='Reply' size='1'>
              			<message>reply</message>
	              		<llnode created='2002-09-19T15:09:54' name='reply'  objname='Reply' size='1'>
               				<message>reply</message>
                				<llnode created='2002-09-19T15:14:17' name='reply'  objname='Reply' size='0'>
                 					<message>reply</message>
                				</llnode>
              			</llnode>
            		</llnode>
		</llnode>
		<llnode created='2002-09-19T14:49:36' name='reply' objname='Reply' size='0'>
			<message>reply</message>
		</llnode>
	</llnode>
	<llnode created='2002-09-19T14:49:08' name='6th Topic' objname='Topic' size='1'>
		<message>6th Topic</message>
		<llnode created='2002-09-19T14:53:47' name='reply' objname='Reply' size='0'>
			<message>reply</message>
		</llnode>
	</llnode>
	<llnode created='2002-09-19T14:42:04' name='7th Topic' objname='Topic' size='0'>
		<message>7th Topic</message>
	</llnode>
	<llnode created='2002-09-19T14:43:26' name='8th Topic' objname='Topic' size='1'>
		<message>8th Topic</message>
		<llnode created='2002-09-19T14:44:34' name='1st Reply' objname='Reply' size='1'>
            		<message>1st Reply</message>
            		<llnode created='2002-09-19T14:50:09' name='reply' objname='Reply' size='0'>
              			<message>reply</message>
            		</llnode>
         		</llnode>
       	</llnode>
	<llnode created='2002-09-19T14:41:36' name='9th Topic' parentid='-267307' size='0'>
		<message>9th Topic</message>
	</llnode>
	<llnode created='2002-09-19T14:41:53' name='10th Topic' parentid='-267307' size='0'>
		<message>10th Topic</message>
	</llnode>
	<llnode created='2002-09-19T15:02:00' name='11th Topic' parentid='-267307' size='1'>
		<message>11th Topic</message>
		<llnode created='2002-09-19T15:03:10' name='reply' parentid='268284' size='1'>
			<message>reply</message>
			<llnode created='2002-09-19T15:04:52' name='reply' parentid='268285' size='1'>
				<message>reply</message>
				<llnode created='2002-09-19T15:06:37' name='reply' parentid='268504' size='0'>
					<message>reply</message>
				</llnode>
			</llnode>
		</llnode>
	</llnode>
	<llnode created='2002-09-19T14:41:36' name='12th Topic' parentid='-267307' size='0'>
		<message>12th Topic</message>
	</llnode>
	......
</llnode>
</livelink>

I need to create a html to get the latest 10 Discussion Topic.  I did following XSLT:

<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" > 
	<xsl:output method = "html" /> 
	<xsl:template match="livelink">
		
	<html>
	<body>	
	<table>
	
	<tr>
		<td><b><br/>Latest Discussion Posts
		</b></td>
	</tr>
	
		<xsl:for-each select="//*[@objname='Topic'] | //*[@objname='Reply']">
			<xsl:sort select="@created" order="descending" />
				<xsl:if test="position() &lt; 11">
	<tr>
		<td>
				<xsl:value-of select="ancestor-or-self::*[@objname='Topic']/@name" />
				<xsl:text> - </xsl:text>
				<xsl:value-of select="@created" />
		</td>
	</tr>
				</xsl:if>
		</xsl:for-each>
	</table>
	</body>
	</html>
	</xsl:template>
	
</xsl:stylesheet> 

The output is as follows:

Latest Discussion Posts 
5th Topic - 2002-09-19T15:14:17
5th Topic - 2002-09-19T15:09:54
11th Topic - 2002-09-19T15:06:37
11th Topic - 2002-09-19T15:04:52
11th Topic - 2002-09-19T15:03:10
11th Topic - 2002-09-19T15:02:00
......

The above output isn't what I want.  I want each topic only display once.

I have struggled with the problem for three days.  Could you please help me with this?  I will really appreciate it.

Thanks in advance,
Yan

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


Current Thread
  • Urgent Help Needed in XSLT
    • Kong, Yan - Fri, 20 Sep 2002 16:42:51 -0400 (EDT) <=
      • Marrow - Fri, 20 Sep 2002 18:13:59 -0400 (EDT)
      • <Possible follow-ups>
      • Kong, Yan - Mon, 23 Sep 2002 10:57:09 -0400 (EDT)
        • Marrow - Mon, 23 Sep 2002 11:29:19 -0400 (EDT)

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.