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/kusstorg.xsl

<?xml version="1.0"?>
<!-- Copyright (c) 2004, 2017, Oracle and/or its affiliates. 
All rights reserved.-->
<!--
NAME
    kusstorg.xsl
DESCRIPTION
    This is a utility stylesheet for generating SXML syntax for
    physical attributes:
     - segment_attributes_clause
     - physical_attributes_clause
     - storage_clause

MODIFIED        MM/DD/YY
    jjanosik    03/24/17 - Bug 24517168: Add storage to subpartitions
    tbhukya     03/21/17 - Bug 25747729: Fix table and index compression
    bwright     03/16/17 - Bug 25326861: Fix INITRANS of part. cluster
    tbhukya     02/13/17 - Bug 25414028: Segment creation not valid in 
                           Partitioned MV log
    tbhukya     01/30/17 - Bug 25095866: Generate MEMOPTIMIZE clause
    jjanosik    12/01/16 - Bug 24465253: Support cellmemory compression in
                           composite partitions
    jjanosik    07/14/16 - Bug 23752742: fix OLTP compression condition
    tbhukya     06/09/16 - Bug 22171888: Support CELLMEMORY
    tbhukya     12/24/15 - RTI 18868579: Replace CellCache with CellMemory
    tbhukya     11/12/15 - Bug 22171671: Generate STORAGE when metadata exists
    tbhukya     11/12/15 - Bug 22171671: Add MAXTRANS
    tbhukya     09/28/15 - Bug 21822731: Support CELLCACHE 
    tbhukya     09/28/15 - Bug 21822338: Support INDEX COMPRESS
    tbhukya     08/31/15 - Bug 21179353: Generate segment_creation_immediate for 
                           non-partitioned table
    tbhukya     08/12/15 - Bug 21276592: Partitioned cluster
    tbhukya     01/05/15 - Bug 20319428: Declare referred params
    rapayne     11/07/14 - bug 19976325 - deferred segment support for [P]IOTs.
    lbarton     09/24/14 - row archival and SXML
    rapayne     03/15/13 - bug 15924364: new COMPRESSION syntax.
    lbarton     09/19/11 - project 32935: row level locking
    rapayne     10/22/10 - bug 9836784: fix doDeferredStg to honor
                           STORAGE transform parameter.
    lbarton     11/04/09 - deferred segment creation for partitions
    abodge      09/22/09 - CONSOLIDATE STYLESHEETS: PHYSICAL_PROPERTIES hack
    lbarton     08/31/09 - bug 8820324: support all values in deferred_stg
    lbarton     08/17/09 - bug 8795792: no compress/logging in deferred stg for
                           indexes
    lbarton     07/10/09 - bug 8494344: archive compression
    rapayne     07/20/09 - bug 8692388: suppress STORAGE clause if there are no
                           relevant storage params.
    rapayne     05/22/09 - bug 8391296: Fix support for  CELL_FLASH_BUFFER and FLASH_CACHE
    rapayne     05/10/09 - bug 8355496: add framework for index deferred storage
                           support.
    adalee      04/16/09 - add FLASH_CACHE and CELL_FLASH_CACHE
    lbarton     02/11/08 - reference/system partitioning
    lbarton     03/19/08 - deferred segment creation
    slynn       10/12/06 - smartfile->securefileversion
    htseng      07/31/06 - add lobretention/maxsize support
    lbarton     11/09/05 - bug 4724986: fix handling of xmlns 
    sdavidso    11/02/05 - fix inconsistent stylesheet format 
    lbarton     09/12/05 - Move no blocksize error to StorageClause 
    lbarton     08/10/05 - lbarton_mddiff
    lbarton     11/04/04 - Initial version
 -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://xmlns.oracle.com/ku">
 <!-- Top level imports -->
 <xsl:import href="kuscomm.xsl"/>
 <!-- Top level params -->
 <xsl:param name="SEGMENT_ATTRIBUTES">1</xsl:param>
 <xsl:param name="STORAGE">1</xsl:param>
 <xsl:param name="TABLESPACE">1</xsl:param>
 <xsl:param name="PHYSICAL_PROPERTIES">1</xsl:param>
 <!-- Templates -->
 <xsl:template name="SegmentAttributes">
  <xsl:param name="ParentNode" select="''"/>
  <xsl:param name="Partitioned" select="''"/>
  <xsl:param name="ObjType">TABLE</xsl:param>
  <xsl:param name="PartitionType" select="''"/>
  <xsl:param name="DefaultBlocksize" select="''"/>
  <xsl:param name="TableNode" select="''"/>
  <xsl:param name="PartNode" select="''"/>
  <!-- *******************************************************************
Template: SegmentAttributes
Parameters:
  ParentNode - Parent node of TS_NAME, BLOCKSIZE, PCT_FREE, etc.
  Partitioned - 0 = non-partitioned, non-0 = partitioned
                Used to locate/interpret the storage and logging information.
                For non-partitioned objects storage information (INIEXTS, etc.)
                is stored under STORAGE (a peer of PCT_FREE, etc.);
                for partitioned objects the information (DEFINIEXTS, etc.)
                is at the same level as DEFPCTFREE, etc.
                The location and encoding of logging information is
                different for partitioned/non-partitioned objects.
                See "LoggingClause", below.
  ObjType - One of
              "TABLE" (default)
              "INDEX" (used for both indexes and IOTs)
              "ROLLBACK"
              "TABLESPACE"
              "PARTITION"
              "PIOT_PARTITION"
  PartitionType - RANGE, HASH, LIST, ''
  DefaultBlocksize - For StorageClause
  TableNode: TABLE_T
  PartNode: partition or subpartition node (PART_LIST_ITEM or SUBPARTS_ITEM)
******************************************************************** -->
  <xsl:if test="not ($SEGMENT_ATTRIBUTES=0) and 
                not ($CM_MODE=1 and $PHYSICAL_PROPERTIES=0)">
   <xsl:element name="SEGMENT_ATTRIBUTES">
    <xsl:call-template name="PhysicalAttributes">
     <xsl:with-param name="ParentNode" select="$ParentNode"/>
     <xsl:with-param name="Partitioned" select="$Partitioned"/>
     <xsl:with-param name="ObjType" select="$ObjType"/>
     <xsl:with-param name="DefaultBlocksize" select="$DefaultBlocksize"/>
     <xsl:with-param name="TableNode" select="$TableNode"/>
     <xsl:with-param name="PartNode" select="$PartNode"/>
    </xsl:call-template>
    <xsl:call-template name="Tablespace">
     <xsl:with-param name="ParentNode" select="$ParentNode"/>
    </xsl:call-template>
    <!--xsl:if test="$ObjType!='PARTITION' and $ObjType!='PIOT_PARTITION'"-->
    <xsl:if test="$PartitionType!='HASH'">
     <xsl:call-template name="LoggingClause">
      <xsl:with-param name="Partitioned" select="$Partitioned"/>
      <xsl:with-param name="FlagsNode" select="$ParentNode/FLAGS"/>
      <xsl:with-param name="DefloggingNode" select="$ParentNode/DEFLOGGING"/>
      <xsl:with-param name="PartitionType" select="$PartitionType"/>
     </xsl:call-template>
    </xsl:if>
   </xsl:element>
  </xsl:if>
 </xsl:template>
 <xsl:template name="PhysicalAttributes">
  <xsl:param name="ParentNode" select="''"/>
  <xsl:param name="Partitioned" select="''"/>
  <xsl:param name="ObjType">TABLE</xsl:param>
  <xsl:param name="DefaultBlocksize" select="''"/>
  <xsl:param name="TableNode" select="''"/>
  <xsl:param name="PartNode" select="''"/>
  <xsl:param name="OIDIndex">0</xsl:param>
  <!-- *******************************************************************
Template: PhysicalAttributes
Parameters:
  ParentNode - Parent node of TS_NAME, BLOCKSIZE, PCT_FREE, etc.
  Partitioned - 0 = non-partitioned, non-0 = partitioned
  ObjType - One of
              "TABLE" (default)
              "INDEX" (used for both indexes and IOTs)
              "ROLLBACK"
              "TABLESPACE"
              "PARTITION"
              "PIOT_PARTITION"
  DefaultBlocksize - For StorageClause
  TableNode: TABLE_T
  PartNode: partition or subpartition node (PART_LIST_ITEM or SUBPARTS_ITEM)
  OIDIndex: flag to indicate we are processing an OID Index clause and do NOT 
         want to call DeferredSegmentCreationClause
