<?xml version='1.0'?><!-- -*- mode: indented-text;-*- -->
<xsl:transform
    xmlns:xsl  ="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:web  ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:u    ="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:mtg  ="http://www.w3.org/2000/11/mr76/minutes#"
    xmlns:email="#"
    xmlns:dist ="#"
    >

<!--@@  xmlns:email="http://www.w3.org/2000/04/maillog2rdf/email#" -->

<xsl:output method="xml" indent="yes"/>

<div xmlns="http://www.w3.org/1999/xhtml">

<address>Dan Connolly <br class=""/>
$Id: minutes2html.xsl,v 1.3 2001/05/25 18:02:28 connolly Exp $</address>
</div>

<xsl:variable name="MeetingNS"
	      select='"http://www.w3.org/2000/11/mr76/minutes#"'/>

<xsl:template match="/web:RDF">
  <xsl:call-template name="meeting-minutes">
    <xsl:with-param name="this"
		    select='*[mtg:agenda]'/>
  </xsl:call-template>
</xsl:template>

<xsl:template name="meeting-minutes">
  <xsl:param name="this"/>

  <xsl:variable name="mtgDate"
		select='$this/mtg:date'/>

  <html>
    <head profile="@@">
      <title>Minutes of a meeting held <xsl:value-of select="$mtgDate"/></title>
    </head>
    <body>
      <p class="@@:context">
        <!-- hmm... would like to do backchaining to
	     get closure of supertypes; this is a limited hack -->
        <xsl:for-each select="$this/web:type/@web:resource">
          <xsl:variable name="clsElt" select='/web:RDF/*[@web:about=current()]'/>

	  <xsl:call-template name="describe-type">
	    <xsl:with-param name="clsElt" select='$clsElt'/>
	  </xsl:call-template>

	  <xsl:call-template name="describe-supertypes">
	    <xsl:with-param name="clsElt" select='$clsElt'/>
	  </xsl:call-template>

        </xsl:for-each>

      <xsl:variable name="prevRef" select="$this/mtg:previous/@web:resource"/>
      <xsl:if test="$prevRef">
        <br class=''/>Previous:
	  <xsl:call-template name="aLink">
	    <xsl:with-param name="ref" select='$prevRef'/>
	    <xsl:with-param name="label">
	      <xsl:variable name="prevMtgElt"
			    select='/web:RDF/*[mtg:record/@web:resource=$prevRef]'/>
              <xsl:value-of select="$prevMtgElt/mtg:date"/>
            </xsl:with-param>
	  </xsl:call-template>
      </xsl:if>
      </p>


      <h1>Minutes <xsl:value-of select="$mtgDate"/></h1>

      <xsl:call-template name="attendance">
        <xsl:with-param name="whoRef" select='$this/mtg:roll/@web:resource'/>
      </xsl:call-template>

      <xsl:call-template name="agenda">
        <xsl:with-param name="whatRef" select='$this/mtg:agenda/@web:resource'/>
        <xsl:with-param name="callRef" select="$this/mtg:meetingCall/@web:resource"/>
      </xsl:call-template>

      <xsl:call-template name="summary">
        <xsl:with-param name="whatRef" select='$this/mtg:agenda/@web:resource'/>
      </xsl:call-template>

    <hr class=''/>
    <address>@@who, scribe for @@who, chair; not yet reviewed by the participants<br class=''/>
    <small>formatting with $Id: minutes2html.xsl,v 1.3 2001/05/25 18:02:28 connolly Exp $; see <a href="http://www.w3.org/2000/11/mr76/">RDF meeting records</a></small>
    </address>
    </body>
  </html>
</xsl:template>    

