these are aaronland.infoxsl tools

rels to unordered lists

This stylesheet has been deprecated in favour of the links to unordered lists stylesheet.

Version 1.1 of this stylesheet was released to provide a bridge between this and the newer stylesheet for people who may be including previous versions in their XSL documents. It is no longer being actively developed.

This stylesheet defines two templates named ListAllRels and ListOneRel which will create one, or more, unordered lists based on the <link> elements in the source document.

List items are grouped according to the rel attribute. Elements whose rel attribute is 'stylesheet' are explictly excluded.

The current version of the rels to unordered lists stylesheet is 1.1.

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 = "rels-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
          rels-to-unordered-lists stylesheet
          imported above -->
     <xsl:call-template name = "ListAllRels" />


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

extending the stylesheet

If you're not wild about unordered lists you can redefine the ListOneRel template in your stylesheet.

This is the template called by the ListAllRels template for each disctinct link/@rel attribute.

This is an example of how to modify the template to create a "horizontal" navigation menu that is suitable for text browsers but than can also be rendered or positioned in a CSS-enabled browser.

# 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.