MINI MINI MANI MO

Path : /opt/oracle/product/18c/dbhomeXE/rdbms/xml/xsl/
File Upload :
Current File : //opt/oracle/product/18c/dbhomeXE/rdbms/xml/xsl/kustblsd.xsl

<?xml version="1.0"?>
<!--

 Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.

NAME
    kustblsd.xsl
DESCRIPTION
    Convert TABLESPACE document (SXML) to creation DDL.

MODIFIED        MM/DD/YY
    tbhukya     09/27/17 - Bug 26859349: Support lost write protection when 
                           version is 12.2.0.2.0 or greater.
    tbhukya     05/26/17 - Bug 26075370:lost write protection in undo tablespace
    jjanosik    05/05/17 - Bug 25239237: handle suspend lost write protection
    tbhukya     03/21/17 - Bug 25747729: Fix table and index compression
    tbhukya     02/03/17 - Bug 25468408: Double quote tablespace group name
    tbhukya     06/09/16 - Bug 22171888: CellMemory support
    tbhukya     12/24/15 - RTI 18868579: Replace CellCache with CellMemory
    tbhukya     11/10/15 - Bug 21747321: Offline temp tablespace
    tbhukya     09/22/15 - Bug 21816026: Offline shadow, undo tablespace
    tbhukya     09/08/15 - Bug 21769074: Support encryption with temp,
                           undo tablespaces
    tbhukya     05/11/15 - Bug 20980538: Lost write protection
    rapayne     02/20/15 - local temporary tblsp support.
    rapayne     02/20/14 - bug 18155007: add INMEMORY support.
    lbarton     09/19/11 - project 32935: row level locking
    rapayne     11/01/09 - bug 8714709: fix encrypted tablespace support.
    lbarton     07/10/09 - bug 8494344: archive compression
    rapayne     02/24/09 - lrg 3784210: add REUSE transform parameter. In the 
                           tkmadftbs test, this will allow us to avoid a race
                           condition that currently causes intermittent failures 
                           on  WINDOWs.
    lbarton     01/17/08 - Bug 6724820: table compression
    lbarton     02/20/06 - bug 4752442: BIGFILE 
    sdavidso    11/02/05 - fix inconsistent stylesheet format 
    sdavidso   08/29/05 - handle OMF datafiles in tablespaces 
    lbarton    08/10/05 - lbarton_mddiff
    htseng     03/21/05 - Initial version
 -->
<xsl:stylesheet version="1.0" xmlns:sxml="http://xmlns.oracle.com/ku" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <!-- Top level imports -->
 <xsl:import href="kuscommd.xsl"/>
 <xsl:import href="kusindxd.xsl"/>
 <xsl:import href="kustbphd.xsl"/>
 <!-- Top-level parameters -->
 <!-- Parameters for DDL generation -->
 <xsl:param name="PRETTY">1</xsl:param>
 <xsl:param name="SQLTERMINATOR">0</xsl:param>
 <xsl:param name="REUSE">0</xsl:param>
 <!-- Templates -->
 <xsl:template match="sxml:TABLESPACE">
  <!-- *******************************************************************