******************************************************************** -->
  <xsl:variable name="doV12SegCreation">
   <xsl:choose>
    <xsl:when test="$VERSION>=1202000000 and
                      ( $ObjType='PIOT_PARTITION' or 
                      ($ObjType='INDEX' and $PartNode and $PartNode/TABPARTOBJ) or
                      ($ObjType='INDEX' and $TableNode and ($TableNode/PROPERTY mod 64)&lt;32))">1</xsl:when>
    <xsl:otherwise>0</xsl:otherwise>
   </xsl:choose>
  </xsl:variable>
  <xsl:if test="$OIDIndex=0 and ($ObjType='TABLE' or $ObjType='PARTITION' or
                       $doV12SegCreation = 1)">
   <xsl:call-template name="DeferredSegmentCreationClause">
    <xsl:with-param name="TableNode" select="$TableNode"/>
    <xsl:with-param name="PartNode" select="$PartNode"/>
   </xsl:call-template>
   <xsl:choose>
    <xsl:when test="$ObjType='TABLE'">
     <xsl:choose>
      <!-- Generate cellmemory at Partitioned table level -->
      <xsl:when test="$TableNode and $TableNode/PART_OBJ/PARTOBJ">
       <xsl:call-template name="DoPartObjCMemoryCompress">
        <xsl:with-param name="CMCompress" select="$TableNode/PART_OBJ/PARTOBJ/SPARE3"/>
       </xsl:call-template>
      </xsl:when>
     </xsl:choose>
     <!-- Generate Memoptimize at table level -->
     <xsl:if test="$TableNode and $TableNode/PROPERTY3">
      <xsl:variable name="MemoptRead">134217728</xsl:variable>
      <xsl:variable name="MemoptWrite">268435456</xsl:variable>
      <xsl:call-template name="DoMemoptimizeSyntax">
       <xsl:with-param name="isMemoptRead" select="($TableNode/PROPERTY3 mod ($MemoptRead*2)>=$MemoptRead)"/>
       <xsl:with-param name="isMemoptWrite" select="($TableNode/PROPERTY3 mod ($MemoptWrite*2)>=$MemoptWrite)"/>
      </xsl:call-template>
     </xsl:if>
    </xsl:when>
    <!-- Generate cellmemory at partition level -->
    <xsl:when test="$ObjType='PARTITION'">
     <xsl:call-template name="DoPartCellMemory">
      <xsl:with-param name="TableNode" select="$TableNode"/>
      <xsl:with-param name="PartNode" select="$PartNode"/>
     </xsl:call-template>
     <!-- Generate Memoptimize at partition level -->
     <xsl:variable name="MemoptRead">1073741824</xsl:variable>
     <xsl:variable name="MemoptWrite">2147483648</xsl:variable>
     <xsl:call-template name="DoMemoptimizeSyntax">
      <xsl:with-param name="isMemoptRead" select="($PartNode/FLAGS mod ($MemoptRead*2)>=$MemoptRead)"/>
      <xsl:with-param name="isMemoptWrite" select="($PartNode/FLAGS mod ($MemoptWrite*2)>=$MemoptWrite)"/>
     </xsl:call-template>
    </xsl:when>
   </xsl:choose>
  </xsl:if>
  <xsl:element name="PCTFREE">
   <xsl:value-of select="$ParentNode/PCT_FREE"/>
   <xsl:value-of select="$ParentNode/DEFPCTFREE"/>
  </xsl:element>
  <xsl:if test="($ObjType!='INDEX') and ($ObjType!='PIOT_PARTITION') and ($OIDIndex=0)">
   <xsl:element name="PCTUSED">
    <xsl:value-of select="$ParentNode/PCT_USED"/>
    <xsl:value-of select="$ParentNode/DEFPCTUSED"/>
   </xsl:element>
  </xsl:if>
  <xsl:element name="INITRANS">
   <!-- Work around for bug 21557769 -->
   <xsl:choose>
    <xsl:when test="$TableNode and $TableNode/SCHEMA_OBJ/TYPE_NAME='CLUSTER' and $ObjType='PARTITION' and $ParentNode/INITRANS and $ParentNode/INITRANS=1">
     <xsl:text>2</xsl:text>
    </xsl:when>
    <xsl:when test="$TableNode and $TableNode/SCHEMA_OBJ/TYPE_NAME='CLUSTER' and $Partitioned!=0 and $ParentNode/DEFINITRANS and $ParentNode/DEFINITRANS=1">
     <xsl:text>2</xsl:text>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="$ParentNode/INITRANS"/>
     <xsl:value-of select="$ParentNode/DEFINITRANS"/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:element>
  <xsl:element name="MAXTRANS">
   <xsl:value-of select="$ParentNode/MAXTRANS"/>
   <xsl:value-of select="$ParentNode/DEFMAXTRANS"/>
  </xsl:element>
  <!-- STORAGE -->
  <xsl:choose>
   <!-- non-partitioned -->
   <xsl:when test="$Partitioned=0">
    <xsl:choose>
     <!-- segment creation deferred for table and index -->
     <xsl:when test="(($ObjType='TABLE' or $ObjType='PARTITION') and
                      $ParentNode/DEFERRED_STG) or
                     ($ObjType = 'INDEX' and
                      string-length($ParentNode/BLOCKSIZE)!=0 and 
                      $ParentNode/DEFERRED_STG)">
      <xsl:call-template name="DoDeferredStg">
       <xsl:with-param name="DeferredStg" select="$ParentNode/DEFERRED_STG"/>
       <xsl:with-param name="BlockSize" select="$ParentNode/BLOCKSIZE | $ParentNode/DEFBLOCKSIZE"/>
      </xsl:call-template>
     </xsl:when>
     <xsl:when test="string-length($ParentNode/BLOCKSIZE)!=0 and
                     $ParentNode/STORAGE">
      <xsl:call-template name="StorageClause">
       <xsl:with-param name="StorageNode" select="$ParentNode/STORAGE"/>
       <xsl:with-param name="BlkSize" select="$ParentNode/BLOCKSIZE"/>
      </xsl:call-template>
     </xsl:when>
     <xsl:when test="string-length($DefaultBlocksize)!=0 and 
                     $ParentNode/STORAGE">
      <xsl:call-template name="StorageClause">
       <xsl:with-param name="StorageNode" select="$ParentNode/STORAGE"/>
       <xsl:with-param name="BlkSize" select="$DefaultBlocksize"/>
      </xsl:call-template>
     </xsl:when>
    </xsl:choose>
   </xsl:when>
   <!-- partitioned -->
   <xsl:otherwise>
    <xsl:choose>
     <xsl:when test="string-length($ParentNode/BLOCKSIZE)!=0 or
                    string-length($ParentNode/DEFBLOCKSIZE)!=0">
      <xsl:call-template name="StorageClause">
       <xsl:with-param name="StorageNode" select="$ParentNode"/>
       <xsl:with-param name="BlkSize" select="$ParentNode/BLOCKSIZE | $ParentNode/DEFBLOCKSIZE"/>
      </xsl:call-template>
     </xsl:when>
     <xsl:when test="string-length($DefaultBlocksize)!=0">
      <xsl:call-template name="StorageClause">
       <xsl:with-param name="StorageNode" select="$ParentNode"/>
       <xsl:with-param name="BlkSize" select="$DefaultBlocksize"/>
      </xsl:call-template>
     </xsl:when>
    </xsl:choose>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="DeferredSegmentCreationClause">
  <xsl:param name="TableNode" select="''"/>
  <xsl:param name="PartNode" select="''"/>
  <!-- *******************************************************************
Template: DeferredSegmentCreationClause: Optionally emit the 
                deferred segment creation clause
Parameters:
  TableNode: TABLE_T
  PartNode: partition or subpartition node (PART_LIST_ITEM or SUBPARTS_ITEM)
