<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!--
******************************************************************
*
* File: pass1_xml.xsl
*
* Copyright 2009 Programming Research Ltd
*
* Written: C.Waddingham, 6-August-2009
*
* Purpose: XSL Stylesheet for generating pass1.xml which is the
*          input to master_xhtml.xsl etc.
*
* Usage: Use as input to xsltproc, e.g. (for the code review case):
*        xsltproc <dash><dash>param op "'C:/..../'" pass1_xml.xsl x1_code_review.xml >pass1.xml
*        Where <dash> is -
******************************************************************
-->

<xsl:stylesheet version="1.0"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:svg="http://www.w3.org/2000/svg" 
                xmlns:prdf="http://www.programmingresearch.com/todo" >

<!--
  <xsl:output method="xml"
            doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
            doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
            indent="yes" /> 
-->
  <xsl:output method="xml"
            indent="yes" /> 

  <xsl:param name='op'/>
  <xsl:param name='title'/>
  <xsl:param name='project_name'/>
  <xsl:param name='date'/>
  <xsl:param name='no_appendix' select="false()" />
  <xsl:param name='no_version' select="false()" />
  
  <xsl:template match="/prdf:report">
    <prdf:report>
      <xsl:choose>
        <xsl:when test="$title">
          <prdf:title><xsl:value-of select="$title"/></prdf:title>
        </xsl:when>
        <xsl:otherwise>
          <xsl:copy-of select="prdf:title"/>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:choose>
        <xsl:when test="$project_name">
          <prdf:project_name><xsl:value-of select="$project_name"/></prdf:project_name>
        </xsl:when>
        <xsl:otherwise>
          <xsl:copy-of select="prdf:project_name"/>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:choose>
        <xsl:when test="$date">
          <prdf:date><xsl:value-of select="$date"/></prdf:date>
        </xsl:when>
        <xsl:otherwise>
          <xsl:copy-of select="prdf:date"/>
        </xsl:otherwise>
      </xsl:choose>
      <prdf:front_page>
        <xsl:for-each select="prdf:front_page/prdf:component">
          <xsl:copy-of select="document(concat($op,.))" />
        </xsl:for-each>
      </prdf:front_page>
      <prdf:main>
        <xsl:for-each select="prdf:main/prdf:component">
          <xsl:copy-of select="document(concat($op,.))" />
        </xsl:for-each>
      </prdf:main>
      <prdf:appendices>
        <xsl:if test="not(boolean($no_appendix))">
          <xsl:for-each select="prdf:appendices/prdf:component">
            <xsl:copy-of select="document(concat($op,.))" />
          </xsl:for-each>
          <xsl:if test="not(boolean($no_version))">
            <xsl:for-each select="prdf:version/prdf:component">
              <xsl:copy-of select="document(concat($op,.))"/>
            </xsl:for-each>
          </xsl:if>
        </xsl:if>
      </prdf:appendices>
    </prdf:report>
  </xsl:template>

</xsl:stylesheet>
