<!-- <options version="1.0"> --><!-- 	<object name="Model"> -->
<!-- 		<properties> -->
<!-- 			<property name="Name" /> -->
<!-- 		</properties> -->
<!-- 		<children> -->
<!-- 			<object name="Table"> -->
<!-- 				<properties> -->
<!-- 					<property name="Name" /> -->
<!-- 				</properties> -->
<!-- 				<children> -->
<!-- 					<object name="Index"> -->
<!-- 						<properties> -->
<!-- 							<property name="Name" /> -->
<!-- 						</properties> -->
<!-- 						<children> -->
<!-- 							<object name="Segment Attributes"> -->
<!-- 								<properties> -->
<!-- 									<property name="TABLESPACE" /> -->
<!-- 								</properties> -->
<!-- 							</object> -->
<!-- 						</children> -->
<!-- 					</object> -->
<!-- 					<object name="Segment Attributes"> -->
<!-- 						<properties> -->
<!-- 							<property name="TABLESPACE" /> -->
<!-- 						</properties> -->
<!-- 					</object> -->
<!-- 				</children> -->
<!-- 			</object> -->
<!-- 			<object name="Tablespace"> -->
<!-- 				<properties> -->
<!-- 					<property name="Name" /> -->
<!-- 					<property name="Definition" /> -->
<!-- 					<property name="Enabled" /> -->
<!-- 					<property name="Generate" /> -->
<!-- 					<property name="BLOCKSIZE" /> -->
<!-- 					<property name="MAXEXTENTS" /> -->
<!-- 					<property name="PCTINCREASE" /> -->
<!-- 					<property name="MINIMUM EXTENT" /> -->
<!-- 					<property name="Type" /> -->
<!-- 					<property name="LOGGING" /> -->
<!-- 					<property name="EXTENT MANAGEMENT" /> -->
<!-- 					<property name="ALLOCATION TYPE" /> -->
<!-- 					<property name="SEGMENT SPACE MANAGEMENT" /> -->
<!-- 					<property name="COMPRESS" /> -->
<!-- 					<property name="OFFLINE" /> -->
<!-- 					<property name="BLOCKSIZE MODIFIER" /> -->
<!-- 					<property name="MINIMUM EXTENT MODIFIER" /> -->
<!-- 					<property name="FORCE LOGGING" /> -->
<!-- 					<property name="File Size" /> -->
<!-- 					<property name="UNIFORM SIZE" /> -->
<!-- 					<property name="UNIFORM SIZE MODIFIER" /> -->
<!-- 					<property name="FLASHBACK" /> -->
<!-- 					<property name="STATUS" /> -->
<!-- 					<property name="RETENTION" /> -->
<!-- 					<property name="Evaluated Create Script" /> -->
<!-- 					<property name="Evaluated Drop Script" /> -->
<!-- 					<property name="GROUP NAME" /> -->
<!-- 					<property name="Built In" /> -->
<!-- 					<property name="Pre Script" /> -->
<!-- 					<property name="Post Script" /> -->
<!-- 				</properties> -->
<!-- 				<children> -->
<!-- 					<object name="Datafile"> -->
<!-- 						<properties> -->
<!-- 							<property name="Name" /> -->
<!-- 							<property name="Definition" /> -->
<!-- 							<property name="Enabled" /> -->
<!-- 							<property name="Generate" /> -->
<!-- 						</properties> -->
<!-- 					</object> -->
<!-- 				</children> -->
<!-- 			</object> -->
<!-- 		</children> -->
<!-- 	</object> -->
<!-- </options> -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:key name="IDs" match="*" use="@id"/>
<xsl:template match="/">
  <html  xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<title>Tablespace Report</title>
      <script type="text/javascript">
        // <![CDATA[
        function toggle(element, togimg) {
          if (element.style.display == 'none') {
            element.style.display = 'block';
            togimg.src="../images/collapse.gif";
          }
          else {
            element.style.display = 'none';
            togimg.src="../images/expand.gif";
          }
        }
        // ]]>
      </script>
		</head>
      <STYLE>
        BODY
        {
        font-family:Arial;
        background-image: url(../images/background.gif);
        }
        H1   { border-bottom: #000099 thick solid; color: #BB1100; }
        H2   { border-bottom: #0000C9 thin solid; color: #BB1100; }
        img { border-width: 0px; }
        .sqlcode
        {
        font-family: system;
        font-size: 70%;
        }
        .CommonHeader
        {
        color: #666666;
        font-size: 100%;
        font-weight: bold;
        font-family: Tahoma, Arial, Helvetica;
        padding: 0px;
        margin: 0px;
        margin-top: 8px;
        }
        a:link, a:visited
        {
        color: #4444BF;
        text-decoration: none;
        }
        .heading-table, .heading-table TD, .heading-table TH
        {
        background-color: #92B2F2;
        color: black;
        border-width: 0px;
        font-family:sans-serif;
        font-weight:600;
        vertical-align:middle;
        }
        .TablesHeader
        {
        color: white;
        background-color: #000099;
        }
        .TableHeading
        {
        border-bottom: #000099 solid;
        }
        pre
        {
        border: solid 1px #666666;
        background-color: #f2f2f2;
        }
      </STYLE>
      <body>
        <table cellpadding="10px" class="heading-table" style="border-width: 5; border-color: #000099; border-style:solid;" width="100%">
          <tr>
            <td width="100px">
            </td>
            <td style="font-size:110%">
              This reporting template displays detailed information about a model's Tablespaces.
            </td>
            <td width="200px">
              <img src="../images/ModelRight.gif" align="right" height="100px"/>
            </td>
          </tr>
        </table>
        <br/>

      <xsl:text>&#xA;</xsl:text>
      <h1 class="TableHeading">
        <img src="../images/model.gif" height="25"/>
        <xsl:text>  </xsl:text>
        <a name="{model/@id}">
          <xsl:value-of select="model/model-properties/model.name" />
        </a>
      </h1>
        <xsl:if test="model/model-properties/model.author">
          <span class="CommonHeader">Author: </span>
              <xsl:value-of select="model/model-properties/model.author" />
        </xsl:if>
        <xsl:if test="model/model-properties/model.company">
          <br/>
          <br/>
          <span class="CommonHeader">Company: </span>
              <xsl:value-of select="model/model-properties/model.company" />
        </xsl:if>
        <xsl:if test="model/@timestamp">
          <br/>
          <span class="CommonHeader">Generated: </span>
          <xsl:value-of select="model/@timestamp" />
        </xsl:if>
        <br/>
        <h2>
          <a href="#Tablespaces">
            <img src="../images/tablespace.gif" />
            Tablespaces
          </a>
        </h2>
        <ul>
          <xsl:for-each select="model/model-children/tablespace">
            <xsl:sort select="tablespace-properties/tablespace.name"/>
            <li>
              <a href="#{@id}">
                <xsl:value-of select="tablespace-properties/tablespace.name"/>
              </a>
            </li>
          </xsl:for-each>
        </ul>
        <xsl:apply-templates select="model/model-children/tablespace">
          <xsl:sort select="tablespace-properties/tablespace.name"/>
        </xsl:apply-templates>
    </body>
  </html>
</xsl:template>
 
  <xsl:template match="tablespace">
    <h2 class="TableHeading">
      <img src="../images/tablespace.gif" />
      <xsl:text>  </xsl:text>
      <a name="{@id}">
        <xsl:value-of select="tablespace-properties/tablespace.name" />
      </a>
    </h2>
    <xsl:variable name="tablespaceId" select="@id" />
    <table>
      <tr>
        <td>
          <span class="CommonHeader">Type: </span>
        </td>
        <td>
          <xsl:value-of select="tablespace-properties/tablespace.type/@property-as-string" />
        </td>
      </tr>
      <xsl:apply-templates select="tablespace-properties/*" />
    </table>
    <br/>
    <xsl:if test="tablespace-children/datafile">
      <h2 style="color: #3344CC">
        <xsl:text>&#xA;&#x9;&#x9;&#x9;</xsl:text>
        Datafiles
      </h2>
      <xsl:for-each select="tablespace-children/datafile">
        <h3 style="color: #3344CC">
          <xsl:value-of select="datafile-properties/datafile.name"/>
        </h3>
        <table>
          <xsl:apply-templates select="datafile-properties/*" />
        </table>
      </xsl:for-each>
    </xsl:if>
    <br/>
    <table border="2">
      <tr>
        <xsl:text>&#xA;&#x9;&#x9;</xsl:text>
        <th class="TablesHeader" width="150px" align="center">
          <xsl:text>&#xA;&#x9;&#x9;&#x9;</xsl:text>
          Used By Tables
        </th>
      </tr>
      <tr>
        <td>
          <xsl:variable name="used-by">
            <xsl:for-each select="/model/model-children/table[table-children/segment-attributes/segment-attributes-properties/segment-attributes.tablespace/@reference-id=$tablespaceId]">
              <xsl:sort select="table-properties/table.name"/>
              <xsl:text>&#xA;&#x9;&#x9;</xsl:text>
              <xsl:call-template name="add-icon">
                <xsl:with-param name="obj-id" select="@id" />
                <xsl:with-param name="width" select="15" />
              </xsl:call-template>
              <xsl:value-of select="table-properties/table.name"/>
              <br />
            </xsl:for-each>
          </xsl:variable>
          <xsl:choose>
            <xsl:when test="string($used-by)!=''">
              <xsl:copy-of select="$used-by"/>
            </xsl:when>
            <xsl:otherwise>
              &lt;Not Used&gt;
            </xsl:otherwise>
          </xsl:choose>
        </td>
      </tr>
    </table>
  <br />
    <table border="2">
      <tr>
        <xsl:text>&#xA;&#x9;&#x9;</xsl:text>
        <th class="TablesHeader" width="150px" align="center">
          <xsl:text>&#xA;&#x9;&#x9;&#x9;</xsl:text>
          Used By Indexes
        </th>
        <th class="TablesHeader" width="150px" align="center">
          <xsl:text>&#xA;&#x9;&#x9;&#x9;</xsl:text>
          Table
        </th>
      </tr>
      <xsl:variable name="used-by-index">
        <xsl:for-each select="/model/model-children/table/table-children/index[index-children/segment-attributes/segment-attributes-properties/segment-attributes.tablespace/@reference-id=$tablespaceId]">
          <xsl:sort select="index-properties/index.name"/>
          <tr>
            <td>
              <xsl:text>&#xA;&#x9;&#x9;</xsl:text>
              <xsl:call-template name="add-icon">
                <xsl:with-param name="obj-id" select="@id" />
                <xsl:with-param name="width" select="15" />
              </xsl:call-template>
              <xsl:value-of select="index-properties/index.name"/>
              <br />
            </td>
            <td>
              <xsl:text>&#xA;&#x9;&#x9;</xsl:text>
              <xsl:call-template name="add-icon">
                <xsl:with-param name="obj-id" select="../../@id" />
                <xsl:with-param name="width" select="15" />
              </xsl:call-template>
              <xsl:value-of select="../../table-properties/table.name"/>
              <br />
            </td>
          </tr>
        </xsl:for-each>
      </xsl:variable>
      <xsl:choose>
        <xsl:when test="string($used-by-index)!=''">
          <xsl:copy-of select="$used-by-index"/>
        </xsl:when>
        <xsl:otherwise>
          <tr>
            <td>
              &lt;Not Used&gt;
            </td>
          </tr>
        </xsl:otherwise>
      </xsl:choose>
    </table>
    <xsl:if test="string(tablespace-properties/tablespace.evaluated-create-script) != ''">
      <br/>
      <span class="CommonHeader">Create Script</span>
      <p class="sqlcode">
        <pre>
          <xsl:value-of select="tablespace-properties/tablespace.evaluated-create-script" />
        </pre>
      </p>
    </xsl:if>
    <xsl:if test="string(tablespace-properties/tablespace.evaluated-drop-script) != ''">
      <br/>
      <span class="CommonHeader">Drop Script</span>
      <p class="sqlcode">
        <pre>
          <xsl:value-of select="tablespace-properties/tablespace.evaluated-drop-script" />
        </pre>
      </p>
    </xsl:if>
  </xsl:template>
  
  <xsl:template match="tablespace-properties/* | datafile-properties/*">
    <xsl:if test="@display-name != 'Name' and @display-name != 'Type' and substring(@display-name, 1, 10)!='Evaluated '">
      <tr>
        <td width="200px">
          <span class="CommonHeader">
            <xsl:value-of select="@display-name" />:
          </span>
        </td>
        <td>
          <xsl:choose>
            <xsl:when test="@property-as-string">
              <xsl:value-of select="@property-as-string"/>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="." />
            </xsl:otherwise>
          </xsl:choose>
        </td>
      </tr>
    </xsl:if>
  </xsl:template>

  <xsl:template name="add-icon">
    <xsl:param name="obj-id" select="''" />
    <xsl:if test="$obj-id != ''">
      <xsl:for-each select="key('IDs', $obj-id)">
        <xsl:variable name="filename">
          <xsl:choose>
            <xsl:when test="name()='key-constraint'">
              <xsl:choose>
                <xsl:when test="key-constraint-properties/key-constraint.type/@property-as-string='Unique'">
                  <xsl:value-of select="'unique-key-constraint'"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="name()"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="name()"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <img src="../images/{$filename}.gif" height="15px" width="15px"/>
        <xsl:text>  </xsl:text>
      </xsl:for-each>
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>