******************************************************************** -->
  <!-- SEGMENT CREATION syntax is new in 11.2;
        not valid for IOTs
                      clustered tables
                      temporary tables
                      typed tables
                      AQ tables
                      external tables
                      tables owned by SYS, SYSTEM, PUBLIC, OUTLN, XDB
                      Partitioned cluster
                      Materialized view log
     12.2 added suppport for IOTs, OBJECT and XMLTYPE tables
    -->
  <xsl:if test="string-length($TableNode)>0
                  and $VERSION>=1102000000
                  and not ((($TableNode/PROPERTY) mod 262144)>=131072)
                  and $TableNode/SCHEMA_OBJ/OWNER_NAME!='SYS'
                  and $TableNode/SCHEMA_OBJ/OWNER_NAME!='SYSTEM'
                  and $TableNode/SCHEMA_OBJ/OWNER_NAME!='PUBLIC'
                  and $TableNode/SCHEMA_OBJ/OWNER_NAME!='OUTLN'
                  and $TableNode/SCHEMA_OBJ/OWNER_NAME!='XDB'
                  and $TableNode/SCHEMA_OBJ/TYPE_NAME!='CLUSTER'
                  and not ($TableNode/ancestor::M_VIEW_LOG_T)">
   <xsl:choose>
    <xsl:when test="($TableNode/PROPERTY mod 64)&lt;32">
     <!-- non-partitioned table -->
     <xsl:choose>
      <xsl:when test="($TableNode/PROPERTY2 mod 8)>=4">
       <xsl:element name="SEGMENT_CREATION_DEFERRED"/>
      </xsl:when>
      <xsl:otherwise>
       <xsl:element name="SEGMENT_CREATION_IMMEDIATE"/>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:when>
    <xsl:when test="string-length($PartNode)=0">
     <!-- table-level setting of partitioned table -->
     <xsl:choose>
      <xsl:when test="($TableNode/PART_OBJ/PARTOBJ/FLAGS mod 4096)>=2048 or 
                          ($TableNode/PART_OBJ/TABPARTOBJ/FLAGS mod 4096)>=2048">
       <xsl:element name="SEGMENT_CREATION_DEFERRED"/>
      </xsl:when>
      <xsl:when test="($TableNode/PART_OBJ/PARTOBJ/FLAGS mod 8192)>=4096 or 
                          ($TableNode/PART_OBJ/TABPARTOBJ/FLAGS mod 8192)>=4096">
       <xsl:element name="SEGMENT_CREATION_IMMEDIATE"/>
      </xsl:when>
     </xsl:choose>
    </xsl:when>
    <xsl:when test="$PartNode/TABPARTOBJ">
     <!-- table level PIOT -->
     <xsl:choose>
      <xsl:when test="(($PartNode/TABPARTOBJ/FLAGS) mod 4096)>=2048">
       <xsl:element name="SEGMENT_CREATION_DEFERRED"/>
      </xsl:when>
      <xsl:when test="(($PartNode/TABPARTOBJ/FLAGS) mod 8192)>=4096">
       <xsl:element name="SEGMENT_CREATION_IMMEDIATE"/>
      </xsl:when>
     </xsl:choose>
    </xsl:when>
    <xsl:when test="local-name($PartNode)='COMPART_LIST_ITEM'">
     <!-- composite partition setting -->
     <xsl:if test="$PartNode/SPARE2">
      <xsl:variable name="CMCompress" select="$PartNode/SPARE2"/>
      <!-- SPARE2 bits. These were gleaned (not copied directly) from cdpart.sql
                8589934592 0x0200000000 'DISABLED',
                4294967296 0x0100000000 'MEMCOMPRESS',
               34359738368 0x0800000000 'MEMCOMPRESS FOR QUERY',
               68719476736 0x1000000000 'MEMCOMPRESS FOR CAPACITY',
      -->
      <xsl:variable name="flagNoCMemory">8589934592</xsl:variable>
      <xsl:variable name="flagCMemory">4294967296</xsl:variable>
      <xsl:variable name="flagCMCompressQuery">34359738368</xsl:variable>
      <xsl:variable name="flagCMCompressCapacity">68719476736</xsl:variable>
      <xsl:variable name="isCMemory" select="($CMCompress mod ($flagCMemory*2))>=$flagCMemory"/>
      <xsl:call-template name="DoCMemoryCompressSyntax">
       <xsl:with-param name="isNoCMemory" select="($CMCompress mod ($flagNoCMemory*2))>=$flagNoCMemory"/>
       <xsl:with-param name="isCMemory" select="$isCMemory"/>
       <xsl:with-param name="isCMCompressQuery" select="$isCMemory and ($CMCompress mod ($flagCMCompressQuery*2))>=$flagCMCompressQuery"/>
       <xsl:with-param name="isCMCompressCapacity" select="$isCMemory and ($CMCompress mod ($flagCMCompressCapacity*2))>=$flagCMCompressCapacity"/>
      </xsl:call-template>
     </xsl:if>
     <xsl:choose>
      <xsl:when test="(($PartNode/SPARE2) mod 512)>=256">
       <xsl:element name="SEGMENT_CREATION_DEFERRED"/>
      </xsl:when>
      <xsl:when test="(($PartNode/SPARE2) mod 1024)>=512">
       <xsl:element name="SEGMENT_CREATION_IMMEDIATE"/>
      </xsl:when>
     </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
     <!-- partition leaf setting -->
     <xsl:choose>
      <xsl:when test="(($PartNode/FLAGS) mod 131072)>=65536">
       <xsl:element name="SEGMENT_CREATION_DEFERRED"/>
      </xsl:when>
      <xsl:otherwise>
       <xsl:element name="SEGMENT_CREATION_IMMEDIATE"/>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:if>
 </xsl:template>
 <!-- **************************************************************
Template: DoPartObjCMemoryCompress: Generate object level cellmemory
                                    for a partitioned table.
   Parameter:
        CMCompress : Cellmemory flag value
******************************************************************** -->
 <xsl:template name="DoPartObjCMemoryCompress">
  <xsl:param name="CMCompress">0</xsl:param>
  <!--  131072   - No Cellmemory
        262144   - Cellmemory enabled
        524288   - memcompress for query
       1048576   - memcompress for capacity
    -->
  <xsl:variable name="flagNoCMemory">131072</xsl:variable>
  <xsl:variable name="flagCMemory">262144</xsl:variable>
  <xsl:variable name="flagCMCompressQuery">524288</xsl:variable>
  <xsl:variable name="flagCMCompressCapacity">1048576</xsl:variable>
  <xsl:call-template name="DoCMemoryCompressSyntax">
   <xsl:with-param name="isNoCMemory" select="($CMCompress mod ($flagNoCMemory*2)>=$flagNoCMemory)"/>
   <xsl:with-param name="isCMemory" select="($CMCompress mod ($flagCMemory*2)>=$flagCMemory)"/>
   <xsl:with-param name="isCMCompressQuery" select="($CMCompress mod ($flagCMCompressQuery*2)>=$flagCMCompressQuery)"/>
   <xsl:with-param name="isCMCompressCapacity" select="($CMCompress mod ($flagCMCompressCapacity*2)>=$flagCMCompressCapacity)"/>
  </xsl:call-template>
 </xsl:template>
 <!-- **************************************************************
Template: DoPartCellMemory: emit cellmemory at partition level 
                            for a partitioned table
   Parameters:
       TableNode: TABLE_T
       PartNode: partition node PART_LIST_ITEM
******************************************************************** -->
 <xsl:template name="DoPartCellMemory">
  <xsl:param name="TableNode" select="''"/>
  <xsl:param name="PartNode" select="''"/>
  <!-- Object level cell memory defaults to partitions as well.
       So, generate cell memory at partition level when object
       level cell memory not specified 
                   OR 
       At Object level, other than no cellmemory provided  and
       At Partition level, no cellmemory provided
    -->
  <xsl:if test="not($TableNode/PART_OBJ/PARTOBJ/SPARE3) or
                   ($TableNode/PART_OBJ/PARTOBJ/SPARE3 and
                    ($TableNode/PART_OBJ/PARTOBJ/SPARE3 mod 262144)&lt;131072 and
                    (($PartNode/DEFERRED_STG/CCFLAG_STG mod 32768)>=16384 or
                     ($PartNode/STORAGE/FLAGS mod 562949953421312)>=281474976710656))">
   <xsl:choose>
    <xsl:when test="$PartNode/DEFERRED_STG">
     <xsl:variable name="CMCompress" select="$PartNode/DEFERRED_STG/CCFLAG_STG"/>
     <!-- 8194  - CELLMEMORY enabled
          8196  - MEMCOMPRESS FOR QUERY
          8200  - MEMCOMPRESS FOR CAPACITY
         16384  - NO CELLMEMORY -->
     <xsl:variable name="flagNoCMemory">16384</xsl:variable>
     <xsl:variable name="flagCMemory">8192</xsl:variable>
     <xsl:variable name="flagCMCompressQuery">4</xsl:variable>
     <xsl:variable name="flagCMCompressCapacity">8</xsl:variable>
     <xsl:variable name="isCMemory" select="($CMCompress mod ($flagCMemory*2)>=$flagCMemory)"/>
     <xsl:call-template name="DoCMemoryCompressSyntax">
      <xsl:with-param name="isNoCMemory" select="($CMCompress mod ($flagNoCMemory*2)>=$flagNoCMemory)"/>
      <xsl:with-param name="isCMemory" select="$isCMemory"/>
      <xsl:with-param name="isCMCompressQuery" select="$isCMemory and ($CMCompress mod ($flagCMCompressQuery*2)>=4)"/>
      <xsl:with-param name="isCMCompressCapacity" select="$isCMemory and ($CMCompress mod ($flagCMCompressCapacity*2)>=8)"/>
     </xsl:call-template>
    </xsl:when>
    <xsl:when test="$PartNode/STORAGE">
     <xsl:variable name="CMCompress" select="$PartNode/STORAGE/FLAGS"/>
     <!--   281474976710656        - NO CELLMEMORY
            140737488355328        - CELLMEMORY Enabled
           1125899906842624        - MEMCOMPRESS FOR QUERY
           2251799813685248        - MEMCOMPRESS FOR CAPACITY
       -->
     <xsl:variable name="flagNoCMemory">281474976710656</xsl:variable>
     <xsl:variable name="flagCMemory">140737488355328</xsl:variable>
     <xsl:variable name="flagCMCompressQuery">1125899906842624</xsl:variable>
     <xsl:variable name="flagCMCompressCapacity">2251799813685248</xsl:variable>
     <xsl:variable name="isCMemory" select="($CMCompress mod ($flagCMemory*2)>=$flagCMemory)"/>
     <xsl:call-template name="DoCMemoryCompressSyntax">
      <xsl:with-param name="isNoCMemory" select="($CMCompress mod ($flagNoCMemory*2)>=$flagNoCMemory)"/>
      <xsl:with-param name="isCMemory" select="$isCMemory"/>
      <xsl:with-param name="isCMCompressQuery" select="$isCMemory and ($CMCompress mod ($flagCMCompressQuery*2)>=$flagCMCompressQuery)"/>
      <xsl:with-param name="isCMCompressCapacity" select="$isCMemory and ($CMCompress mod ($flagCMCompressCapacity*2)>=$flagCMCompressCapacity)"/>
     </xsl:call-template>
    </xsl:when>
   </xsl:choose>
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoDeferredStg">
  <xsl:param name="DeferredStg" select="''"/>
  <xsl:param name="Blocksize">8192</xsl:param>
  <xsl:param name="IsSubpartition">0</xsl:param>
  <!-- *******************************************************************
