This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Nested XML elements to HTML
- To: "'xsl-list at mulberrytech dot com'" <xsl-list at mulberrytech dot com>
- Subject: Nested XML elements to HTML
- From: "Schachter, Michael" <MSchachter at bluestone dot com>
- Date: Mon, 7 Aug 2000 15:50:57 -0400
- Reply-To: xsl-list at mulberrytech dot com
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