these are aaronland.infoxsl tools

links to unordered lists

This stylesheet creates one, or more, unordered lists based on the <link> elements in the source document.

List items are grouped according to their rev or rel attributes. Elements whose rel attribute is 'stylesheet' are explictly excluded.

The current version of the links to unordered lists stylesheet is 1.0.

released December 14, 2002



# file:///path/to/your-stylesheet.xsl

<?xml version="1.0" encoding="utf-8"?>

  <!-- doctype stuff removed 
       for the sake of brevity -->
  <xsl:output method="xml"/>

  <xsl:include href = "links-to-unordered-lists.xsl" />

  <xsl:template match="/">

    <xsl:attribute name = "x:lang">
     <xsl:value-of select = "/h:html/@x:lang" />

    <!-- note that this will probably add
         a 'profile=""' attribute to your head
         element. don't worry, it's actually
         part of the spec, not that I've ever
         seen anyone use it... -->
    <xsl:copy-of select = "/h:html/h:head" />

     <xsl:for-each select="/h:html/h:body/@*">
      <xsl:attribute name="{name()}">
       <xsl:value-of select="."/>

          select = "/h:html/h:body/child::node()" />

     <!-- this template is defined in the
          links-to-unordered-lists stylesheet
          imported above -->
     <xsl:call-template name = "ListAllLinks" />


xsltproc \
 -o /path/to/xhtml-file.html \

extending the stylesheet

If you're not wild about unordered lists you can redefine either the ListOneRel or ListOneRev templates in your stylesheet.

These are called by the ListAllLinks template for each disctinct link/@rev or link/@rel grouping.

This is an example of how to modify the template to create a "horizontal" navigation menu for your forward links.

# prints a menu in the form of 
# [title|title][title]

<xsl:template name = "ListOneRel">

 <!-- this is a string containing the
      value of the @rel attribute, not 
      a node -->
 <xsl:param name = "rel" />

  <xsl:attribute name = "class">
   rel-link-<xsl:value-of select = "$rel" />

        select = "/h:html/h:head/h:link[@rel = $rel]">
     <xsl:attribute name = "class">
      <xsl:attribute name = "href">
       <xsl:value-of select = "@href" />
      <xsl:attribute name = "title">
       <xsl:value-of select = "@title" />
      <xsl:value-of select = "@title" />

     <xsl:variable name = "count" value-of =
          "count(/h:html/h:head/h:link[@rel = $rel])" />

     <xsl:if test = "position() &lt; $count">|</xsl:if>



Copyright © 2002 Aaron Straup Cope. All Rights Reserved.

Permission to use, copy, modify and distribute this stylesheet and its acompanying documentation for any purpose and without fee is hereby granted in perpetuity, provided that the above copyright notice and this paragraph appear in all copies. The copyright holders make no representation about the suitability of the stylesheet for any purpose.

It is provided "as is" without expressed or implied warranty.