Template: DoDeferredStg - generate storage params when seg creation deferred
Current node:  INDEX_T/PARTITION_LIST/PARTITION_LIST_ITEM
            or TABLE_T
Parameters:
  DeferredStg - DEFERRED_STORAGE node
  Blocksize - 

need to build storage clause
  <STORAGE>
      <INITIAL>2097152</INITIAL>
      <NEXT>1048576</NEXT>
      <MINEXTENTS>1</MINEXTENTS>
      <MAXEXTENTS>2147483645</MAXEXTENTS>
      <PCTINCREASE>0</PCTINCREASE>
      <MAXSIZE>10485760</MAXSIZE>
      <FREELISTS>1</FREELISTS>
      <FREELIST_GROUPS>1</FREELIST_GROUPS>
      <BUFFER_POOL>DEFAULT</BUFFER_POOL>
  </STORAGE

******************************************************************** -->
  <xsl:variable name="hasINITIAL" select="$DeferredStg and $DeferredStg/INITIAL_STG"/>
  <xsl:variable name="hasNEXT" select="$DeferredStg and $DeferredStg/NEXT_STG"/>
  <xsl:variable name="hasMINEXT" select="$DeferredStg and $DeferredStg/MINEXT_STG"/>
  <xsl:variable name="hasMAXEXT" select="$DeferredStg and $DeferredStg/MAXEXT_STG"/>
  <xsl:variable name="hasPCTINC" select="$DeferredStg and $DeferredStg/PCTINC_STG"/>
  <xsl:variable name="hasMAXSIZE" select="$DeferredStg and $DeferredStg/MAXSIZ_STG"/>
  <xsl:variable name="hasFREELISTS" select="$DeferredStg and $DeferredStg/FRLINS_STG"/>
  <xsl:variable name="hasFREELIST_GROUPS" select="$DeferredStg and $DeferredStg/MAXINS_STG"/>
  <xsl:variable name="hasBUFFER_POOL" select="$DeferredStg and $DeferredStg/BFP_STG"/>
  <!-- Suppress STORAGE clause if there are no relevant deferred stg params -->
  <xsl:variable name="hasLine1" select="$hasINITIAL or $hasNEXT or $hasMINEXT or $hasMAXEXT"/>
  <xsl:variable name="hasLine2" select="$hasPCTINC or $hasMAXSIZE or $hasFREELISTS or $hasFREELIST_GROUPS or $hasBUFFER_POOL"/>
  <xsl:if test="((not ($STORAGE=0)) and ($hasLine1 or $hasLine2))">
   <xsl:element name="STORAGE">
    <!-- don't do these for subpartitions -->
    <xsl:if test="$IsSubpartition=0">
     <xsl:call-template name="DoDeferredStgParam">
      <xsl:with-param name="ParamName">INITIAL</xsl:with-param>
      <xsl:with-param name="ParamVal" select="$DeferredStg/INITIAL_STG"/>
      <xsl:with-param name="testval" select="$hasINITIAL"/>
      <xsl:with-param name="mult" select="$Blocksize"/>
     </xsl:call-template>
     <xsl:call-template name="DoDeferredStgParam">
      <xsl:with-param name="ParamName">NEXT</xsl:with-param>
      <xsl:with-param name="ParamVal" select="$DeferredStg/NEXT_STG"/>
      <xsl:with-param name="testval" select="$hasNEXT"/>
      <xsl:with-param name="mult" select="$Blocksize"/>
     </xsl:call-template>
     <xsl:call-template name="DoDeferredStgParam">
      <xsl:with-param name="ParamName">MINEXTENTS</xsl:with-param>
      <xsl:with-param name="ParamVal" select="$DeferredStg/MINEXT_STG"/>
      <xsl:with-param name="testval" select="$hasMINEXT"/>
     </xsl:call-template>
     <xsl:call-template name="DoDeferredStgParam">
      <xsl:with-param name="ParamName">MAXEXTENTS</xsl:with-param>
      <xsl:with-param name="ParamVal" select="$DeferredStg/MAXEXT_STG"/>
      <xsl:with-param name="testval" select="$hasMAXEXT"/>
     </xsl:call-template>
     <xsl:call-template name="DoDeferredStgParam">
      <xsl:with-param name="ParamName">PCTINCREASE</xsl:with-param>
      <xsl:with-param name="ParamVal" select="$DeferredStg/PCTINC_STG"/>
      <xsl:with-param name="testval" select="$hasPCTINC"/>
     </xsl:call-template>
     <xsl:call-template name="DoDeferredStgParam">
      <xsl:with-param name="ParamName">MAXSIZE</xsl:with-param>
      <xsl:with-param name="ParamVal" select="$DeferredStg/MAXSIZ_STG"/>
      <xsl:with-param name="testval" select="$hasMAXSIZE"/>
      <xsl:with-param name="mult" select="$Blocksize"/>
     </xsl:call-template>
     <xsl:call-template name="DoDeferredStgParam">
      <xsl:with-param name="ParamName">FREELISTS</xsl:with-param>
      <xsl:with-param name="ParamVal" select="$DeferredStg/FRLINS_STG"/>
      <xsl:with-param name="testval" select="$hasFREELISTS"/>
     </xsl:call-template>
     <xsl:call-template name="DoDeferredStgParam">
      <xsl:with-param name="ParamName">FREELIST_GROUPS</xsl:with-param>
      <xsl:with-param name="ParamVal" select="$DeferredStg/MAXINS_STG"/>
      <xsl:with-param name="testval" select="$hasFREELIST_GROUPS"/>
     </xsl:call-template>
    </xsl:if>
    <xsl:if test="$hasBUFFER_POOL">
     <xsl:apply-templates select="$DeferredStg/BFP_STG"/>
    </xsl:if>
   </xsl:element>
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoIniNext">
  <xsl:param name="Size">0</xsl:param>
  <xsl:param name="BlkSize">0</xsl:param>
  <!-- *******************************************************************
Template: DoIniNext emit the numeric value for INITIAL, NEXT, etc.
Parameters:
 Size: size value in blocks
 BlkSize: value of BLOCKSIZE
******************************************************************** -->
  <xsl:value-of select="$Size*$BlkSize"/>
 </xsl:template>
 <xsl:template name="DoDeferredStgParam">
  <xsl:param name="ParamName" select="''"/>
  <xsl:param name="ParamVal" select="''"/>
  <xsl:param name="testval" select="''"/>
  <xsl:param name="mult">1</xsl:param>
  <!-- *******************************************************************
Template: DoDeferredStgParam - Utility template to emit a single
  STORAGE param
Parameters:
  ParamName - name, e.g., INITIAL
  ParamVal - value if any
  testval - true if ParamVal is valid
  mult - factor to multiply ParamVal (e.g., INITIAL is stored as
         a number of blocks, so mult would be the blocksize)
******************************************************************** -->
  <xsl:if test="$testval">
   <xsl:choose>
    <xsl:when test="$ParamName='MAXSIZE'">
     <xsl:call-template name="DoMAXSIZE">
      <xsl:with-param name="MaxSize" select="$ParamVal"/>
      <xsl:with-param name="BlkSize" select="$mult"/>
     </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
     <xsl:element name="{$ParamName}">
      <xsl:call-template name="DoIniNext">
       <xsl:with-param name="Size" select="$ParamVal"/>
       <xsl:with-param name="BlkSize" select="$mult"/>
      </xsl:call-template>
     </xsl:element>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:if>
 </xsl:template>
 <xsl:template name="StorageClause">
  <xsl:param name="StorageNode" select="''"/>
  <xsl:param name="ObjType">TABLE</xsl:param>
  <xsl:param name="BlkSize">0</xsl:param>
  <xsl:param name="IsSubpartition">0</xsl:param>
  <!-- *******************************************************************
