<<<?xml version="1.0">>>

# This is a snippet of XSLT.  To convert it into the more-common
# XML form, use the following command:
#
#    pxslcc --indent xsl-stylesheet-01.pxsl > xsl-stylesheet-01.xsl

xsl:stylesheet \
  -version=1.0 \
  -extension-element-prefixes=func \
  -xmlns:xml=http://www.w3.org/XML/1998/namespace \
  -xmlns:mcf=http://moertel.com/xsl/1.0/functions \
  -xmlns:func=http://exslt.org/functions \
  -xmlns:xsl=http://www.w3.org/1999/XSL/Transform

  func:function -name=mcf:vertical-menu
    xsl:param -name=menu
    xsl:param -name=target-absloc
    func:result
      div -class=vmenu
        div -class=vmenu-items
          xsl:for-each -select=$menu/*
            xsl:if -test=self::menu
              xsl:copy-of -select=mcf:vertical-menu(.,$target-absloc)
            xsl:if -test=<{self::title or self::menu-item}>
              xsl:variable -name=menu-absloc -select=mcf:absloc()
              xsl:variable -name=mm-item-id \
                -select=mcf:maximal-matching-item($menu,$target-absloc)
              xsl:if -test=self::title
                xsl:variable -name=title \
                  -select=mcf:menu-title($menu,$target-absloc)
                xsl:choose
                  xsl:when -test=generate-id()=$mm-item-id
                    div -class=vmenu-title-selected
                      xsl:apply-templates -select=$title
                  xsl:otherwise
                    div -class=vmenu-title
                      a -href={mcf:menu-link($menu-absloc)}
                        xsl:apply-templates -select=$title
              xsl:if -test=self::menu-item
                xsl:choose
                  xsl:when -test=generate-id()=$mm-item-id
                    div -class=vmenu-item-selected
                      xsl:apply-templates
                  xsl:otherwise
                    div -class=vmenu-item
                      a -href={mcf:menu-link($menu-absloc)}
                        xsl:apply-templates
