<?xml version="1.0" encoding="utf-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                             xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"
                             xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint"
                             exclude-result-prefixes="w wx">
 <xsl:output method="xml" indent="yes" encoding="ISO-8859-1"/>

<!--

 "This product may incorporate intellectual property owned by Microsoft Corporation. The terms and conditions upon which Microsoft is licensing such intellectual property may be found at http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp."

-->

 <xsl:template match="/">
  <page>

   <xsl:value-of select="'&#xA;&#xA;   '"/>
   <xsl:comment>
    This BYU ECEn Template XML was generated via an XSLT
    translation, the most recent stable version of which
    can be found at...

    http://www.ece.byu.edu/include/xml_templates_stable/tools/from_wordml.xsl

    ...instructions for use will someday be somewhere as well.
   </xsl:comment>

   <xsl:value-of select="'&#xA;&#xA; '"/>
   <title>
    <xsl:value-of select="'&#xA;  '"/>
    <text>Put Page Title Here</text>
   <xsl:value-of select="'&#xA; '"/>
   </title>
   <xsl:value-of select="'&#xA; '"/>
   <name>Put Page Name Here</name>
   <xsl:value-of select="'&#xA;&#xA; '"/>
   <style>secondary page</style>
   <xsl:value-of select="'&#xA;&#xA; '"/>
   <content>
    <xsl:apply-templates>
     <xsl:with-param name="indent-string" select="'&#xA;  '"/>
    </xsl:apply-templates>
   <xsl:value-of select="'&#xA; '"/>
   </content>
  </page>
 </xsl:template>

 <xsl:template match="*">
  <xsl:param name="indent-string"/>

  <xsl:apply-templates>
   <xsl:with-param name="indent-string" select="$indent-string"/>
  </xsl:apply-templates>
 </xsl:template>

 <xsl:template match="w:tbl">
  <xsl:param name="indent-string"/>

  <xsl:value-of select="$indent-string"/>
  <section>
   <xsl:value-of select="concat($indent-string,' ')"/>
   <style>visible border</style>
   <xsl:apply-templates select="w:tr" mode="has-row">
    <xsl:with-param name="indent-string" select="concat($indent-string,'  ')"/>
   </xsl:apply-templates>
   <xsl:apply-templates select="w:tr[1]/w:tc" mode="has-column">
    <xsl:with-param name="indent-string" select="concat($indent-string,'  ')"/>
   </xsl:apply-templates>
   <xsl:apply-templates select="w:tr">
    <xsl:with-param name="indent-string" select="concat($indent-string,'  ')"/>
   </xsl:apply-templates>
  <xsl:value-of select="$indent-string"/>
  </section>
 </xsl:template>

 <xsl:template match="w:tr" mode="has-row">
  <xsl:param name="indent-string"/>

  <xsl:value-of select="$indent-string"/>
  <has-row><xsl:value-of select="generate-id()"/></has-row>
 </xsl:template>

 <xsl:template match="w:tc" mode="has-column">
  <xsl:param name="indent-string"/>

  <xsl:value-of select="$indent-string"/>
  <has-column><xsl:value-of select="generate-id()"/></has-column>
 </xsl:template>

 <xsl:template match="w:tr">
  <xsl:param name="indent-string"/>

  <xsl:value-of select="$indent-string"/>
  <section>
   <xsl:value-of select="concat($indent-string,' ')"/>
   <in-row><xsl:value-of select="generate-id()"/></in-row>
   <xsl:apply-templates select="w:tc">
    <xsl:with-param name="indent-string" select="concat($indent-string,' ')"/>
   </xsl:apply-templates>
  <xsl:value-of select="$indent-string"/>
  </section>
 </xsl:template>

 <xsl:template match="w:tc">
  <xsl:param name="indent-string"/>

  <xsl:value-of select="$indent-string"/>
  <section>
   <xsl:value-of select="concat($indent-string,' ')"/>
   <in-column><xsl:value-of select="generate-id(../../w:tr[1]/w:tc[count(current()/preceding-sibling::w:tc)+1])"/></in-column>
   <xsl:apply-templates>
    <xsl:with-param name="indent-string" select="concat($indent-string,' ')"/>
   </xsl:apply-templates>
  <xsl:value-of select="$indent-string"/>
  </section>
 </xsl:template>

 <xsl:template match="w:p">
  <xsl:param name="indent-string"/>

  <xsl:choose>
   <xsl:when test="w:pPr[w:pStyle[starts-with(@w:val,'Heading')]]">
    <xsl:value-of select="$indent-string"/>
    <title>
     <xsl:apply-templates>
      <xsl:with-param name="indent-string" select="concat($indent-string,' ')"/>
     </xsl:apply-templates>
    <xsl:value-of select="$indent-string"/>
    </title>
   </xsl:when>
   <xsl:when test="w:pPr[w:listPr] and not(preceding-sibling::w:p[1][w:pPr[w:listPr[w:ilfo[@w:val = current()/w:pPr/w:listPr/w:ilfo/@w:val]]]])">
    <xsl:value-of select="$indent-string"/>
    <section>
     <xsl:value-of select="concat($indent-string,' ')"/>
     <style>sub-sections numbered</style>
     <xsl:apply-templates select="." mode="list">
      <xsl:with-param name="indent-string" select="concat($indent-string,' ')"/>
     </xsl:apply-templates>
    <xsl:value-of select="$indent-string"/>
    </section>
   </xsl:when>
   <xsl:when test="w:pPr[w:listPr]">
    <!-- Don't do anything; these are handled under the w:p template
         in list mode. -->
   </xsl:when>
   <xsl:otherwise>
    <xsl:apply-templates>
     <xsl:with-param name="indent-string" select="$indent-string"/>
    </xsl:apply-templates>
    <xsl:if test="w:r and following-sibling::w:p[w:r]">
     <xsl:value-of select="$indent-string"/>
     <paragraph-break/>
    </xsl:if>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>

 <xsl:template match="w:p" mode="list">
  <xsl:param name="indent-string"/>

  <xsl:value-of select="$indent-string"/>
  <section>
   <xsl:if test="following-sibling::w:p[1][w:pPr[w:listPr[w:ilvl[@w:val > current()/w:pPr/w:listPr/w:ilvl/@w:val] and w:ilfo[@w:val = current()/w:pPr/w:listPr/w:ilfo/@w:val]]]]">
    <xsl:value-of select="concat($indent-string,' ')"/>
    <style>sub-sections numbered</style>
   </xsl:if>
   <xsl:apply-templates>
    <xsl:with-param name="indent-string" select="concat($indent-string,' ')"/>
   </xsl:apply-templates>
   <xsl:apply-templates select="following-sibling::w:p[1][w:pPr[w:listPr[w:ilvl[@w:val > current()/w:pPr/w:listPr/w:ilvl/@w:val] and w:ilfo[@w:val = current()/w:pPr/w:listPr/w:ilfo/@w:val]]]]" mode="list">
    <xsl:with-param name="indent-string" select="concat($indent-string,'  ')"/>
   </xsl:apply-templates>
  <xsl:value-of select="$indent-string"/>
  </section>
  <xsl:apply-templates select="following-sibling::w:p[1][w:pPr[w:listPr[w:ilvl[@w:val = current()/w:pPr/w:listPr/w:ilvl/@w:val] and w:ilfo[@w:val = current()/w:pPr/w:listPr/w:ilfo/@w:val]]]]" mode="list">
   <xsl:with-param name="indent-string" select="$indent-string"/>
  </xsl:apply-templates>
 </xsl:template>

 <xsl:template match="w:r">
  <xsl:param name="indent-string"/>

  <xsl:choose>
   <xsl:when test="w:rPr[w:b|w:i|w:u]">
    <xsl:value-of select="$indent-string"/>
    <special-text>
     <xsl:if test="w:rPr[w:b[not(@w:val='off')]]">
      <xsl:value-of select="concat($indent-string,' ')"/>
      <style>bold</style>
     </xsl:if>
     <xsl:if test="w:rPr[w:i[not(@w:val='off')]]">
      <xsl:value-of select="concat($indent-string,' ')"/>
      <style>italic</style>
     </xsl:if>
     <xsl:if test="w:rPr[w:u[not(@w:val='off')]]">
      <xsl:value-of select="concat($indent-string,' ')"/>
      <style>underlined</style>
     </xsl:if>
     <xsl:apply-templates>
      <xsl:with-param name="indent-string" select="concat($indent-string,' ')"/>
     </xsl:apply-templates>
    <xsl:value-of select="$indent-string"/>
    </special-text>
   </xsl:when>
   <xsl:otherwise>
    <xsl:apply-templates>
     <xsl:with-param name="indent-string" select="$indent-string"/>
    </xsl:apply-templates>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>

 <xsl:template match="w:t">
  <xsl:param name="indent-string"/>

  <xsl:value-of select="$indent-string"/>
  <text>
   <xsl:value-of select="."/>
  </text>
 </xsl:template>

 <xsl:template match="w:hlink">
  <xsl:param name="indent-string"/>

  <xsl:value-of select="$indent-string"/>
  <special-text>
   <xsl:value-of select="concat($indent-string,' ')"/>
   <related-page>
    <xsl:value-of select="@w:dest"/>
   <xsl:value-of select="concat($indent-string,' ')"/>
   </related-page>
   <xsl:apply-templates>
    <xsl:with-param name="indent-string" select="concat($indent-string,' ')"/>
   </xsl:apply-templates>
  <xsl:value-of select="$indent-string"/>
  </special-text>
 </xsl:template>

 <xsl:template match="wx:sub-section[parent::wx:sub-section]">
  <xsl:param name="indent-string"/>

  <xsl:value-of select="$indent-string"/>
  <section>

   <xsl:apply-templates>
    <xsl:with-param name="indent-string" select="concat($indent-string,' ')"/>
   </xsl:apply-templates>

  <xsl:value-of select="$indent-string"/>
  </section>
 </xsl:template>

 <xsl:template match="text()"/>
</xsl:transform>