Template: StorageClause
Parameters:
  StorageNode - STORAGE node
  ObjType - One of
              "TABLE" (default)
              "INDEX" (used for both indexes and IOTs)
              "ROLLBACK"
              "TABLESPACE"
              "PARTITION"
              "PIOT_PARTITION"
  BlkSize - tablespace blocksize
******************************************************************** -->
  <xsl:if test="not ($STORAGE=0)">
   <xsl:element name="STORAGE">
    <!-- not for subpartitions -->
    <xsl:if test="$IsSubpartition=0">
     <xsl:if test="$StorageNode/DEFINIEXTS or $StorageNode/INIEXTS
              or $StorageNode/DFLINIT">
      <xsl:if test="$BlkSize=0">
       <xsl:text>
        **** kusstorg.xsl/StorageClause ERROR: No BLOCKSIZE VALUE ***
</xsl:text>
      </xsl:if>
      <xsl:element name="INITIAL">
       <xsl:choose>
        <xsl:when test="$StorageNode/INIEXTS">
         <xsl:value-of select="($StorageNode/INIEXTS)*$BlkSize"/>
        </xsl:when>
        <xsl:when test="$StorageNode/DEFINIEXTS">
         <xsl:value-of select="($StorageNode/DEFINIEXTS)*$BlkSize"/>
        </xsl:when>
        <xsl:when test="$StorageNode/DFLINIT">
         <xsl:value-of select="($StorageNode/DFLINIT)*$BlkSize"/>
        </xsl:when>
       </xsl:choose>
      </xsl:element>
     </xsl:if>
      <xsl:if test="$StorageNode/DEFEXTSIZE or $StorageNode/EXTSIZE
              or $StorageNode/DFLINCR">
      <xsl:if test="$BlkSize=0">
       <xsl:text>
        **** kusstorg.xsl/StorageClause ERROR: No BLOCKSIZE VALUE ***
</xsl:text>
      </xsl:if>
      <xsl:element name="NEXT">
       <xsl:choose>
        <xsl:when test="$StorageNode/EXTSIZE">
         <xsl:value-of select="($StorageNode/EXTSIZE)*$BlkSize"/>
        </xsl:when>
        <xsl:when test="$StorageNode/DEFEXTSIZE">
         <xsl:value-of select="($StorageNode/DEFEXTSIZE)*$BlkSize"/>
        </xsl:when>
        <xsl:when test="$StorageNode/DFLINCR">
         <xsl:value-of select="($StorageNode/DFLINCR)*$BlkSize"/>
        </xsl:when>
       </xsl:choose>
      </xsl:element>
     </xsl:if>
     <xsl:if test="$StorageNode/DEFMINEXTS or $StorageNode/MINEXTS
              or $StorageNode/DFLMINEXT">
      <xsl:element name="MINEXTENTS">
       <xsl:choose>
        <xsl:when test="$StorageNode/MINEXTS">
         <xsl:value-of select="($StorageNode/MINEXTS)"/>
        </xsl:when>
        <xsl:when test="$StorageNode/DEFMINEXTS">
         <xsl:value-of select="($StorageNode/DEFMINEXTS)"/>
        </xsl:when>
        <xsl:when test="$StorageNode/DFLMINEXT">
         <xsl:value-of select="($StorageNode/DFLMINEXT)"/>
        </xsl:when>
       </xsl:choose>
      </xsl:element>
     </xsl:if>
     <xsl:if test="$StorageNode/DEFMAXEXTS or $StorageNode/MAXEXTS
              or $StorageNode/DFLMAXEXT">
      <xsl:element name="MAXEXTENTS">
       <xsl:choose>
        <xsl:when test="$StorageNode/MAXEXTS">
         <xsl:value-of select="($StorageNode/MAXEXTS)"/>
        </xsl:when>
        <xsl:when test="$StorageNode/DEFMAXEXTS">
         <xsl:value-of select="($StorageNode/DEFMAXEXTS)"/>
        </xsl:when>
        <xsl:when test="$StorageNode/DFLMAXEXT">
         <xsl:value-of select="($StorageNode/DFLMAXEXT)"/>
        </xsl:when>
       </xsl:choose>
      </xsl:element>
     </xsl:if>
     <xsl:if test="not($ObjType='ROLLBACK')">
      <xsl:if test="$StorageNode/DEFEXTPCT or $StorageNode/EXTPCT
               or $StorageNode/DFLEXTPCT">
       <xsl:element name="PCTINCREASE">
        <xsl:choose>
         <xsl:when test="$StorageNode/EXTPCT">
          <xsl:value-of select="($StorageNode/EXTPCT)"/>
         </xsl:when>
         <xsl:when test="$StorageNode/DEFEXTPCT">
          <xsl:value-of select="($StorageNode/DEFEXTPCT)"/>
         </xsl:when>
         <xsl:when test="$StorageNode/DFLEXTPCT">
          <xsl:value-of select="($StorageNode/DFLEXTPCT)"/>
         </xsl:when>
        </xsl:choose>
       </xsl:element>
      </xsl:if>
     </xsl:if>
     <xsl:if test="($ObjType != 'ROLLBACK') or
                 ($ObjType != 'TABLESPACE')">
      <!-- MAXSIZE clause -->
      <!-- 11g: BITMAPRANGES => MAXSIZE -->
      <xsl:if test="$StorageNode/BITMAPRANGES and 
         ($StorageNode/FLAGS mod 8388608)>=4194304 or $StorageNode/DEFMAXSIZE">
       <xsl:call-template name="DoMAXSIZE">
        <xsl:with-param name="MaxSize" select="$StorageNode/BITMAPRANGES | $StorageNode/DEFMAXSIZE"/>
        <xsl:with-param name="BlkSize" select="$BlkSize"/>
       </xsl:call-template>
      </xsl:if>
      <xsl:if test="2097152 > ($StorageNode/FLAGS mod 4194304)">
       <xsl:if test="$StorageNode/DEFLISTS > 0 or $StorageNode/LISTS">
        <xsl:element name="FREELISTS">
         <xsl:value-of select="$StorageNode/LISTS"/>
         <xsl:value-of select="$StorageNode/DEFLISTS"/>
        </xsl:element>
       </xsl:if>
       <xsl:if test="$StorageNode/DEFGROUPS > 0 or $StorageNode/GROUPS">
        <xsl:element name="FREELIST_GROUPS">
         <xsl:value-of select="$StorageNode/GROUPS"/>
         <xsl:value-of select="$StorageNode/DEFGROUPS"/>
        </xsl:element>
       </xsl:if>
      </xsl:if>
      </xsl:if>
     </xsl:if>
     <xsl:if test="$StorageNode/CACHEHINT or $StorageNode/DEFBUFPOOL">
      <xsl:apply-templates select="$StorageNode/CACHEHINT | $StorageNode/DEFBUFPOOL"/>
     </xsl:if>
   </xsl:element>
  </xsl:if>
 </xsl:template>
 <xsl:template match="CACHEHINT | DEFBUFPOOL | BFP_STG">
  <!-- *******************************************************************
Template: CACHEHINT | DEFBUFPOOL - output BUFFER_POOL value
******************************************************************** -->
  <!-- BUFFER_POOL is the least significant 2 bits (bit [0-1]) -->
  <xsl:element name="BUFFER_POOL">
   <xsl:choose>
    <xsl:when test="(. mod 4)=1">KEEP</xsl:when>
    <xsl:when test="(. mod 4)=2">RECYCLE</xsl:when>
    <xsl:otherwise>DEFAULT</xsl:otherwise>
   </xsl:choose>
  </xsl:element>
  <!-- new cachehint FLASH_CACHE/ CELL_FLASH_CACHE requires 11.2 comp -->
  <xsl:if test="$VERSION>=1102000000">
   <!-- FLASH_CACHE is the next 2 bits (bit [2-3]) -->
   <xsl:element name="FLASH_CACHE">
    <xsl:choose>
     <xsl:when test="floor((. mod 16) div 4)=1">KEEP</xsl:when>
     <xsl:when test="floor((. mod 16) div 4)=2">NONE</xsl:when>
     <xsl:otherwise>DEFAULT</xsl:otherwise>
    </xsl:choose>
   </xsl:element>
   <!-- CELL_FLASH_CACHE is the next 2 bits (bit [4-5]) -->
   <xsl:element name="CELL_FLASH_CACHE">
    <xsl:choose>
     <xsl:when test="floor((. mod 64) div 16)=1">KEEP</xsl:when>
     <xsl:when test="floor((. mod 64) div 16)=2">NONE</xsl:when>
     <xsl:otherwise>DEFAULT</xsl:otherwise>
    </xsl:choose>
   </xsl:element>
  </xsl:if>
 </xsl:template>
 <xsl:template name="Tablespace">
  <xsl:param name="ParentNode" select="''"/>
  <!-- *******************************************************************
