<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" indent="yes"
	doctype-system="brainstorming.dtd" />
<!--
	Copyright (c) 2002 Kenneth B. Sall. All Rights Reserved. 
	This code may not be copied, modified, or duplicated in any manner 
	without written consent from the author at ken@sall.net. 
-->
 
<xsl:param name="label">XML.gov Demo: XHTML to Custom XML</xsl:param>

<xsl:template match="table/tbody" >
  <!-- TBD: Note hard-coded averages from original data -->
  <Brainstorming dataCollectionDate="2002-08-30" 
	avrWeightedTotalScore="39.5" avrTotalVotes="19.4" avrAverage="2.03"> 
    <xsl:apply-templates  /> 
  </Brainstorming>
</xsl:template>


<!-- Rows with colspan attribute contain no data -->
<!-- TBD not working -->
<xsl:template match="tr/td[@colspan]">
</xsl:template>


<xsl:template match="tr">
 <!-- Rows with colspan attribute contain no data, so skip them. -->
 <!-- But this messes up the numbering -->
 <xsl:if test="not(./td/@colspan)">
  <xsl:element name="Idea">
    <xsl:attribute name="origID"><xsl:number/></xsl:attribute>
    <Description><xsl:value-of select="normalize-space(td[1])" /></Description>
    <Rankings>
      <Low><xsl:value-of select="td[2]" /></Low>
      <Medium><xsl:value-of select="td[3]" /></Medium>
      <High><xsl:value-of select="td[4]" /></High>
    </Rankings>
    <WeightedTotalScore><xsl:value-of select="td[5]" /></WeightedTotalScore>
    <TotalVotes><xsl:value-of select="normalize-space(td[6])" /></TotalVotes> <!-- TBD: normal-space -->
    <Average><xsl:value-of select="normalize-space(td[7])" /></Average>
    <!-- FocusGroup and ProjectName need to be added later. -->
    <FocusGroup>
      <Lead>
        <First>Lead-TBD</First>
        <Last>Lead-TBD</Last>
      </Lead>
      <Volunteer>
        <First>TBD</First>
        <Last>TBD</Last>
      </Volunteer>
    </FocusGroup>
    <ProjectName>Project-TBD</ProjectName>
  </xsl:element>
 </xsl:if> 
</xsl:template>



 <xsl:template match="text()" /> <!-- swallow other text -->
</xsl:stylesheet>