Template: TABLESPACE - top-level template for tables.
  This template calls one of
   - DoUndoTS
   - DoPermanentTS
   - DoTemporaryTS
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="sxml:TYPE='UNDO'">
    <xsl:call-template name="DoUndoTS"/>
    <!-- Enable or suspend lost write protection -->
    <xsl:if test="$VERSION>=1202000200 and 
                  (sxml:ENABLE_LOST_WRITE_PROTECTION or
                   sxml:SUSPEND_LOST_WRITE_PROTECTION)">
     <xsl:if test="$SQLTERMINATOR=1">
      <xsl:text>;</xsl:text>
      <!-- Terminate the SQL statement -->
     </xsl:if>
    <xsl:if test="$PRETTY=1">
     <xsl:text>&#xa; </xsl:text>
    </xsl:if>
    <xsl:text> ALTER TABLESPACE "</xsl:text>
     <xsl:value-of select="sxml:NAME"/>
     <xsl:choose>
      <xsl:when test="sxml:ENABLE_LOST_WRITE_PROTECTION">
       <xsl:text>" ENABLE LOST WRITE PROTECTION</xsl:text>
      </xsl:when>
      <xsl:when test="sxml:SUSPEND_LOST_WRITE_PROTECTION">
       <xsl:text>" SUSPEND LOST WRITE PROTECTION</xsl:text>
      </xsl:when>
     </xsl:choose>
    </xsl:if>
   </xsl:when>
   <xsl:when test="sxml:TYPE='TEMPORARY'">
    <xsl:call-template name="DoTemporaryTS"/>
    <xsl:if test="sxml:DATAFILE_LIST/sxml:DATAFILE_LIST_ITEM/sxml:OFFLINE">
     <xsl:if test="$SQLTERMINATOR=1">
      <xsl:text>;</xsl:text>
      <!-- Terminate the SQL statement -->
     </xsl:if>
     <xsl:if test="$PRETTY=1">
      <xsl:text>&#xa; </xsl:text>
     </xsl:if>
     <xsl:text> ALTER TABLESPACE "</xsl:text>
     <xsl:value-of select="sxml:NAME"/>
     <xsl:text> TEMPFILE OFFLINE</xsl:text>
    <xsl:if test="$SQLTERMINATOR=1">
     <xsl:text>;</xsl:text>
     <!-- Terminate the SQL statement -->
    </xsl:if>
   </xsl:if>
   </xsl:when>
   <xsl:when test="sxml:TYPE='PERMANENT'">
    <xsl:call-template name="DoPermanentTS"/>
    <xsl:if test="$VERSION>=1202000200 and 
                  (sxml:ENABLE_LOST_WRITE_PROTECTION or
                   sxml:SUSPEND_LOST_WRITE_PROTECTION)">
     <xsl:if test="$SQLTERMINATOR=1">
      <xsl:text>;</xsl:text>
      <!-- Terminate the SQL statement -->
     </xsl:if>
     <xsl:if test="$PRETTY=1">
      <xsl:text>&#xa; </xsl:text>
     </xsl:if>
     <xsl:text> ALTER TABLESPACE "</xsl:text>
     <xsl:value-of select="sxml:NAME"/>
     <xsl:choose>
      <xsl:when test="sxml:ENABLE_LOST_WRITE_PROTECTION">
       <xsl:text>" ENABLE LOST WRITE PROTECTION</xsl:text>
      </xsl:when>
      <xsl:when test="sxml:SUSPEND_LOST_WRITE_PROTECTION">
       <xsl:text>" SUSPEND LOST WRITE PROTECTION</xsl:text>
      </xsl:when>
     </xsl:choose>
    </xsl:if>
   </xsl:when>
   <xsl:otherwise>
    <xsl:text>??? Unknown tablespace type: </xsl:text>
    <xsl:value-of select="sxml:TYPE"/>
   </xsl:otherwise>
  </xsl:choose>
  <xsl:if test="$SQLTERMINATOR=1">
   <xsl:text>;</xsl:text>
   <!-- Terminate the SQL statement -->
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoUndoTS">
  <!-- *******************************************************************
Template: DoUndoTS
Current node: TABLESPACE
******************************************************************** -->
  <xsl:call-template name="DoCreateVerb"/>
  <xsl:text>UNDO TABLESPACE "</xsl:text>
  <xsl:value-of select="sxml:NAME"/>
  <xsl:text>" DATAFILE </xsl:text>
  <xsl:apply-templates select="sxml:DATAFILE_LIST"/>
  <xsl:if test="sxml:OFFLINE">
   <xsl:text> OFFLINE</xsl:text>
  </xsl:if>
  <xsl:if test="sxml:BLOCKSIZE">
   <xsl:text> BLOCKSIZE </xsl:text>
   <xsl:value-of select="sxml:BLOCKSIZE"/>
  </xsl:if>
  <xsl:apply-templates select="sxml:EXTENT_MANAGEMENT"/>
  <xsl:apply-templates select="sxml:RETENTION_GUARANTEE"/>
 </xsl:template>
 <xsl:template name="DoCreateVerb">
  <!-- *******************************************************************
 Template: DoCreateVerb
     Output CREATE [BIGFILE]
******************************************************************** -->
  <xsl:text> CREATE </xsl:text>
  <xsl:apply-templates select="sxml:BIGFILE"/>
 </xsl:template>
 <xsl:template match="sxml:BIGFILE">
  <!-- *******************************************************************
 Template: BIGFILE
     Output BIGFILE
******************************************************************** -->
  <xsl:text>BIGFILE </xsl:text>
 </xsl:template>
 <xsl:template match="sxml:ENCRYPT">
  <!-- *******************************************************************
 Template: ENCRYPT
******************************************************************** -->
  <xsl:text> ENCRYPTION USING '</xsl:text>
  <xsl:value-of select="sxml:ENCRYPTIONALG"/>
  <xsl:text>' </xsl:text>
  <xsl:if test="$VERSION>=1202000000">
   <xsl:text>ENCRYPT </xsl:text>
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoTemporaryTS">
  <!-- *******************************************************************