Template: Tablespace
Parameters:
  ParentNode - Parent node of TS_NAME or DEFTS_NAME
******************************************************************** -->
  <xsl:if test="not ($TABLESPACE=0)">
   <xsl:if test="$ParentNode/TS_NAME or $ParentNode/DEFTS_NAME">
    <xsl:element name="TABLESPACE">
     <xsl:value-of select="$ParentNode/TS_NAME"/>
     <xsl:value-of select="$ParentNode/DEFTS_NAME"/>
    </xsl:element>
   </xsl:if>
  </xsl:if>
 </xsl:template>
 <xsl:template name="LoggingClause">
  <xsl:param name="Partitioned" select="''"/>
  <xsl:param name="FlagsNode" select="''"/>
  <xsl:param name="DefloggingNode" select="''"/>
  <xsl:param name="PartitionType" select="''"/>
  <!-- *******************************************************************
Template: LoggingClause
Parameters:
  Partitioned - 0 = non-partitioned, non-0 = partitioned
  FlagsNode - FLAGS node with logging/nologging bit (tab$.flags)
  DefloggingNode - DEFLOGGING node (partobj$.deflogging)
  PartitionType - RANGE, HASH, LIST, ''
******************************************************************** -->
  <xsl:choose>
   <!-- non-partitioned, either a non-partitioned table or
        a leaf partition -->
   <xsl:when test="$Partitioned=0">
    <xsl:choose>
     <xsl:when test="string-length($PartitionType)=0">
      <xsl:element name="LOGGING">
       <xsl:choose>
        <xsl:when test="($FlagsNode mod 64)>=32">N</xsl:when>
        <xsl:otherwise>Y</xsl:otherwise>
       </xsl:choose>
      </xsl:element>
     </xsl:when>
     <!-- a leaf partition: NoLogging is bit 0x04 in FLAGS=1 (in tabpart$) -->
     <xsl:when test="($FlagsNode mod 8)>=4">
      <xsl:element name="LOGGING">N</xsl:element>
     </xsl:when>
    </xsl:choose>
   </xsl:when>
   <!-- partitioned -->
   <xsl:otherwise>
    <xsl:choose>
     <xsl:when test="$DefloggingNode=1">
      <xsl:element name="LOGGING">Y</xsl:element>
     </xsl:when>
     <xsl:when test="$DefloggingNode=2">
      <xsl:element name="LOGGING">N</xsl:element>
     </xsl:when>
    </xsl:choose>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="ParallelClause">
  <xsl:param name="ParentNode" select="''"/>
  <!-- *******************************************************************
Template: ParallelClause
Parameters:
  ParentNode - Parent node of DEGREE
******************************************************************** -->
  <!-- For compatibility support both old and new syntax -->
  <xsl:if test="$ParentNode/DEGREE">
   <xsl:choose>
    <!-- old syntax: PARALLEL (DEGREE n [INSTANCES m])
          For this we use a PARALLEL_DEGREE element -->
    <xsl:when test="32767>($ParentNode/INSTANCES)">
     <xsl:element name="PARALLEL_DEGREE">
      <xsl:choose>
       <xsl:when test="$ParentNode/DEGREE=32767">
        <xsl:element name="DEGREE">DEFAULT</xsl:element>
       </xsl:when>
       <xsl:otherwise>
        <xsl:element name="DEGREE">
         <xsl:value-of select="$ParentNode/DEGREE"/>
        </xsl:element>
       </xsl:otherwise>
      </xsl:choose>
      <xsl:choose>
       <xsl:when test="$ParentNode/INSTANCES=32767">
        <xsl:element name="INSTANCES">DEFAULT</xsl:element>
       </xsl:when>
       <xsl:when test="32767>$ParentNode/INSTANCES">
        <xsl:element name="INSTANCES">
         <xsl:value-of select="$ParentNode/INSTANCES"/>
        </xsl:element>
       </xsl:when>
      </xsl:choose>
     </xsl:element>
    </xsl:when>
    <!-- new syntax PARALLEL [n] -->
    <xsl:otherwise>
     <xsl:element name="PARALLEL">
      <xsl:choose>
       <xsl:when test="32767>($ParentNode/DEGREE)">
        <xsl:value-of select="$ParentNode/DEGREE"/>
       </xsl:when>
       <xsl:otherwise>AUTOMATIC</xsl:otherwise>
      </xsl:choose>
     </xsl:element>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoMAXSIZE">
  <xsl:param name="MaxSize">0</xsl:param>
  <xsl:param name="BlkSize">0</xsl:param>
  <!--  *******************************************************************
Template: DoMAXSIZE
Parameters:
 MaxSize: Maxsimum Size
 BlkSize: Block Size
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="$MaxSize=0">
   </xsl:when>
   <xsl:when test="$MaxSize=4294967295 or $MaxSize=2147483645">
   </xsl:when>
   <xsl:otherwise>
    <xsl:element name="MAXSIZE">
     <xsl:choose>
      <xsl:when test="($MaxSize * $BlkSize) >= (2147483646 * 512)">
       <xsl:text>UNLIMITED</xsl:text>
      </xsl:when>
      <xsl:when test="($MaxSize * $BlkSize) > 2147483647">
       <xsl:value-of select="floor(($MaxSize * $BlkSize) div 1048576)"/>
       <xsl:text>M</xsl:text>
      </xsl:when>
      <xsl:otherwise>
       <xsl:value-of select="$MaxSize * $BlkSize"/>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:element>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="DoCMemoryCompress">
  <xsl:param name="CMCompress">0</xsl:param>
  <!-- ***********************************************************************
Template: DoCMemoryCompress - emit CELLMEMORY MEMCOMPRESS FOR QUERY|CAPACITY

              seg$.spare1:
                   #define KTSSEGM_FLAG_CC_ENABLED      ((ub8)0x0800000000000)
                   #define KTSSEGM_FLAG_CC_NOT_ENABLED  ((ub8)0x1000000000000)
                   #define KTSSEGM_FLAG_CC_IFC          ((ub8)0x2000000000000)
                   #define KTSSEGM_FLAG_CC_QUERY        ((ub8)0x4000000000000)
                   #define KTSSEGM_FLAG_CC_CAPACITY     ((ub8)0x8000000000000)

Parameters:
  CMCompress: Node with STORAGE/FLAGS2 value
************************************************************************** -->
  <xsl:variable name="flagNoCMemory">65536</xsl:variable>
  <xsl:variable name="flagCMemory">131072</xsl:variable>
  <xsl:variable name="flagCMCompressQuery">262144</xsl:variable>
  <xsl:variable name="flagCMCompressCapacity">524288</xsl:variable>
  <xsl:call-template name="DoCMemoryCompressSyntax">
   <xsl:with-param name="isNoCMemory" select="($CMCompress mod ($flagNoCMemory*2)>=$flagNoCMemory)"/>
   <xsl:with-param name="isCMemory" select="($CMCompress mod ($flagCMemory*2)>=$flagCMemory)"/>
   <xsl:with-param name="isCMCompressQuery" select="($CMCompress mod ($flagCMCompressQuery*2)>=$flagCMCompressQuery)"/>
   <xsl:with-param name="isCMCompressCapacity" select="($CMCompress mod ($flagCMCompressCapacity*2)>=$flagCMCompressCapacity)"/>
  </xsl:call-template>
 </xsl:template>
 <xsl:template name="DoSegCompress">
  <xsl:param name="Compress">0</xsl:param>
  <!-- *******************************************************************
Template: DoSegCompress - emit [NO]COMPRESS for leaf partition
                          or non-partitioned table
             seg$.spare1:
                   /* #define KTSSEGM_FLAG_COMPRESSED 0x0800    (2048) */
                   /* #define KTSSEGM_FLAG_OLTP  0x1000000  (16777216) */
                   /* #define KTSSEGM_FLAG_ARCH1 0x2000000  (33554432) */
                   /* #define KTSSEGM_FLAG_ARCH2 0x4000000  (67108864) */
                   /* #define KTSSEGM_FLAG_ARCH3 0x8000000 (134217728) */
       /* #define KTSSEGM_FLAG_HCC_ROW_LOCKING 0x80000000 (2147483648) */
          (names defined in ktscts.h)
  OLTP compression only valid in 11.1 and later
  archive compression only valid in 11.2 and later
  row level locking only valid in 12c and later
Parameters:
  Compress: Node with the compression bit
