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

source

www.aaronland.info/xsl/xhtml/links-to-unordered-lists/links-to-unordered-lists-v1.0.xsl

example

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

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:x="http://www.w3.org/XML/1998/namespace"
    xmlns:h="http://www.w3.org/1999/xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    exclude-result-prefixes="h"
    version="1.0">

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

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

  <xsl:template match="/">

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

    <!-- 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" />

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

     <xsl:copy-of 
          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" />

    </body>
   </html>
  </xsl:template>

</xsl:stylesheet>
xsltproc \
 -o /path/to/xhtml-file.html \
 /path/to/your-stylesheet.xsl
 /path/to/xhtml-file.xml
   

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" />

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

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

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

     <xsl:if test = "position() &lt; $count">|</xsl:if>
    </span> 
   </xsl:for-each>]
  </span>

</xsl:template>
   

license

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.