<xsl:template name="attendance">
  <xsl:param name="whoRef"/>

  <!-- hmm... enhancement:
       long form, with full names,
       list affiliation, or $who/represents/$org-group
    -->

  <xsl:variable name="whoElt" select='/web:RDF/*[@web:about=$whoRef]'/>

  <div class="attendance">
    <p><strong>Present:</strong>

      <!-- Another little idiom to write up...
           RDF sequence items have these funny _1 _2 _3 names
        -->
      <!-- @@hack: need to match against the RDF namespace too... -->
      <xsl:for-each select="$whoElt/*[number(substring(local-name(), 2))>0]">
        <!-- @@sort by name, acutally -->
        <xsl:sort select='number(substring(local-name(), 2))' data-type="number"/>

	<xsl:variable name="respElt"
		       select='/web:RDF/*[@web:about=current()/@web:resource]'/>

        <!-- @@this or should be implemented using rdfs:subClassOf inference -->
	<xsl:if test='$respElt/web:type[@web:resource =
	              concat($MeetingNS, "Present")
		      or @web:resource = concat($MeetingNS, "ChairAck")
		      or @web:resource = concat($MeetingNS, "ScribeAck")
		      ]
		      or $respElt/mtg:presentOnlyFor'>
            <xsl:call-template name="aLink">
              <xsl:with-param name="ref"
			      select='$respElt/mtg:from/@web:resource'/>
	    </xsl:call-template>
           
	    <xsl:if test='$respElt/web:type[@web:resource =
				            concat($MeetingNS, "ChairAck")]'>
              <xsl:text>(Chair)</xsl:text>
	    </xsl:if>

	    <xsl:if test='$respElt/web:type[@web:resource =
				            concat($MeetingNS, "ScribeAck")]'>
              <xsl:text>(Scribe)</xsl:text>
	    </xsl:if>

	    <xsl:if test='$respElt/mtg:presentOnlyFor'>
	      <xsl:text> (in part @@which item)</xsl:text>
	    </xsl:if>

            <xsl:text>, </xsl:text>
        </xsl:if>
      </xsl:for-each>
    </p>

    <p>Regrets:
      <xsl:for-each select="$whoElt/*[number(substring(local-name(), 2))>0]">
	<xsl:variable name="respElt"
		       select='/web:RDF/*[@web:about=current()/@web:resource]'/>

	<xsl:if test='$respElt/web:type[@web:resource =
	              concat($MeetingNS, "Regrets")
		      ]'>
          <xsl:call-template name="aLink">
            <xsl:with-param name="ref"
			    select='$respElt/mtg:from/@web:resource'/>
	  </xsl:call-template>
	</xsl:if>
      </xsl:for-each>
    </p>

    <p>Absent:
      <xsl:for-each select="$whoElt/*[number(substring(local-name(), 2))>0]">
	<xsl:variable name="respElt"
		       select='/web:RDF/*[@web:about=current()/@web:resource]'/>

	<xsl:if test='$respElt/web:type[@web:resource =
	              concat($MeetingNS, "Absent")
		      ]'>
          <xsl:call-template name="aLink">
            <xsl:with-param name="ref"
			    select='$respElt/mtg:from/@web:resource'/>
	  </xsl:call-template>
	</xsl:if>
      </xsl:for-each>
    </p>

    <p>@@haven't implemented "excused"</p>

  </div>
</xsl:template>


<xsl:template name="summary">
  <xsl:param name="whatRef"/>

  <xsl:variable name="whatElt" select='/web:RDF/*[@web:about=$whatRef]'/>

  <div class="summary">
    <h2>Summary</h2>

    <p>@@link to transcript</p>

    <xsl:for-each select="$whatElt/*[number(substring(local-name(), 2))>0]">
      <xsl:sort select='number(substring(local-name(), 2))' data-type="number"/>
      <xsl:variable name="itemElt"
		          select='/web:RDF/*[@web:about=current()/@web:resource]'/>

      <div>
	  <h3><a name='{generate-id($itemElt)}'>
	    <xsl:value-of select="$itemElt/u:label"/>
	    </a>
          </h3>

	<!-- hmm... markup should be allowed in summary;
	     need to watch for relative URI references, though
          -->
	<xsl:if test="$itemElt/mtg:summary">
	  <p><xsl:value-of select="$itemElt/mtg:summary"/></p>
	</xsl:if>

	<xsl:if test="$itemElt/u:comment"> <!-- foreach? -->
	  <p><em><xsl:value-of select="$itemElt/u:comment"/></em></p>
	</xsl:if>

        <ul>
	<xsl:for-each select='$itemElt/mtg:result/@web:resource'>
	  <xsl:variable name="resElt" select="/web:RDF/*[@web:about=current()]"/>

	  <xsl:choose>
	    <xsl:when test='$resElt/web:type[
		              @web:resource = concat($MeetingNS, "Decision")
			      ]'>
              <li>
	        <strong>
		  <a name="generate-id($resElt)">RESOLVED: </a>
                </strong>
		<xsl:value-of select="$resElt/u:label"/>
	      </li>
            </xsl:when>

	    <xsl:when test='$resElt/web:type[
		              @web:resource = concat($MeetingNS, "ActionAck")
			      ]'>
              <li>
	        <strong>
		  <a name="generate-id($resElt)">ACTION</a>
		  <xsl:call-template name="aLink">
		    <xsl:with-param name="ref" select="$resElt/mtg:from/@web:resource"/>
		  </xsl:call-template>
		  <xsl:text>: </xsl:text>
                </strong>
		<xsl:value-of select="$resElt/u:label"/>
	      </li>
            </xsl:when>

	    <xsl:when test='$resElt/web:type[
		              @web:resource = concat($MeetingNS, "ActionDone")
			      ]'>
              <li>
	        <strong>
		  <a name="generate-id($resElt)">DONE</a>
		  <xsl:call-template name="aLink">
		    <xsl:with-param name="ref" select="$resElt/mtg:from/@web:resource"/>
		  </xsl:call-template>
		  <xsl:text>: </xsl:text>
                </strong>
		<xsl:value-of select="$resElt/u:label"/>
	      </li>
            </xsl:when>

	    <xsl:when test='$resElt/web:type[
		              @web:resource = concat($MeetingNS, "Withdrawn")
			      ]'>
              <li>
	        <span>
		  <a name="generate-id($resElt)">Withdrawn</a>
		  <xsl:text>: </xsl:text>
                </span>
		<xsl:value-of select="$resElt/u:label"/>
	      </li>
            </xsl:when>

            <xsl:otherwise>
	      <p>@@result type not implemented</p>
	    </xsl:otherwise>
	  </xsl:choose>
	</xsl:for-each>

	</ul>

	<p>@@disposition: done/postponed/withdrawn/...</p>
      </div>
    </xsl:for-each>

  </div>