******************************************************************** -->
  <xsl:if test="$Compress">
   <xsl:variable name="CMCompress" select="$Compress"/>
   <!--   281474976710656 - NO CELLMEMORY
          140737488355328 - CELLMEMORY Enabled
         1125899906842624 - MEMCOMPRESS FOR QUERY
         2251799813685248 - MEMCOMPRESS FOR CAPACITY -->
   <xsl:variable name="flagNoCMemory">281474976710656</xsl:variable>
   <xsl:variable name="flagCMemory">140737488355328</xsl:variable>
   <xsl:variable name="flagCMCompressQuery">1125899906842624</xsl:variable>
   <xsl:variable name="flagCMCompressCapacity">2251799813685248</xsl:variable>
   <xsl:variable name="isCMemory" select="($CMCompress mod ($flagCMemory*2)>=$flagCMemory)"/>
   <xsl:call-template name="DoCMemoryCompressSyntax">
    <xsl:with-param name="isNoCMemory" select="($CMCompress mod ($flagNoCMemory*2)>=$flagNoCMemory)"/>
    <xsl:with-param name="isCMemory" select="$isCMemory"/>
    <xsl:with-param name="isCMCompressQuery" select="$isCMemory and ($CMCompress mod ($flagCMCompressQuery*2)>=$flagCMCompressQuery)"/>
    <xsl:with-param name="isCMCompressCapacity" select="$isCMemory and ($CMCompress mod ($flagCMCompressCapacity*2)>=$flagCMCompressCapacity)"/>
   </xsl:call-template>
  </xsl:if>
  <xsl:variable name="flagCompressed">2048</xsl:variable>
  <xsl:variable name="isCompressed" select="($Compress mod ($flagCompressed * 2))>=$flagCompressed"/>
  <xsl:variable name="flagOLTPCompressed">16777216</xsl:variable>
  <xsl:variable name="isOLTPCompressed" select="($Compress mod ($flagOLTPCompressed * 2))>=$flagOLTPCompressed"/>
  <xsl:variable name="flagArch1">33554432</xsl:variable>
  <xsl:variable name="compressLevel" select="floor(($Compress mod ($flagArch1 * 8)) div $flagArch1)"/>
  <xsl:variable name="isArchCompressed" select="$compressLevel!=0"/>
  <xsl:variable name="rllBit">2147483648</xsl:variable>
  <xsl:variable name="rllOn" select="($Compress mod ($rllBit * 2))>=$rllBit"/>
  <xsl:call-template name="DoCompressSyntax">
   <xsl:with-param name="isCompressed" select="$isCompressed"/>
   <xsl:with-param name="isOLTPCompressed" select="$isOLTPCompressed"/>
   <xsl:with-param name="isArchCompressed" select="$isArchCompressed"/>
   <xsl:with-param name="compressLevel" select="$compressLevel"/>
   <xsl:with-param name="rowLevelLocking" select="$rllOn"/>
  </xsl:call-template>
 </xsl:template>
 <xsl:template name="DoPartOBJCompress">
  <xsl:param name="Compress">0</xsl:param>
  <!-- *******************************************************************
Template: DoPartOBJCompress - emit [NO]COMPRESS default value
          for subpartitions of a composite partitioned table
  [from dpart.bsq]
  /*  compression attribute of the partition */
  /*            following bit patterns are possible: */
  /*            00000000 : Compression not specified */
  /*            00000001 : Compression enabled for direct load operations */
  /*            00000010 : Compression disabled      */
  /*            00000101 : Compression enabled for all operations */
  /*            00001001 : Archive Compression: level 1 */
  /*            00010001 : Archive Compression: level 2 */
  /*            00011001 : Archive Compression: level 3 */
  /*            00100001 : Archive Compression: level 4 */
  /*            00101001 : Archive Compression: level 5 */
  /*            00110001 : Archive Compression: level 6 */
  /*            00111001 : Archive Compression: level 7 */
  /*            01001001 : query low row level locking  */
  /*            01010001 : query high row level locking  */
  /*            01011001 : archive low row level locking  */
  /*            01100001 : archive high row level locking  */
  /*            All other bit patterns are incorrect. */
  These are stored in byte 4 of partobj$.spare2 or byte 0 of tabcompart$.spare2
Parameters:
  Compress: byte containing the partition compression attribute
******************************************************************** -->
  <xsl:variable name="locCompress" select="floor($Compress)"/>
  <xsl:variable name="flagCompressed">1</xsl:variable>
  <xsl:variable name="isCompressed" select="($locCompress mod ($flagCompressed * 2))>=$flagCompressed"/>
  <xsl:variable name="flagOLTPCompressed">4</xsl:variable>
  <xsl:variable name="isOLTPCompressed" select="($Compress mod ($flagOLTPCompressed * 2))>=$flagOLTPCompressed"/>
  <xsl:variable name="flagArch1">8</xsl:variable>
  <xsl:variable name="compressLevel" select="floor(($locCompress mod ($flagArch1 * 8)) div $flagArch1)"/>
  <xsl:variable name="isArchCompressed" select="$compressLevel!=0"/>
  <xsl:variable name="rllBit">64</xsl:variable>
  <xsl:variable name="rllOn" select="($Compress mod ($rllBit * 2))>=$rllBit"/>
  <!-- emit nothing if compression not specified -->
  <xsl:if test="$locCompress!=0">
   <xsl:call-template name="DoCompressSyntax">
    <xsl:with-param name="isCompressed" select="$isCompressed"/>
    <xsl:with-param name="isOLTPCompressed" select="$isOLTPCompressed"/>
    <xsl:with-param name="isArchCompressed" select="$isArchCompressed"/>
    <xsl:with-param name="compressLevel" select="$compressLevel"/>
    <xsl:with-param name="rowLevelLocking" select="$rllOn"/>
   </xsl:call-template>
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoTSCompress">
  <xsl:param name="Compress">0</xsl:param>
  <xsl:param name="Compress2">0</xsl:param>
  <!-- *******************************************************************
Template: DoTSCompress - emit [NO]COMPRESS value for tablespaces
             ts$.flags:
              /* #define KTT_COMPRESSED               0x40 (64)              */
              /* #define KTT_OLTP_COMPRESSION   0x10000(65536)   */
#define KTT_ARCH1_COMPRESSION  ((ub4)0x20000)    /* Archive compressed table */
#define KTT_ARCH2_COMPRESSION  ((ub4)0x40000)    /* Archive compressed table */
#define KTT_ARCH3_COMPRESSION  ((ub4)0x80000)    /* Archive compressed table */
#define KTT_HCC_ROW_LOCKING    ((ub4)0x400000) /* Row level locking with HCC 
                                                                 compression */
#define KTT_IDX_COMPRESSED      ((ub8)0x1000000000000)
/* Type of index compression */
#define KTT_ADVLOW_COMPRESSION  ((ub8)0x2000000000000)       /* Advanced Low */
#define KTT_ADVHIGH_COMPRESSION ((ub8)0x4000000000000)      /* Advanced High */
#define KTT_TBL_COMPRESSED ((ub8)0x8000000000000) /* Tables compressed */

Note: KTT_TBL_COMPRESSED detected in Compress2 using variable flagCompressed2

Note: Changes in this template should probably be duplicated in kustorag.xsl

Parameters:
  Compress: Node with the compression bits