Template: DoTemporaryTS
Current node: TABLESPACE
******************************************************************** -->
  <xsl:call-template name="DoCreateVerb"/>
  <xsl:if test="sxml:LOCAL">
   <xsl:text>LOCAL </xsl:text>
  </xsl:if>
  <xsl:text>TEMPORARY TABLESPACE </xsl:text>
  <xsl:if test="sxml:LOCAL">
   <xsl:text>FOR </xsl:text>
   <xsl:value-of select="sxml:LOCAL"/>
   <xsl:text> </xsl:text>
  </xsl:if>
  <xsl:call-template name="QuotedName">
   <xsl:with-param name="NameNode" select="sxml:NAME"/>
  </xsl:call-template>
  <xsl:text> TEMPFILE </xsl:text>
  <xsl:apply-templates select="sxml:DATAFILE_LIST"/>
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa; </xsl:text>
  </xsl:if>
  <xsl:apply-templates select="sxml:TABLESPACE_GROUP"/>
  <xsl:apply-templates select="sxml:EXTENT_MANAGEMENT"/>
  <!-- Offline temp tablespace when tempfile is offline -->
  <xsl:if test="sxml:DATAFILE_LIST/sxml:DATAFILE_LIST_ITEM[sxml:TFSTATUS='OFFLINE']">
   <xsl:if test="$SQLTERMINATOR=1">
    <xsl:text>;</xsl:text>
    <!-- Terminate the SQL statement -->
   </xsl:if>
   <xsl:if test="$PRETTY=1">
    <xsl:text>&#xa; </xsl:text>
   </xsl:if>
   <xsl:text>ALTER TABLESPACE </xsl:text>
   <xsl:call-template name="QuotedName">
   <xsl:with-param name="NameNode" select="sxml:NAME"/>
   </xsl:call-template>
   <xsl:text> TEMPFILE OFFLINE</xsl:text>
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoPermanentTS">
  <!-- *******************************************************************
Template: DoPermanentTS
Current node: TABLESPACE
******************************************************************** -->
  <xsl:call-template name="DoCreateVerb"/>
  <xsl:text>TABLESPACE "</xsl:text>
  <xsl:value-of select="sxml:NAME"/>
  <xsl:text>" DATAFILE </xsl:text>
  <xsl:apply-templates select="sxml:DATAFILE_LIST"/>
  <xsl:if test="sxml:OFFLINE">
   <xsl:text> OFFLINE</xsl:text>
  </xsl:if>
  <xsl:if test="$VERSION>=1202000200 and sxml:LOST_WRITE_PROTECTION">
   <xsl:text> LOST WRITE PROTECTION</xsl:text>
  </xsl:if>
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa; </xsl:text>
  </xsl:if>
  <xsl:apply-templates select="sxml:MINIMUM_EXTENT"/>
  <xsl:apply-templates select="sxml:LOGGING"/>
  <xsl:if test="not(sxml:LOST_WRITE_PROTECTION)">
   <xsl:choose>
    <xsl:when test="sxml:OFFLINE"> OFFLINE</xsl:when>
    <xsl:otherwise> ONLINE</xsl:otherwise>
   </xsl:choose>
  </xsl:if>
  <xsl:apply-templates select="sxml:BLOCKSIZE"/>
  <xsl:apply-templates select="sxml:FORCE_LOGGING"/>
  <xsl:apply-templates select="sxml:EXTENT_MANAGEMENT"/>
  <xsl:apply-templates select="sxml:DEFAULT"/>
  <xsl:apply-templates select="sxml:SEGMENT_SPACE_MANAGEMENT"/>
 </xsl:template>
 <xsl:template match="sxml:DATAFILE_LIST">
  <!-- *******************************************************************
Template: DATAFILE_LIST
******************************************************************** -->
  <xsl:for-each select="sxml:DATAFILE_LIST_ITEM">
   <xsl:if test="$PRETTY=1">
    <xsl:text>&#xa;   </xsl:text>
   </xsl:if>
   <xsl:if test="sxml:NAME">
    <xsl:text>'</xsl:text>
    <xsl:value-of select="sxml:NAME"/>
    <xsl:text>'</xsl:text>
   </xsl:if>
   <xsl:if test="sxml:SIZE">
    <xsl:text> SIZE </xsl:text>
    <xsl:value-of select="sxml:SIZE"/>
   </xsl:if>
   <xsl:if test="sxml:NAME and (sxml:REUSE or $REUSE)">
    <xsl:text> REUSE</xsl:text>
   </xsl:if>
   <xsl:if test="sxml:AUTOEXTEND">
    <xsl:if test="$PRETTY=1">
     <xsl:text>&#xa;   </xsl:text>
    </xsl:if>
    <xsl:text> AUTOEXTEND ON</xsl:text>
    <xsl:if test="sxml:AUTOEXTEND/sxml:NEXT">
     <xsl:text> NEXT </xsl:text>
     <xsl:value-of select="sxml:AUTOEXTEND/sxml:NEXT"/>
    </xsl:if>
    <xsl:if test="sxml:AUTOEXTEND/sxml:MAXSIZE">
     <xsl:text> MAXSIZE </xsl:text>
     <xsl:value-of select="sxml:AUTOEXTEND/sxml:MAXSIZE"/>
    </xsl:if>
   </xsl:if>
   <xsl:if test="position()!=last()">
    <xsl:if test="$PRETTY=1">
     <xsl:text>,</xsl:text>
    </xsl:if>
   </xsl:if>
  </xsl:for-each>
 </xsl:template>
 <xsl:template match="sxml:EXTENT_MANAGEMENT">
  <!-- *******************************************************************
