Re: [xsl] Displaying one node at a time

Subject: Re: [xsl] Displaying one node at a time
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Mon, 04 Jul 2005 20:42:15 +0200
Hi,

Tempore 20:02:06, die 07/04/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Fadi Qutaishat <fadi_taher2000@xxxxxxxxx>:

How can I display one chunk at a time, for example,
using a next link.

But word 'link' in this context seems to imply html.


Just a wild guess, but I think your looking for a stylesheet that generates DHTML to dynamically browse your page's chunks:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:output method="html" indent="yes" encoding="UTF-8" omit-xml-declaration="yes"/>


<xsl:template match="/">
	<html>
		<head>title
		<script type="text/javascript">
		function show(id) {
		var block=document.getElementsByTagName('div');
		for (i=0;i &lt; block.length;i++) {
			block[i].style.display='none';
		}
		document.getElementById(id).style.display='block';
		}
		</script>
		</head>
		<body onload="show('{//chunk/@id[1]}')">
			<xsl:apply-templates/>
		</body>
	</html>
</xsl:template>

<xsl:template match="page">
<h1>My page</h1>
<ul>
<xsl:for-each select="chunk">
<li><a href="javascript: show('{@id}')">chunk <xsl:value-of select="@id"/></a></li>
</xsl:for-each>
</ul>
<xsl:apply-templates/>
</xsl:template>


<xsl:template match="chunk">
<div id="{@id}" style="display: none">
<h2>chunk <xsl:value-of select="@id"/></h2>
<p><xsl:apply-templates/></p>
<xsl:if test="position()!=1">
<a href="javascript: show('{preceding-sibling::chunk[1]/@id}')">&lt;&lt;previous chunk |</a>
</xsl:if>
<xsl:if test="position()!=last()">
<a href="javascript: show('{following-sibling::chunk[1]/@id}')">| next chunk&gt;&gt;</a>
</xsl:if>
</div>
</xsl:template>


</xsl:stylesheet>

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Spread the wiki (http://www.wikipedia.org)

Current Thread