******************************************************************** -->
  <xsl:variable name="locCompress" select="floor($Compress)"/>
  <xsl:variable name="flagCompressed">64</xsl:variable>
  <xsl:variable name="flagCompressed2">524288</xsl:variable>
  <xsl:variable name="isCompressed" select="($locCompress mod ($flagCompressed * 2))>=$flagCompressed"/>
  <xsl:variable name="isTableCompressed" select="($Compress2 mod ($flagCompressed2 * 2))>=$flagCompressed2"/>
  <xsl:variable name="flagOLTPCompressed">65536</xsl:variable>
  <xsl:variable name="isOLTPCompressed" select="($Compress mod ($flagOLTPCompressed * 2))>=$flagOLTPCompressed"/>
  <xsl:variable name="flagArch1">131072</xsl:variable>
  <xsl:variable name="compressLevel" select="floor(($locCompress mod ($flagArch1 * 8)) div $flagArch1)"/>
  <xsl:variable name="isArchCompressed" select="$compressLevel!=0"/>
  <xsl:variable name="rllBit">4194304</xsl:variable>
  <xsl:variable name="rllOn" select="($Compress mod ($rllBit * 2))>=$rllBit"/>
  <xsl:variable name="flag2IndexCompressed">65536</xsl:variable>
  <xsl:variable name="isIndexCompressed" select="($Compress2 mod ($flag2IndexCompressed * 2))>=$flag2IndexCompressed"/>
  <xsl:variable name="flag2IndexCompressedAdvLow">131072</xsl:variable>
  <xsl:variable name="isIndexCompressedAdvLow" select="($Compress2 mod ($flag2IndexCompressedAdvLow * 2))>=$flag2IndexCompressedAdvLow"/>
  <xsl:variable name="flag2IndexCompressedAdvHigh">262144</xsl:variable>
  <xsl:variable name="isIndexCompressedAdvHigh" select="($Compress2 mod ($flag2IndexCompressedAdvHigh * 2))>=$flag2IndexCompressedAdvHigh"/>
  <xsl:call-template name="DoCompressSyntax">
   <xsl:with-param name="isCompressed" select="$isCompressed"/>
   <xsl:with-param name="isTableCompressed" select="$isTableCompressed"/>
   <xsl:with-param name="isOLTPCompressed" select="$isOLTPCompressed"/>
   <xsl:with-param name="isArchCompressed" select="$isArchCompressed"/>
   <xsl:with-param name="compressLevel" select="$compressLevel"/>
   <xsl:with-param name="rowLevelLocking" select="$rllOn"/>
   <xsl:with-param name="isIndexCompressed" select="$isIndexCompressed"/>
   <xsl:with-param name="isIndexCompressedAdvLow" select="$isIndexCompressedAdvLow"/>
   <xsl:with-param name="isIndexCompressedAdvHigh" select="$isIndexCompressedAdvHigh"/>
  </xsl:call-template>
 </xsl:template>
 <xsl:template name="DoCompressSyntax">
  <xsl:param name="isCompressed" select="false()"/>
  <xsl:param name="isTableCompressed" select="false()"/>
  <xsl:param name="isOLTPCompressed" select="false()"/>
  <xsl:param name="isArchCompressed" select="false()"/>
  <xsl:param name="compressLevel">0</xsl:param>
  <xsl:param name="flag">0</xsl:param>
  <xsl:param name="rowLevelLocking">0</xsl:param>
  <xsl:param name="isIndexCompressed" select="false()"/>
  <xsl:param name="isIndexCompressedAdvLow" select="false()"/>
  <xsl:param name="isIndexCompressedAdvHigh" select="false()"/>
  <!-- *******************************************************************
Template: DoCompressSyntax - common template to emit [NO]COMPRESS 
Parameters:
  isCompressed
  isOLTPCompressed
  isArchCompressed - archive compressed
  compressLevel - archive compression level
  flag - flag field of ku$_ilm_policy_t
  rowLevelLocking - 1 = ROW_LEVEL_LOCKING (for archive compression)
Implicit input:
  VERSION
Notes (copied from kustorag.xsl):
  Archive level compression is new in 11.2 and has a unique block format
  which is not supported in earlier versions.  Consequently, if VERSION
  is earlier than 11.2, we must specify NOCOMPRESS.
  On the other hand, the block formats for OLTP compression (new in 11.1)
  and DIRECT_LOAD are the same, so if VERSION < 11.1 we can specify COMPRESS.
  (Update: in 11.2 COMPRESS FOR ALL OPERATIONS is renamed COMPRESS FOR OLTP;
   COMPRESS FOR DIRECT_LOAD_OPERATIONS is renamed COMPRESS FOR BASIC.)
  ROW_LEVEL_LOCKING syntax is new in 12c; suppress for lower versions.
  Syntax change in 12.1:
    a. "COMPRESS FOR OLTP" has been renamed to "ROW STORE COMPRESS ADVANCED"
    b. "COMPRESS FOR [QUERY|ARCHIVE] [HIGH|LOW]" has been renamed to "COLUMN
       STORE COMPRESS FOR [QUERY|ARCHIVE] [HIGH|LOW]" 
******************************************************************** -->
  <!-- When segment_attributes are disabled then we should not emit the COMPRESS clause -->
  <xsl:if test="$SEGMENT_ATTRIBUTES=1">
   <xsl:choose>
    <xsl:when test=" $isCompressed and $isArchCompressed">
     <xsl:choose>
      <xsl:when test="$VERSION>=1102000000">
       <xsl:choose>
        <xsl:when test="$compressLevel=1 or $compressLevel=2">
         <xsl:element name="COMPRESS">QUERY</xsl:element>
        </xsl:when>
        <xsl:when test="$compressLevel=3 or $compressLevel=4">
         <xsl:element name="COMPRESS">ARCHIVE</xsl:element>
        </xsl:when>
        <xsl:otherwise>
         <xsl:element name="COMPRESS">
          <xsl:text>**INVALID COMPRESSION VALUE (</xsl:text>
          <xsl:value-of select="$compressLevel"/>
          <xsl:text>)** </xsl:text>
         </xsl:element>
        </xsl:otherwise>
       </xsl:choose>
       <xsl:if test="$compressLevel=1 or $compressLevel=3">
        <xsl:element name="COMPRESS_LEVEL">LOW</xsl:element>
       </xsl:if>
       <xsl:if test="$VERSION>=1200000000">
        <xsl:if test="$rowLevelLocking=1">
         <xsl:element name="ROW_LEVEL_LOCKING"/>
        </xsl:if>
       </xsl:if>
      </xsl:when>
      <xsl:otherwise>
       <xsl:element name="COMPRESS">N</xsl:element>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:when>
    <xsl:when test="$isCompressed and $isOLTPCompressed">
     <xsl:choose>
      <xsl:when test="$VERSION>=1200000000">
       <xsl:choose>
        <xsl:when test="$flag=4">
         <xsl:element name="COMPRESS">ROW STORE COMPRESS ADVANCED INPLACE</xsl:element>
        </xsl:when>
        <xsl:otherwise>
         <xsl:element name="COMPRESS">ROW STORE COMPRESS ADVANCED</xsl:element>
        </xsl:otherwise>
       </xsl:choose>
      </xsl:when>
      <xsl:when test="$VERSION>=1102000000">
       <xsl:element name="COMPRESS">OLTP</xsl:element>
      </xsl:when>
      <xsl:when test="$VERSION>=1100000000">
       <xsl:element name="COMPRESS">ALL</xsl:element>
      </xsl:when>
      <xsl:otherwise>
       <xsl:element name="COMPRESS">DIRECT_LOAD</xsl:element>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:when>
    <xsl:when test="$VERSION>=1202000000 and ($isTableCompressed or $isIndexCompressed)">
     <xsl:if test="$isTableCompressed">
      <xsl:element name="TABLE_COMPRESS">
       <xsl:choose>
        <xsl:when test="$isOLTPCompressed">
         <xsl:text>OLTP</xsl:text>
        </xsl:when>
        <xsl:when test="$isArchCompressed">
         <xsl:choose>
          <xsl:when test="$compressLevel=1">QUERY_LOW</xsl:when>
          <xsl:when test="$compressLevel=2">QUERY_HIGH</xsl:when>
          <xsl:when test="$compressLevel=3">ARCHIVE_LOW</xsl:when>
          <xsl:when test="$compressLevel=4">ARCHIVE_HIGH</xsl:when>
         </xsl:choose>
        </xsl:when>
       </xsl:choose>
      </xsl:element>
     </xsl:if>
     <xsl:if test="$isIndexCompressed">
      <xsl:element name="INDEX_COMPRESS">
       <xsl:if test="$isIndexCompressedAdvHigh">
        <xsl:text> ADVANCED HIGH</xsl:text>
       </xsl:if>
       <xsl:if test="$isIndexCompressedAdvLow">
        <xsl:text> ADVANCED LOW</xsl:text>
       </xsl:if>
      </xsl:element>
     </xsl:if>
    </xsl:when>
    <xsl:when test="$isCompressed">
     <xsl:choose>
      <xsl:when test="$VERSION>=1102000000">
       <xsl:element name="COMPRESS">BASIC</xsl:element>
      </xsl:when>
      <xsl:otherwise>
       <xsl:element name="COMPRESS">DIRECT_LOAD</xsl:element>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
     <xsl:element name="COMPRESS">N</xsl:element>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoCellMemory">
  <xsl:param name="CellMemory">0</xsl:param>
  <xsl:variable name="flagNoCMemory">16777216</xsl:variable>
  <xsl:variable name="flagCMemory">33554432</xsl:variable>
  <xsl:variable name="flagCMCompressQuery">67108864</xsl:variable>
  <xsl:variable name="flagCMCompressCapacity">134217728</xsl:variable>
  <xsl:call-template name="DoCMemoryCompressSyntax">
   <xsl:with-param name="isNoCMemory" select="($CellMemory mod ($flagNoCMemory*2)>=$flagNoCMemory)"/>
   <xsl:with-param name="isCMemory" select="($CellMemory mod ($flagCMemory*2)>=$flagCMemory)"/>
   <xsl:with-param name="isCMCompressQuery" select="($CellMemory mod ($flagCMCompressQuery*2)>=$flagCMCompressQuery)"/>
   <xsl:with-param name="isCMCompressCapacity" select="($CellMemory mod ($flagCMCompressCapacity*2)>=$flagCMCompressCapacity)"/>
  </xsl:call-template>
 </xsl:template>
</xsl:stylesheet>

OHA YOOOO