logo

View Navigation With XSL

What is it with XSL? It's one of those languages that you use so infrequently that, each time you do, you face the same learning curve as the last time. Or maybe that's just me.

Yesterday I was playing with XSL again. Once I'd got back up the curve I had some fun seeing what I could do with Domino's View XML, sorry, DXL. It's amazing what you can do with XSL(T?).

Remember my article called Sensible Web Navigation? It described how to work out the number of documents in a view, so that we can work out whether to show the next/previous page links.

Well you can do this fairly easily with the DXL for a view. The image on the right shows a snippet DXL for this site's Feedback view. The URL used to get the XML is like:

/store.nsf/feedback?readviewentries&start=23&count=10

Notice a couple of things in the XML: the root node (viewentries) contains the "toplevelentries" parameter, which tells us how many documents are in the view. Plus, each document's node (viewentry) has a "position" attribute to tell us its place in the view. Using this information we can create the Next/Previous links using XSL. Here's how.

First thing we need is three variables in our XSL:

<xsl:variable name="ViewTotal" select="number(/viewentries/@toplevelentries)" />
<xsl:variable name="ViewPageStart" select="number(//viewentry[1]/@position)"/>
<xsl:variable name="ViewPageEnd" select="number(//viewentry[last()]/@position)"/>

Using these values we can decide whether to add a More » link. Like so:

<xsl:if test="$ViewPageEnd &lt; $ViewTotal">
<xsl:element name="a">
<xsl:attribute name="href">feedback?OpenView&amp;start=<xsl:value-of select="$ViewPageEnd + 1"/>&amp;count=10</xsl:attribute>
<xsl:text disable-output-escaping="yes">More &amp;raquo;</xsl:text>
</xsl:element>
</xsl:if>

The code for the « Previous is too similar to bother showing. Easy though ain't it?!

Why was I doing this? Well, I needed to fetch a user's email from their Mail database and display it as a "view" in a website. At some point I'll try and package the code in to a sample database and write an article called View Navigation With XSL. In the mean time, if you want to read about XSL and see some example code, this is a good place to start.

Comments

  1. Not sure if you've seen this article, but it's along the same lines (view navigation) using AJAX.

    {Link}

    • avatar
    • tani
    • Thu 14 Jul 2005 08:36

    Comment 2 to that article says yes he has! =)

    Dangit' all. I was gonna start looking at this after the Tour De France was done. Darn OLN coverage in the evening keeps me too busy to look at stuff like this. =/

    I can't wait to dive into it!

    • avatar
    • Jake Howlett
    • Thu 14 Jul 2005 09:19

    Yeah, I've seen Bob's article. It's a good'en. But it's quite different to what I've been doing, although still similar.

  2. I like both articles enough that I will combine them today. An AJAX request to readviewentries, XSLT to organize, and the different nav format.

    Good stuff, and another RSS feed!!

    • avatar
    • Brandon
    • Thu 14 Jul 2005 13:01

    OFF TOPIC (but a very cool concept that could work well for Domino developers):

    {Link}

    • avatar
    • David Schmidt
    • Fri 15 Jul 2005 03:41

    {Link}

    {Link}

    {Link}

    {Link}

    http://free.corefusion.net/Free/wausau/home.nsf/$$NavigatorTemplateDefault?OpenForm

    {Link}

    {Link}

    {Link}

    {Link}

    {Link}

    {Link}

    {Link}

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Thu 14 Jul 2005

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

Elsewhere

Here are the external links posted on the same day.

More links are available in the archive »

More Content