xsl-list
[Top] [All Lists]

Re: Displaying one node at a time

2005-07-04 11:42:15
Hi,

Tempore 20:02:06, die 07/04/2005 AD, hinc in xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Fadi Qutaishat <fadi_taher2000(_at_)yahoo(_dot_)com>:

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('{(_at_)id}')">chunk <xsl:value-of select="@id"/></a></li>
                 </xsl:for-each>
        </ul>
        <xsl:apply-templates/>
</xsl:template>

<xsl:template match="chunk">
        <div id="{(_at_)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)

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>