</xsl:template>

<xsl:template name="agenda">
  <xsl:param name="whatRef"/>
  <xsl:param name="callRef"/>

  <xsl:variable name="whatElt" select='/web:RDF/*[@web:about=$whatRef]'/>

  <div class="agenda">
    <h2>Agenda</h2>

    <xsl:if test="$callRef">
      <p class="@@:meetingCall">
        <xsl:call-template name="aLink">
	  <xsl:with-param name="ref" select='$callRef'/>
	  <xsl:with-param name="label" select='"meeting call with proposed agenda"'/>
	</xsl:call-template>

      </p>
    </xsl:if>

    <ol>
    <xsl:for-each select="$whatElt/*[number(substring(local-name(), 2))>0]">
      <xsl:sort select='number(substring(local-name(), 2))' data-type="number"/>
      <xsl:variable name="itemElt"
		          select='/web:RDF/*[@web:about=current()/@web:resource]'/>

      <li>
	  <a href='#{generate-id($itemElt)}'>
	    <xsl:value-of select="$itemElt/u:label"/>
	    </a>


	@@disp
      </li>
    </xsl:for-each>
    </ol>

  </div>

</xsl:template>

<xsl:template name="describe-supertypes">
  <xsl:param name="clsElt"/>

    <xsl:for-each select='$clsElt/u:subClassOf/@web:resource'>
      <xsl:variable name="superElt" select='/web:RDF/*[@web:about=current()]'/>

      <xsl:call-template name="describe-type">
        <xsl:with-param name="clsElt" select="$superElt"/>
      </xsl:call-template>
    </xsl:for-each>

</xsl:template>


<xsl:template name="describe-type">
  <xsl:param name="clsElt"/>

  <xsl:for-each select="$clsElt/u:seeAlso/@web:resource">
    <xsl:call-template name="aLink">
      <xsl:with-param name="ref" select="current()"/>
    </xsl:call-template>
  </xsl:for-each>
</xsl:template>

<xsl:template name="aLink">
  <xsl:param name="ref"/>
  <xsl:param name="label"/>

  <xsl:variable name="elt" select='/web:RDF/*[@web:about=$ref]'/>

  <!-- hmm... absolutize? -->
  <a href="{$ref}">
    <xsl:choose>
      <xsl:when test="$label">
	<xsl:value-of select="$label"/>
      </xsl:when>

      <xsl:when test="$elt/u:label">
	<xsl:value-of select="$elt/u:label"/>
      </xsl:when>

      <xsl:when test="$elt/email:subject">
	<xsl:value-of select="$elt/email:subject"/>
      </xsl:when>

      <xsl:otherwise>
	<xsl:message>no label for linked item. @@peeking in URI</xsl:message>
	<xsl:value-of select='concat("@@", substring($ref, string-length($ref)-10))'/>
      </xsl:otherwise>
    </xsl:choose>
  </a>
  <xsl:if test='$elt/mtg:archivedIn'>
   <xsl:text> (</xsl:text>
   <a href='{$elt/mtg:archivedIn/@web:resource}'>archive</a>
   <xsl:text>)</xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template name="symLink">
  <xsl:param name="ref"/>

  <!-- hmm... absolutize? -->
  <a href="{$ref}">
    <xsl:value-of select='substring-after($ref, "#")'/>
  </a>
</xsl:template>

<!-- don't pass text thru -->
<xsl:template match="text()|@*">
</xsl:template>

</xsl:transform>
