Skip to content

Creating a threaded comment generator with XSL

by Cory Foy on November 23rd, 2004

I got an email from a friend of mine who is building a BBS app that he wants to have threaded comments. Basically:

- This is the top post

   - This is the reply to the top

      - This is the reply to the reply

He’s using classic ASP, and was looking for a way to avoid having to do a recursive query to get the information. At first I was thinking of some SQL strategies to help avoid it but then thought that XML might be a good answer to it.

XML Document:





   
      

      I'm a top level thread

   

   
      

      I'm a top level2 thread

   

   
      

      I'm a mid level thread

   

   
      

      I'm a mid level thread

   

   
      

      I'm a mid level thread

   

   
      

      I'm a mid level thread

   

   
      

      I'm a top level3 thread

   

XSL Document:







   

      

         

      

      

         

Here is some cool BBS type stuff:

         

      


   



   


       

          
  •       

             

          


       

       



   

   


       

          
  •       

             

          


       

       



Output:



     
  • I'm a top level thread
  •  


         
    • Mid Level Thread
    •    


              
      • Mid Level Thread
      •    

         

    • Mid Level Thread
    •  

From → Uncategorized

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS