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

RE: Generating multi-level recursive nested lists??

Subject: RE: Generating multi-level recursive nested lists??
From: "Arne Borkowski \(borko.net\)" <arne@xxxxxxxxx>
Date: Tue, 10 Apr 2001 02:21:55 +0200
a level re
Hi Paul,

I tried some changes and I guess I did in the way you'd like it.
Give it a try ...

By the way ... I think you should not worry about Cocoon instructions,
but I use it and tested it with that.

----------8<-------------- "my" XSL stylesheet -------------

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/">
  <xsl:processing-instruction
name="cocoon-format">type="text/html"</xsl:processing-instruction>
    <HTML>
      <BODY>
         <H1><xsl:value-of select="toc/title"/></H1>

		<ol>
        	<xsl:apply-templates select="toc/folder"/>
		</ol>

      </BODY>
    </HTML>
  </xsl:template>


  <xsl:template match="folder">
	 <li id="foldheader"><xsl:value-of select="foldertitle"/></li>
     <xsl:apply-templates />
  </xsl:template>


  <xsl:template match="folder/folder">
  	<ol>
 	  <LI id="foldheader"><xsl:value-of select="foldertitle"/></LI>
      <xsl:apply-templates />
	</ol>
  </xsl:template>

  <xsl:template match="list">
    <ol id="foldinglist">
      <xsl:for-each select="file">
        <li>
	    <xsl:value-of select="." />
	    <xsl:apply-templates />
	</li>
      </xsl:for-each>
    </ol>
  </xsl:template>

  <xsl:template match="file">
    <xsl:value-of select="."/>
  </xsl:template>

  <xsl:template match="text()">
<!--    <xsl:value-of select="." />
 -->
  </xsl:template>

</xsl:stylesheet>

-----8<---------- "my" HTML output ------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<HTML>
<BODY>
 <H1>Paul's XML Test</H1>

 <ol>
	<li id="foldheader">Software<ol id="foldinglist">
		<li>outer 1
		<li>outer 2
 </ol>
 <ol>
	<LI id="foldheader">Nested<ol id="foldinglist">
		<li>nested 1
		<li>nested 2
 </ol>
</ol>
	<li id="foldheader">Software2<ol id="foldinglist">
		<li>outer 1b
		<li>outer 2b
</ol>
</ol>
</BODY>
</HTML>
<!-- This page was served in 63 milliseconds by Cocoon 1.8.2 -->



Maybe I was wrong with what you really wanted ... however it seemed
close for me ...

Regards, Arne Borkowski
Hamburg / Germany




> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Paul Foege
> Sent: Tuesday, April 10, 2001 12:28 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Generating multi-level recursive nested lists??
>
>
> Hello
>
> I have been struggling with this for the last few days, and I
> can't seem to
> get it to work.  I contacted some other supposed "XML/XSL
> Experts" and they
> couldn't help me.  Any help would be greatly appreciated.
>
>
> I have the following xml:
>
> <toc>
> 	<title>Paul's XML Test</title>
> 	<folder>
> 	    <foldertitle>Software</foldertitle>
>
> 	    <list>
> 	    	<file>outer 1</file>
> 	    	<file>outer 2</file>
> 	    </list>
>
> 		<folder>
> 	    		<foldertitle>Nested</foldertitle>
> 	    		<list>
> 	      		<file>nested 1</file>
> 	      		<file>nested 2</file>
> 	     		</list>
> 	   	</folder>
>
> 	</folder>
>
> 	<folder>
> 		 <foldertitle>Software2</foldertitle>
> 			<list>
> 	    			<file>outer 1b</file>
> 	    			<file>outer 2b</file>
> 	   		</list>
> 	</folder>
>
> </toc>
>
>
> I am trying to apply an XSL style sheet to produce the following HTML:
>
> 	<ul>
>
> 	   <li id="foldheader">Software</li>
> 	   <ul id="foldinglist">
> 	      <li>outer 1</li>
> 	      <li>outer 2</li>
> 	      <li id="foldheader">Nested</li>
>
> 		  <ul id="foldinglist">
> 	         <li>nested 1</li>
> 	         <li>nested 2</li>
> 	        </ul>
> 	   </ul>
>
> 	   <li id="foldheader">Software2</li>
> 	   <ul id="foldinglist">
> 	      <li>outer 1</li>
> 	      <li>outer 2</li>
> 	   </ul>
>
> 	</ul>
>
>
> Here is my XSL:  It messes up on the nesting level of my <LI>s.
>
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
>
>   <xsl:template match="/">
>     <HTML>
>       <BODY>
>
>          <H1><xsl:value-of select="toc/title"/></H1>
>
> 		<ol>
>         	<xsl:apply-templates select="toc/folder"/>
> 		</ol>
>
>       </BODY>
>     </HTML>
>   </xsl:template>
>
>
>   <xsl:template match="folder">
> 	 <li id="foldheader"><xsl:value-of select="foldertitle"/></li>
>      <xsl:apply-templates />
>   </xsl:template>
>
>
>   <xsl:template match="folder/folder">
>   	<ol>
>  	  <LI id="foldheader"><xsl:value-of select="foldertitle"/></LI>
>       <xsl:apply-templates />
> 	</ol>
>   </xsl:template>
>
>
>   <xsl:template match="list">
>     <ol id="foldinglist">
>       <xsl:for-each select="file">
>         <li><xsl:apply-templates /></li>
>       </xsl:for-each>
>     </ol>
>   </xsl:template>
>
>
>   <xsl:template match="text()"><xsl:value-of />
>   </xsl:template>
>
> </xsl:stylesheet>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>

Attachment: smime.p7s
Description: S/MIME cryptographic signature

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.