Template: EXTENT_MANAGEMENT
******************************************************************** -->
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa; </xsl:text>
  </xsl:if>
  <xsl:text> EXTENT MANAGEMENT </xsl:text>
  <xsl:value-of select="sxml:TYPE"/>
  <xsl:if test="sxml:ALLOCATION_TYPE">
   <xsl:text> </xsl:text>
   <xsl:value-of select="sxml:ALLOCATION_TYPE"/>
  </xsl:if>
  <xsl:if test="sxml:SIZE">
   <xsl:text> SIZE </xsl:text>
   <xsl:value-of select="sxml:SIZE"/>
  </xsl:if>
  <xsl:apply-templates select="../sxml:ENCRYPT"/>
 </xsl:template>
 <xsl:template match="sxml:RETENTION_GUARANTEE">
  <!-- *******************************************************************
Template: RETENTION_GUARANTEE
******************************************************************** -->
  <xsl:text> RETENTION GUARANTEE</xsl:text>
 </xsl:template>
 <xsl:template match="sxml:TABLESPACE_GROUP">
  <!-- *******************************************************************
Template: TABLESPACE_GROUP
******************************************************************** -->
  <xsl:text> TABLESPACE GROUP </xsl:text>
  <xsl:value-of select="."/>
 </xsl:template>
 <xsl:template match="sxml:MINIMUM_EXTENT">
  <!-- *******************************************************************
Template: MINIMUM_EXTENT
******************************************************************** -->
  <xsl:text> MINIMUM EXTENT </xsl:text>
  <xsl:value-of select="."/>
 </xsl:template>
 <xsl:template match="sxml:BLOCKSIZE">
  <!-- *******************************************************************
Template: BLOCKSIZE
******************************************************************** -->
  <xsl:text> PERMANENT BLOCKSIZE </xsl:text>
  <xsl:value-of select="."/>
 </xsl:template>
 <xsl:template match="sxml:FORCE_LOGGING">
  <!-- *******************************************************************
Template: FORCE_LOGGING
******************************************************************** -->
  <xsl:text> FORCE LOGGING </xsl:text>
 </xsl:template>
 <xsl:template match="sxml:DEFAULT">
  <!-- *******************************************************************
Template: DEFAULT
******************************************************************** -->
  <xsl:text> DEFAULT</xsl:text>
  <xsl:apply-templates select="sxml:INMEMORY"/>
  <xsl:call-template name="DoCompressDDL">
   <xsl:with-param name="Compress" select="sxml:COMPRESS"/>
   <xsl:with-param name="TableCompress" select="sxml:TABLE_COMPRESS"/>
   <xsl:with-param name="CompressLevel" select="sxml:COMPRESS_LEVEL"/>
   <xsl:with-param name="RowLevelLocking" select="sxml:ROW_LEVEL_LOCKING"/>
   <xsl:with-param name="IndexCompress" select="sxml:INDEX_COMPRESS"/>
  </xsl:call-template>
  <xsl:if test="sxml:NO_CELLMEMORY">
   <xsl:text> NO CELLMEMORY</xsl:text>
  </xsl:if>
  <xsl:if test="sxml:CELLMEMORY">
   <xsl:if test="$PRETTY=1">
    <xsl:text>&#xa;</xsl:text>
   </xsl:if>
   <xsl:text> CELLMEMORY</xsl:text>
   <xsl:choose>
    <xsl:when test="sxml:CELLMEMORY='MEMCOMPRESS FOR QUERY'">
     <xsl:text> MEMCOMPRESS FOR QUERY</xsl:text>
    </xsl:when>
    <xsl:when test="sxml:CELLMEMORY='MEMCOMPRESS FOR CAPACITY'">
     <xsl:text> MEMCOMPRESS FOR CAPACITY</xsl:text>
    </xsl:when>
   </xsl:choose>
  </xsl:if>
  <xsl:apply-templates select="sxml:STORAGE"/>
 </xsl:template>
 <xsl:template match="sxml:SEGMENT_SPACE_MANAGEMENT">
  <!-- *******************************************************************
Template: SEGMENT_SPACE_MANAGEMENT
******************************************************************** -->
  <xsl:text> SEGMENT SPACE MANAGEMENT </xsl:text>
  <xsl:value-of select="."/>
 </xsl:template>
</xsl:stylesheet>

OHA YOOOO