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

RE: Urgent : Nested List Help

Subject: RE: Urgent : Nested List Help
From: Pieter Reint Siegers Kort <pieter.siegers@xxxxxxxxxxx>
Date: Thu, 3 Feb 2005 17:08:35 -0600
xsl ul
Hi Sefa,

Just delete

<xsl:template match="link/link">

		<li>
					<xsl:value-of select="@name"/>
		</li>

	<ul>
		<xsl:apply-templates />
	</ul>
</xsl:template>

from your stylesheet.

HTH,
<prs/> 

-----Original Message-----
From: Sefa Sevtekin [mailto:sevtekin@xxxxxxxxxxx] 
Sent: Thursday, February 03, 2005 3:58 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Urgent : Nested List Help

Hi, I am trying to transform an XML file by using XSL and display it as
html. Here is the XML:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="links.xsl"?> <links>
    <link name="1">
		<link name="1.1" url="#"/>
		<link name="1.2">
			<link name="1.2.1"/>
			<link name="1.2.2"/>
		</link>
    </link>
    <link name="2">
		<link name="2.1">
			<link name="2.1.1"/>
			<link name="2.1.2"/>
			<link name="2.1.3"/>
		</link>
		<link name="2.2">
			<link name="2.2.1"/>
			<link name="2.2.2"/>
			<link name="2.2.3"/>
		</link>
		<link name="2.3"/>
    </link>
    <link name="3"/>
</links>

and here is the XSL:

<?xml version="1.0"  encoding="UTF-8" ?> <xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
</head>
<body>

	<ul>
		<xsl:apply-templates select="links/link"/>
	</ul>


</body>
</html>
</xsl:template>

<xsl:template match="link">
			<li>
				<xsl:value-of select="@name"/>
			</li>
			<xsl:apply-templates />
</xsl:template>

<xsl:template match="link/link">

		<li>
					<xsl:value-of select="@name"/>
		</li>

	<ul>
		<xsl:apply-templates />
	</ul>
</xsl:template>
</xsl:stylesheet>

and here is the output html:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <html>
<head> </head> <body>
    <ul>
      <li>1</li>
      <li>1.1</li>
      <ul>
      </ul>
      <li>1.2</li>
      <ul>
        <li>1.2.1</li>
        <ul>
        </ul>
        <li>1.2.2</li>
        <ul>
        </ul>
      </ul>
      <li>2</li>
      <li>2.1</li>
      <ul>
        <li>2.1.1</li>
        <ul>
        </ul>
        <li>2.1.2</li>
        <ul>
        </ul>
        <li>2.1.3</li>
        <ul>
        </ul>
      </ul>
      <li>2.2</li>
      <ul>
        <li>2.2.1</li>
        <ul>
        </ul>
        <li>2.2.2</li>
        <ul>
        </ul>
        <li>2.2.3</li>
        <ul>
        </ul>
      </ul>
      <li>2.3</li>
      <ul>
      </ul>
      <li>3</li>
    </ul>
</body>
</html>


The problem is xsl creates empty  <ul></ul> in between. Can you help me fix
it?

Thanks

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.