<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:include href="login.xsl"/>

  <xsl:output method="html" version="4.01"
      encoding="UTF-8" indent="yes"
      doctype-public="-//W3C//DTD HTML 4.01//EN"
      doctype-system="http://www.w3.org/TR/html4/strict.dtd"/>

  <xsl:template match="tags">

    <xsl:variable name="title">Tags for <xsl:value-of select="name"/></xsl:variable>

<html>
  <head>
    <title><xsl:value-of select="$title"/></title>
  </head>
  <body>
    <h1><xsl:value-of select="$title"/></h1>

    <xsl:variable name="login" select="document('login.php')/login/user"/>

    <xsl:apply-templates select="$login"/>

    <ul id="tagList">
    <xsl:for-each select="tag">
      <li>
        <a href="tag.php?id={@id}" 
          title="{concat('Nodes with tag ', .)}"><xsl:value-of select="."/></a>
      </li>
    </xsl:for-each>
    </ul>

    <xsl:if test="$login != ''">
      <xsl:call-template name="tagForm"/>
    </xsl:if>



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

  <xsl:template name="tagForm">
    <div id="tagForm">
      <h2>Add a tag to this node</h2>
      <form method="post" action="tagNode.php">
        <p>
          <input name="nodeid" type="hidden" value="{@nodeid}"/>
          <label for="tagField">Tag name:</label>
          <input id="tagField" name="tagname" type="text"/>
          <input type="submit" value="Add tag"/>
        </p>
      </form> 
    </div>
 </xsl:template>

</xsl:stylesheet>

