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

Nested XML elements to HTML

Subject: Nested XML elements to HTML
From: "Schachter, Michael" <MSchachter@xxxxxxxxxxxxx>
Date: Mon, 7 Aug 2000 15:50:57 -0400
nested xml elements
Hi,

I'm having a problem converting xml elements that are in a nested format to
html that would be presentable.

Here is an example of what the xml looks like:

<discussion>
   <post id="33">
      <author>mike</author>
      <date>2000-06-22 15:02:12</date>
      <subject>Test Thread 1</subject>
      <data>parent test 1</data>

      <post id="36">
         <author>mike</author>
         <date>2000-06-22 15:04:00</date>
         <subject>Test Thread 1-a</subject>
         <data>nothin</data>
      </post>

      <post id="37">
         <author>john</author>
         <date>2000-06-22 15:04:30</date>
         <subject>Test Thread 1-b</subject>
         <data>nothing also</data>
      </post>
         
         <post id="45">
            <date>2000-06-22 15:05:30</date>
            <subject>Test Thread 1-b-1</subject>
            <data>I second that.</data>
         </post>

      <post id="39">
         <author>mike</author>
         <date>2000-06-22 15:05:00</date>
         <subject>Test Thread 1-c</subject>
         <data>heh.</data>
      </post>
   </post>
</discussion>

Here is what I want the html to look like:

   <blockquote>
      <b>Test Thread 1 by mike @ 2000-06-22 15:02:12</b>
      <br />parent test 1

      <blockquote>
         <b>Test Thread 1-a by mike @ 2000-06-22 15:04:00</b>
         <br>nothin
      </blockquote>

      <blockquote>
         <b>Test Thread 1-b by john @ 2000-06-22 15:04:30</b>
         <br>nothing also
      
         
         <blockquote>
            <b>Test Thread 1-b-1 by mike @ 2000-06-22 15:05:30</b>
            <br>I second that.
         </blockquote>  

      </blockquote>

      <blockquote>
         <b>Test Thread 1-c by mike @ 2000-06-22 15:05:00</b>
         <br>heh.
      </blockquote>
   </blockquote>

Here is the stylesheet I'm using, of course, it doesn't work.  The problem
is that it parses right through the node structure logically instead of
straight up text-replacement (well, thats not really a problem, but it makes
this difficult for me to get it to work):

<?xml version="1.0" ?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
<xsl:output method="xml"/> 
   <xsl:template match="discussion">
      <xsl:for-each select="/descendant::post">
         <blockquote>
            <b>
               <xsl:value-of select="subject" /> by 
               <xsl:value-of select="author" />
               @ <xsl:value-of select="date" />
            </b>
            <br />
            <xsl:value-of select="data" />
	</blockquote>
      </xsl:for-each>
   </xsl:template>
</xsl:stylesheet>

Any help whatsoever would be greatly appreciated, thanks.




 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-2011 All Rights Reserved.