Example 17-29: Library stylesheet to handle formatting of actions bar

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <!--
   | UtilActions.xsl: Transform <actions> structural info
   |                  into HTML "action bar" presentations.
   +-->
  <xsl:template match="actions">
    <xsl:variable name="LoginPage" select="'Login.xsql'"/>
    <!-- User is logged in if forumuser cookie is present -->
    <xsl:variable name="LoggedIn"
       select="boolean(/page/request/cookies/forumuser)"/>
    <center>
      <span class="actions">
        <xsl:for-each select="link">
          <a>
            <xsl:attribute name="href">
              <xsl:choose>
                <xsl:when test="@login='yes' and not($LoggedIn)">
                  <xsl:value-of select="$LoginPage"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="@page"/>
                  <xsl:if test="*">?</xsl:if>
                  <xsl:for-each select="*">
                    <xsl:value-of select="name(.)"/>
                    <xsl:text>=</xsl:text>
                    <xsl:value-of select="."/>
                    <xsl:if test="position() != last()">
                      <xsl:text>&amp;</xsl:text>
                    </xsl:if>
                  </xsl:for-each>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:attribute>
            <xsl:if test="@login='yes' and not($LoggedIn)">Login to </xsl:if>
            <xsl:value-of select="@label"/>
          </a>
        </xsl:for-each>
      </span>
    </center>
    <hr/>
  </xsl:template>
</xsl:stylesheet>