<?xml version="1.0"?>
<!-- Copyright (c) 2000, 2009, Oracle and/or its affiliates.
All rights reserved. -->
<!-- 
NAME
    kutable.xsl
DESCRIPTION
    XSLT stylesheet for XML => DDL conversion of md$_{h/fh/pfh/io}table_t ADTs
NOTES
    Do NOT modify this file under any circumstance. Copy the file
    if you wish to use this stylesheet with an external XML/XSL parser

MODIFIED        MM/DD/YY
    abodge      11/11/08 - Update from RDBMS_MAIN_LINUX_081110
    lbarton     08/28/08 - bug 7334782: more xmltype virt cols
    lbarton     06/23/08 - bug 6523175: xmltype virtual columns
    lbarton     03/18/08 - deferred segment creation
    abodge      01/16/07 - Set SQLTERMINATOR and CONSTRAINTS_AS_ALTER for CM
    dgagne      11/14/07 - add network name transform
    lbarton     11/02/07 - bug 6060058: flashback archived tables
    lbarton     02/01/07 - IMPORT_CONVENTIONAL
    rapayne     04/01/07 - bug 5910237: ensure additional space after
                           RETURN AS VALUE/LOCATOR clause.
    lbarton     09/18/06 - bug 5212908: PARALLEL_HINT
    lbarton     07/17/06 - bug 5386908: XMLTYPE_STREAM_FORMAT param 
    dgagne      05/12/06 - remove transportable requirement to departition a 
                           table 
    weizhang    05/30/06 - proj 19400: enable TABLESPACE for GTT
    cchiappa    04/11/06 - ORGANIZATION CUBE tables 
    cmlim       11/29/05 - support dml error logging 
    lbarton     01/20/06 - partition transportable; split off kutabcon.xsl
                            and kuntab.xsl
    rapayne     01/27/06 - lrg 2035104:ROW MOVEMENT tied to FLAGS not TRIGFLAGS
    lbarton     01/20/06 - fix test for ext tbl 
    htseng      12/16/05 - add transform param PARTITIONING 
    lbarton     12/29/05 - REMAP_COLUMN_NAME
    sdavidso    11/02/05 - fix inconsistent stylesheet format 
    htseng      10/19/05 - fix bug 4120481:add MVIEW_LOG param to DoParallel 
    sdavidso    09/20/05 - fix compressed keys in partioned IOT 
    htseng      08/05/05 - bug 3560220: get correct behavior from processor
    lbarton     05/04/05 - bug 4347010: exclude unused columns
    htseng      02/10/05 - bug 3966743: enable row movement
    htseng      01/18/05 - fix bug 4128169 : setup correct filter for 
                           tablespace 
    lbarton     01/04/05 - bug 4017065: SUBSTITUTABLE on object table 
    rpfau       12/01/04 - Fix problem if system generated column name for 
                           object attr. Put out XMLschema info if needed for
                           attributes in object tables.
    rpfau       11/22/04 - Do not put out check_type calls for transportable 
                           classic. 
    rpfau       10/25/04 - More on bug 3599656 - remove just added owner_name 
                           and name from ku_subcoltype_t and do versioning. 
    rpfau       10/15/04 - bug 3599656 - call check_type before creating 
                           tables for transportable import.
    lbarton     08/17/04 - lrg1728547/bug 3047454: ADT attr of unused col 
    lbarton     08/05/04 - Bug 3813945: encryption password
    rpfau       06/22/04 - Pretty up alignment in template match "PLOBMD".
    htseng      07/12/04 - fix default value for substitutable clause 
    htseng      06/24/04 - bug 3678702: long raw column is not last one 
    lbarton     05/14/04 - Add TRANSPORTABLE_CLASSIC 
    htseng      04/27/04 - bug 3566300 - support subtitutable column
    lbarton     05/11/04 - Bug 3617842: SAMPLE and PCTSPACE 
    htseng      04/15/04 - enhance bug3470826 fix 
    rpfau       04/12/04 - Cleanup based on Lee's review. 
    htseng      03/22/04 - bug 3470826: duplicate column 
    rpfau       03/31/04 - Fix temporary table with name specified for 
                           oidindex - bug 3470762. 
    emagrath    02/10/04 - Transportable OID/SETID constraints/indexes
    lbarton     12/02/03 - Bug 3281574: dataobj# for nested IOTs 
    bmccarth    10/30/03 - get REF correct for XMLSchemas 
    lbarton     09/22/03 - Bug 3149477: SUBPARTITION_NAME param 
    lbarton     09/24/03 - lrg 1572904: define PRS_PATCHTABLEMETADATA 
    dgagne      09/08/03 - add convert parse item for PATCHTABLEMETADATA 
    htseng      08/14/03 - fix bug 3080271 add alter table modify clause 
    lbarton     08/14/03 - Bug 3047175: TTS and unused cols 
    lbarton     07/10/03 - Bug 3045654: nested table tablespace if vsn >= 10
    emagrath    06/06/03 - Correct index info for constraints
    emagrath    05/20/03 - Revamp constraint processing
    lbarton     03/20/03 - Bug 2844132: omit oidindex on temp table
    htseng      02/20/03 - fix CON1_LIST to pass correct $Property value
    lbarton     01/30/03 - primary key for nested IOT
    lbarton     12/31/02 - add plobmd to pcolumn_t for transportable
    htseng      11/01/02 - temp disable nested tablespace
    lbarton     10/11/02 - new parse item: SYSTEM_GENERATED
    htseng      10/28/02 - add tablespace for nested table
    lbarton     08/02/02 - transportable export
    lbarton     07/22/02 - Network export
    htseng      07/29/02 - add more parse params
    lbarton     06/03/02 - data layer and network support
    emagrath    05/17/02 - Stabilize constraint generation order
    lbarton     04/01/02 - xdb fix
    emagrath    01/31/02 - Complete support for REF constraints
    dgagne      11/05/01 - remove row movement from partitions
    lbarton     10/25/01 - xdb support
    lbarton     10/05/01 - Support Ordered Collections in Tables
    dgagne      10/15/01 - add heap segment compression support
    dgagne      06/27/01 - add external table clause
    lbarton     06/01/01 - remove oradb-style imports
    lbarton     04/17/01 - do it again and do it right
    lbarton     04/16/01 - bugfix
    lbarton     01/12/01 - add comments
    lbarton     01/10/01 - nested table referential constraints
    lbarton     12/20/00 - NOT NULL for adt/ref col
    lbarton     12/01/00 - XMLType support
    lbarton     11/01/00 - align table constraints
    lbarton     10/24/00 - sort in views, not xsl
    gclaborn    10/30/00 - Add external imports; change name
    lbarton     10/05/00 - more bugfixes
    lbarton     09/21/00 - bugfixes
    lbarton     08/18/00 - logical standby support
    lbarton     07/24/00 - use uriref in import
    lbarton     06/23/00 - Multinested collections
    lbarton     06/12/00 - constraints in CREATE TABLE
    lbarton     06/01/00 - support parsing
    lbarton     05/15/00 - Params for new API
    lbarton     03/29/00 - More partitioning support
    lbarton     03/17/00 - Multinested collections
 -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <!-- Import required scripts -->
 <xsl:import href="kucommon.xsl"/>
 <xsl:import href="kucolumn.xsl"/>
 <xsl:import href="kustorag.xsl"/>
 <xsl:import href="kuprtobj.xsl"/>
 <xsl:import href="kuconstr.xsl"/>
 <xsl:import href="kuobjtbl.xsl"/>
 <xsl:import href="kuiot.xsl"/>
 <xsl:import href="kucot.xsl"/>
 <xsl:import href="kulob.xsl"/>
 <xsl:import href="kuidxwrk.xsl"/>
 <xsl:import href="kuexttbl.xsl"/>
 <xsl:import href="kutabcon.xsl"/>
 <xsl:import href="kuntab.xsl"/>
 <!-- Top-level parameters -->
 <xsl:param name="PRETTY">1</xsl:param>
 <xsl:param name="SQLTERMINATOR">0</xsl:param>
 <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="CONSTRAINTS">1</xsl:param>
 <xsl:param name="REF_CONSTRAINTS">1</xsl:param>
 <xsl:param name="CONSTRAINTS_AS_ALTER">0</xsl:param>
 <xsl:param name="OID">0</xsl:param>
 <xsl:param name="SIZE_BYTE_KEYWORD">0</xsl:param>
 <xsl:param name="EXPORT">0</xsl:param>
 <xsl:param name="TRANSPORTABLE">0</xsl:param>
 <xsl:param name="TRANSPORTABLE_CLASSIC">0</xsl:param>
 <xsl:param name="VERSION">9999999999</xsl:param>
 <xsl:param name="PCTSPACE">100</xsl:param>
 <!-- params for Logical Standby -->
 <xsl:param name="INSERT">0</xsl:param>
 <xsl:param name="DBLINK">0</xsl:param>
 <!-- params for load/unload and network -->
 <xsl:param name="OPERATION_TYPE">CREATE</xsl:param>
 <xsl:param name="EXT_TABLE_NAME" select="''"/>
 <xsl:param name="EXT_TABLE_SCHEMA" select="''"/>
 <xsl:param name="EXT_TABLE_CLAUSE" select="''"/>
 <xsl:param name="SCN">0</xsl:param>
 <xsl:param name="PARTITION_NAME" select="''"/>
 <xsl:param name="SUBPARTITION_NAME" select="''"/>
 <xsl:param name="NETWORK_LINK" select="''"/>
 <xsl:param name="NETWORK_SCHEMA" select="''"/>
 <xsl:param name="NETWORK_NAME" select="''"/>
 <xsl:param name="QUERY" select="''"/>
 <xsl:param name="DROP">0</xsl:param>
 <xsl:param name="SAMPLE" select="''"/>
 <xsl:param name="ENCRYPTION_PASSWORD" select="''"/>
 <xsl:param name="PARTITIONING">1</xsl:param>
 <xsl:param name="DML_ERROR_LOGGING_CLAUSE" select="''"/>
 <xsl:param name="USE_DML_APPEND_HINT">1</xsl:param>
 <xsl:param name="XMLTYPE_STREAM_FORMAT" select="''"/>
 <xsl:param name="PARALLEL_HINT" select="''"/>
 <!-- params for parse -->
 <xsl:param name="PRS_DDL">0</xsl:param>
 <xsl:param name="PRS_DELIM">\{]`</xsl:param>
 <xsl:param name="PRS_VERB">0</xsl:param>
 <xsl:param name="PRS_OBJECT_TYPE">0</xsl:param>
 <xsl:param name="PRS_SCHEMA">0</xsl:param>
 <xsl:param name="PRS_NAME">0</xsl:param>
 <xsl:param name="PRS_TABLESPACE">0</xsl:param>
 <xsl:param name="PRS_GRANTEE">0</xsl:param>
 <xsl:param name="PRS_GRANTOR">0</xsl:param>
 <xsl:param name="PRS_BASE_OBJECT_SCHEMA">0</xsl:param>
 <xsl:param name="PRS_BASE_OBJECT_NAME">0</xsl:param>
 <xsl:param name="PRS_BASE_OBJECT_TYPE">0</xsl:param>
 <xsl:param name="PRS_SYSTEM_GENERATED">0</xsl:param>
 <xsl:param name="PRS_PATCHTABLEMETADATA">0</xsl:param>
 <xsl:param name="PRS_LONG_POSITION">0</xsl:param>
 <!-- Params for column name remapping -->
 <xsl:param name="REMAP_COLUMN_NAMEO1" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEN1" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEO2" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEN2" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEO3" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEN3" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEO4" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEN4" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEO5" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEN5" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEO6" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEN6" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEO7" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEN7" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEO8" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEN8" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEO9" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEN9" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEO10" select="''"/>
 <xsl:param name="REMAP_COLUMN_NAMEN10" select="''"/>
 <!-- Templates -->
 <xsl:template match="TABLE_T">
  <!-- *******************************************************************
Template: TABLE_T - top-level template for tables.
  Depending on OPERATION_TYPE this template calls
   CreateDBTable (in this module) for CREATE
   LoadTableFromNetwork (in kuexttbl.xsl) for NETWORK
   CreExtTable (in kuexttbl.xsl) for EXPORT or IMPORT
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="$OPERATION_TYPE='CREATE'">
    <xsl:call-template name="CreateDBTable"/>
   </xsl:when>
   <xsl:when test="$OPERATION_TYPE='NETWORK'">
    <xsl:call-template name="LoadTableFromNetwork">
     <xsl:with-param name="DBlinkName" select="$NETWORK_LINK"/>
     <xsl:with-param name="RemoteSchema" select="$NETWORK_SCHEMA"/>
     <xsl:with-param name="RemoteName" select="$NETWORK_NAME"/>
    </xsl:call-template>
   </xsl:when>
   <xsl:when test="$OPERATION_TYPE='IMPORT' or
                   $OPERATION_TYPE='IMPORT_CONVENTIONAL'">
    <xsl:call-template name="CreateExtTable"/>
   </xsl:when>
   <xsl:when test="$OPERATION_TYPE='EXPORT'">
    <xsl:call-template name="CreateExtTable">
     <xsl:with-param name="DBlinkName" select="$NETWORK_LINK"/>
    </xsl:call-template>
   </xsl:when>
   <xsl:otherwise>
    <xsl:text>***ERROR: UNEXPECTED OPERATION_TYPE: </xsl:text>
    <xsl:value-of select="$OPERATION_TYPE"/>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="CreateDBTable">
  <!-- *******************************************************************
Template: CreateDBTable
******************************************************************** -->
  <!-- Add check_type calls for object types used directly by the table.
      Do this first, so the parse parameters defined right after this are
      create table parse items, not check_type parse items.
   -->
  <xsl:call-template name="CheckTypes"/>
  <!--
    Generate parse items for CREATE TABLE
   -->
  <xsl:if test="$TRANSPORTABLE=1 and $PRS_PATCHTABLEMETADATA=1">
   <xsl:value-of select="$PRS_DELIM"/>
   <xsl:text>APATCHTABLEMETADATA</xsl:text>
   <xsl:value-of select="$PRS_DELIM"/>
   <xsl:text>B</xsl:text>
   <xsl:choose>
    <xsl:when test="COL_LIST/COL_LIST_ITEM[TYPE_NUM=112]">
     <xsl:text>Y</xsl:text>
    </xsl:when>
    <xsl:when test="COL_LIST/COL_LIST_ITEM[TYPE_NUM=8]
               and COL_LIST/COL_LIST_ITEM[last()]/TYPE_NUM!=8">
     <xsl:text>Y</xsl:text>
    </xsl:when>
    <xsl:when test="COL_LIST/COL_LIST_ITEM[TYPE_NUM=24]
               and COL_LIST/COL_LIST_ITEM[last()]/TYPE_NUM!=24">
     <xsl:text>Y</xsl:text>
    </xsl:when>
    <xsl:otherwise>
     <xsl:text>N</xsl:text>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:if>
  <xsl:if test="$PRS_TABLESPACE=1">
   <xsl:value-of select="$PRS_DELIM"/>
   <xsl:text>ATABLESPACE</xsl:text>
   <xsl:value-of select="$PRS_DELIM"/>
   <xsl:text>B</xsl:text>
   <xsl:choose>
    <xsl:when test="(PART_OBJ)">
     <xsl:value-of select="PART_OBJ/PARTOBJ/DEFTS_NAME"/>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="TS_NAME"/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:if>
  <xsl:call-template name="DoParse">
   <xsl:with-param name="Verb">CREATE</xsl:with-param>
   <xsl:with-param name="ObjectType">TABLE</xsl:with-param>
   <xsl:with-param name="SchemaNode" select="SCHEMA_OBJ/OWNER_NAME"/>
   <xsl:with-param name="NameNode" select="SCHEMA_OBJ/NAME"/>
  </xsl:call-template>
  <!-- 
      CREATE [ GLOBAL TEMPORARY ] TABLE foo.bar
  -->
  <xsl:text>CREATE </xsl:text>
  <xsl:if test="(PROPERTY mod 8388608)>=4194304">
   <xsl:text>GLOBAL TEMPORARY </xsl:text>
  </xsl:if>
  <xsl:text>TABLE </xsl:text>
  <xsl:apply-templates select="SCHEMA_OBJ"/>
  <!--
     Dispatch to processing template for relational/object table
-->
  <xsl:choose>
   <xsl:when test="(PROPERTY mod 2)=0">
    <!-- relational table -->
    <xsl:call-template name="CreRelTable"/>
   </xsl:when>
   <xsl:otherwise>
    <!-- object table or xmltype table -->
    <xsl:call-template name="CreObjTable"/>
   </xsl:otherwise>
  </xsl:choose>
  <xsl:if test="$SQLTERMINATOR=1">
   <!-- Terminate the SQL statement -->
   <xsl:text>;</xsl:text>
  </xsl:if>
  <!--
       For transportable, generate ALTER TABLE SET UNUSED for unused cols
      (prop bit 0x8000) that are not ADT attributes (prop bit 0x01) 
-->
  <xsl:if test="$TRANSPORTABLE=1">
   <xsl:for-each select="COL_LIST/COL_LIST_ITEM[(PROPERTY mod 65536)>=32768
                                           and (PROPERTY mod 2)&lt;1]">
    <xsl:call-template name="DoParse">
     <xsl:with-param name="Verb">ALTER</xsl:with-param>
     <xsl:with-param name="ObjectType">TABLE</xsl:with-param>
     <xsl:with-param name="SchemaNode" select="../../SCHEMA_OBJ/OWNER_NAME"/>
     <xsl:with-param name="NameNode" select="../../SCHEMA_OBJ/NAME"/>
    </xsl:call-template>
    <xsl:text>
  ALTER TABLE </xsl:text>
    <xsl:apply-templates select="../../SCHEMA_OBJ"/>
    <xsl:text>SET UNUSED ("</xsl:text>
    <xsl:value-of select="NAME"/>
    <xsl:text>")</xsl:text>
    <xsl:if test="$SQLTERMINATOR=1">
     <xsl:text>;</xsl:text>
     <!-- Terminate the SQL statement -->
    </xsl:if>
   </xsl:for-each>
  </xsl:if>
  <!-- Add any top level table constraints needed as ALTER TABLE statements -->
  <xsl:call-template name="GenTableConstraints">
   <xsl:with-param name="SchemaObjParent" select="current()"/>
   <xsl:with-param name="ListParent" select="current()"/>
   <xsl:with-param name="InColList">0</xsl:with-param>
   <xsl:with-param name="CommaNeeded">0</xsl:with-param>
   <xsl:with-param name="Property" select="PROPERTY"/>
   <xsl:with-param name="Nested">0</xsl:with-param>
  </xsl:call-template>
  <!-- For transportable, ENABLE Hidden (OID or SETID) constraints -->
  <!-- (implicit part of CREATE TABLE for modes other than transportable) -->
  <!-- Not needed for original exp/imp (which has its own way of doing this) -->
  <xsl:if test="$TRANSPORTABLE=1 and $TRANSPORTABLE_CLASSIC=0">
   <xsl:for-each select="CON1_LIST/CON1_LIST_ITEM[OID_OR_SETID!=0]">
    <xsl:if test="$PRETTY=1">
     <xsl:text>&#xa;  </xsl:text>
    </xsl:if>
    <xsl:call-template name="DoHiddenConstraint">
     <xsl:with-param name="SchemaObjParent" select="../.."/>
     <xsl:with-param name="ConstraintNode" select="current()"/>
    </xsl:call-template>
   </xsl:for-each>
  </xsl:if>
  <!-- Add any nested table constraints needed as ALTER TABLE statements -->
  <xsl:if test="(PROPERTY mod 8)>=4">
   <!-- has nested-TABLE columns -->
   <xsl:call-template name="GenNestedTableConstraints">
    <xsl:with-param name="ListParent" select="NT/NTS"/>
   </xsl:call-template>
  </xsl:if>
  <!-- ALTER TABLE modify statement to get object default value -->
  <xsl:call-template name="GenObjDefValue">
   <xsl:with-param name="SchemaObjParent" select="current()"/>
   <xsl:with-param name="Property" select="PROPERTY"/>
  </xsl:call-template>
  <!-- Generate INSERT SELECT for logical standby -->
  <xsl:if test="$INSERT=1">
   <xsl:if test="$PRETTY=1">
    <xsl:text>&#xa;  </xsl:text>
   </xsl:if>
   <xsl:call-template name="LoadTableFromNetwork">
    <xsl:with-param name="DBlinkName" select="$DBLINK"/>
   </xsl:call-template>
  </xsl:if>
 </xsl:template>
 <xsl:template name="CreRelTable">
  <!-- *******************************************************************
Template: CreRelTable - syntax for relational tables
******************************************************************** -->
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa; </xsl:text>
  </xsl:if>
  <!-- Begin any CREATE TABLE properties with open paren -->
  <xsl:call-template name="TablePropertyParen">
   <xsl:with-param name="OpenParen">1</xsl:with-param>
   <xsl:with-param name="SchemaObjParent" select="current()"/>
   <xsl:with-param name="ListParent" select="current()"/>
   <xsl:with-param name="Property" select="PROPERTY"/>
   <xsl:with-param name="Nested">0</xsl:with-param>
  </xsl:call-template>
  <!-- column list -->
  <xsl:apply-templates select="COL_LIST">
   <xsl:with-param name="ADT_type">TABLE</xsl:with-param>
  </xsl:apply-templates>
  <!-- Add any table constraints needed in CREATE TABLE properties -->
  <!--  (Need initial comma for relational tables) -->
  <xsl:call-template name="GenTableConstraints">
   <xsl:with-param name="SchemaObjParent" select="current()"/>
   <xsl:with-param name="ListParent" select="current()"/>
   <xsl:with-param name="InColList">1</xsl:with-param>
   <xsl:with-param name="CommaNeeded">1</xsl:with-param>
   <xsl:with-param name="Property" select="PROPERTY"/>
   <xsl:with-param name="Nested">0</xsl:with-param>
  </xsl:call-template>
  <!-- End any CREATE TABLE properties with close paren -->
  <xsl:call-template name="TablePropertyParen">
   <xsl:with-param name="OpenParen">0</xsl:with-param>
   <xsl:with-param name="SchemaObjParent" select="current()"/>
   <xsl:with-param name="ListParent" select="current()"/>
   <xsl:with-param name="Property" select="PROPERTY"/>
   <xsl:with-param name="Nested">0</xsl:with-param>
  </xsl:call-template>
  <!-- if temp table emit ON COMMIT... -->
  <xsl:call-template name="GenOnCommitAction"/>
  <xsl:if test="(PROPERTY mod 262144)>=131072">
   <!-- AQ -->
   <xsl:text>USAGE QUEUE </xsl:text>
  </xsl:if>
  <xsl:if test="(PROPERTY mod 128)>=64">
   <!-- IOT -->
   <xsl:call-template name="OrgIndex"/>
  </xsl:if>
  <!-- object_type_col_properties in relational table -->
  <xsl:for-each select="COL_LIST/COL_LIST_ITEM[TYPE_NUM=121]">
   <xsl:choose>
    <!-- bug 4347010: skip all of this if column is unused -->
    <xsl:when test="(PROPERTY mod 65536)>=32768"/>
    <!--  0x800 - SUBSTITUTABLE specified explicitly -->
    <xsl:when test="(TYPEMD/FLAGS mod 4096)>= 2048">
     <xsl:text>COLUMN </xsl:text>
     <xsl:value-of select="NAME"/>
     <xsl:text> SUBSTITUTABLE AT ALL LEVELS </xsl:text>
     <xsl:if test="$PRETTY=1">
      <xsl:text>&#xa;  </xsl:text>
     </xsl:if>
    </xsl:when>
    <!--  0x400 - NOT SUBSTITUTABLE specified explicitly -->
    <xsl:when test="(TYPEMD/FLAGS mod 2048)>=1024">
     <xsl:text>COLUMN </xsl:text>
     <xsl:value-of select="NAME"/>
     <xsl:text> NOT SUBSTITUTABLE AT ALL LEVELS </xsl:text>
     <xsl:if test="$PRETTY=1">
      <xsl:text>&#xa;  </xsl:text>
     </xsl:if>
    </xsl:when>
    <xsl:when test="(TYPEMD/SUBTYPE_LIST/SUBTYPE_LIST_ITEM/FLAGS mod 4) =3">
     <xsl:text>COLUMN </xsl:text>
     <xsl:value-of select="NAME"/>
     <xsl:text> IS OF TYPE (ONLY </xsl:text>
     <xsl:apply-templates select="TYPEMD/SUBTYPE_LIST/SUBTYPE_LIST_ITEM/SCHEMA_OBJ"/>
     <xsl:text>) </xsl:text>
     <xsl:if test="$PRETTY=1">
      <xsl:text>&#xa;  </xsl:text>
     </xsl:if>
    </xsl:when>
   </xsl:choose>
  </xsl:for-each>
  <xsl:call-template name="XMLSchemaBasedCols"/>
  <xsl:choose>
   <xsl:when test="PROPERTY>=2147483648">
    <!-- External table -->
    <xsl:call-template name="GenExtTableClauses"/>
   </xsl:when>
   <xsl:when test="(PROPERTY2 mod 2)=1">
    <!-- CUBE table -->
    <xsl:call-template name="GenCubeTableClauses">
      <xsl:with-param name="CubeTab" select="CUBETAB"/>
      <xsl:with-param name="PrettyCR">1</xsl:with-param>
    </xsl:call-template>
   </xsl:when>
   <xsl:when test="(PROPERTY mod 2048)>=1024">
    <!-- clustered table -->
    <xsl:apply-templates select="TABCLUSTER"/>
    <xsl:if test="$TRANSPORTABLE=1">
     <xsl:text> STORAGE (TABNO </xsl:text>
     <xsl:value-of select="TAB_NUM"/>
     <xsl:text>)</xsl:text>
    </xsl:if>
   </xsl:when>
   <xsl:when test="4194304>(PROPERTY mod 8388608)">
    <!-- non-temporary table: generate the physical attributes -->
    <xsl:call-template name="GenTablePhysicalAttrs">
     <xsl:with-param name="Pctspace" select="$PCTSPACE"/>
    </xsl:call-template>
   </xsl:when>
   <xsl:when test="(PROPERTY mod 8388608)>=4194304">
    <!-- global temporary table: generate the tablespace clause -->   
    <xsl:if test="$TABLESPACE=1">
     <!-- only handle GTT with explicitly specified tablespace -->
     <xsl:if test="(current()/TS_NAME)!='SYSTEM'">
      <xsl:apply-templates select="current()/TS_NAME"/>
     </xsl:if>
    </xsl:if>
   </xsl:when>
  </xsl:choose>
  <xsl:if test="(FLAGS mod 262144) >= 131072">
   <!-- row movement -->
   <xsl:text> ENABLE ROW MOVEMENT </xsl:text>
  </xsl:if>
  <!-- flashback archive (no data pump support yet) -->
  <xsl:if test="$EXPORT=0">
   <xsl:apply-templates select="FBA"/>
  </xsl:if>
 </xsl:template>
 <xsl:template name="CreObjTable">
  <!-- *******************************************************************
Template: CreObjTable - syntax for object tables and XMLTYPE tables
******************************************************************** -->
  <!-- OF TYPE foo.bar -->
  <xsl:call-template name="ObjTable"/>
  <!-- Begin any CREATE TABLE properties with open paren -->
  <xsl:call-template name="TablePropertyParen">
   <xsl:with-param name="OpenParen">1</xsl:with-param>
   <xsl:with-param name="SchemaObjParent" select="current()"/>
   <xsl:with-param name="ListParent" select="current()"/>
   <xsl:with-param name="Property" select="PROPERTY"/>
   <xsl:with-param name="Nested">0</xsl:with-param>
  </xsl:call-template>
  <!-- Add any table constraints needed in CREATE TABLE properties -->
  <!--  (No initial comma for object tables) -->
  <xsl:call-template name="GenTableConstraints">
   <xsl:with-param name="SchemaObjParent" select="current()"/>
   <xsl:with-param name="ListParent" select="current()"/>
   <xsl:with-param name="InColList">1</xsl:with-param>
   <xsl:with-param name="CommaNeeded">0</xsl:with-param>
   <xsl:with-param name="Property" select="PROPERTY"/>
   <xsl:with-param name="Nested">0</xsl:with-param>
  </xsl:call-template>
  <!-- End any CREATE TABLE properties with close paren -->
  <xsl:call-template name="TablePropertyParen">
   <xsl:with-param name="OpenParen">0</xsl:with-param>
   <xsl:with-param name="SchemaObjParent" select="current()"/>
   <xsl:with-param name="ListParent" select="current()"/>
   <xsl:with-param name="Property" select="PROPERTY"/>
   <xsl:with-param name="Nested">0</xsl:with-param>
  </xsl:call-template>
  <!-- if temp table emit ON COMMIT... -->
  <xsl:call-template name="GenOnCommitAction"/>
  <!-- If this is an XMLSchema object table output that -->
  <!-- info now to make the parser happy -->
  <xsl:if test="COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']/OPQMD/SCHEMA_ELMT">
   <xsl:if test="$PRETTY=1">
    <xsl:text>&#xa; </xsl:text>
   </xsl:if>
   <!-- Simplify logic in templates by emitting XMLTYPE here, but only if
        there is a LOBMD entry indicating that there is a STORE AS CLOB
        clause. -->
   <xsl:if test="COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']/LOBMD">
    <xsl:text> XMLTYPE</xsl:text>
   </xsl:if>
   <xsl:apply-templates select="COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']/OPQMD/SCHEMA_ELMT"/>
  </xsl:if>
  <xsl:if test="(PROPERTY mod 8192)>=4096">
   <!-- has primary-key OID -->
   <xsl:text>OBJECT IDENTIFIER IS PRIMARY KEY </xsl:text>
   <xsl:if test="$PRETTY=1">
    <xsl:text>&#xa;   </xsl:text>
   </xsl:if>
  </xsl:if>
  <!-- OIDINDEX  -->
  <xsl:call-template name="DoOidindex"/>
  <xsl:if test="(PROPERTY mod 262144)>=131072">
   <!-- AQ -->
   <xsl:text>USAGE QUEUE </xsl:text>
  </xsl:if>
  <xsl:if test="(PROPERTY mod 128)>=64">
   <!-- IOT -->
   <xsl:call-template name="OrgIndex"/>
  </xsl:if>
  <xsl:call-template name="XMLSchemaBasedCols"/>
  <xsl:if test="4194304>(PROPERTY mod 8388608)">
   <!-- non-temporary table: generate the physical attributes -->
   <xsl:call-template name="GenTablePhysicalAttrs">
    <xsl:with-param name="Pctspace" select="$PCTSPACE"/>
   </xsl:call-template>
  </xsl:if>
  <xsl:if test="(PROPERTY mod 8388608)>=4194304">
   <!-- global temporary table: generate the tablespace clause -->   
   <xsl:if test="$TABLESPACE=1">
    <!-- only handle GTT with explicitly specified tablespace -->
    <xsl:if test="(current()/TS_NAME)!='SYSTEM'">
     <xsl:apply-templates select="current()/TS_NAME"/>
    </xsl:if>
   </xsl:if>
  </xsl:if>
  <xsl:if test="(TRIGFLAG mod 4194304) >= 2097152">
   <!-- row movement -->
   <xsl:text> ENABLE ROW MOVEMENT </xsl:text>
  </xsl:if>
 </xsl:template>
 <xsl:template name="OrgIndex">
  <!-- *******************************************************************
Template: OrgIndex - ORGANIZATION INDEX ( COMPRESS n | NOCOMPRESS )
******************************************************************** -->
  <xsl:text>ORGANIZATION INDEX </xsl:text>
  <!-- 
      If departitionin don't generate COMPRESS
      value will come from partition
-->
  <xsl:if test="string-length($PARTITION_NAME)=0 and
                string-length($SUBPARTITION_NAME)=0">
   <xsl:choose>
    <xsl:when test="NUMKEYCOLS>0">
     <xsl:text>COMPRESS </xsl:text>
     <xsl:value-of select="NUMKEYCOLS"/>
     <xsl:text> </xsl:text>
    </xsl:when>
    <xsl:otherwise>NOCOMPRESS </xsl:otherwise>
   </xsl:choose>
  </xsl:if>
 </xsl:template>
 <xsl:template name="XMLSchemaBasedCols">
  <!-- *******************************************************************
Template: XMLSchemaBasedCols
******************************************************************** -->
  <!-- XML schema-based columns in relational tables and XML schema-based
      attributes in object tables. But don't put anything out for table
      level for an object table (already done above). Table level for an
      object table is indicated by NAME='SYS_NC_ROWINFO$'.  -->
  <!-- bug 4347010: skip unused columns (PROPERTY bit 0x8000 32768) -->
  <xsl:for-each select="COL_LIST/COL_LIST_ITEM[NAME!='SYS_NC_ROWINFO$' and
                       (32768 > (PROPERTY mod 65536)) and
                       TYPE_NUM=58 and
                       TYPEMD/SCHEMA_OBJ/OWNER_NAME='SYS' and
                       TYPEMD/SCHEMA_OBJ/NAME='XMLTYPE' and
                       OPQMD/SCHEMA_ELMT]">
   <!-- Add optional "COLUMN" -->
   <xsl:text>XMLTYPE COLUMN </xsl:text>
   <!-- Fix problem if system generated column name for an object
       attribute. Use attribute name instead of system generated name. -->
   <xsl:call-template name="ColNameOrAttr">
    <xsl:with-param name="ColItem" select="current()"/>
   </xsl:call-template>
   <xsl:apply-templates select="OPQMD/SCHEMA_ELMT"/>
   <xsl:if test="$PRETTY=1">
    <xsl:text>&#xa;  </xsl:text>
   </xsl:if>
  </xsl:for-each>
 </xsl:template>
 <xsl:template name="GenExtTableClauses">
  <!-- *******************************************************************
Template: GenExtTableClauses - generate clauses for external table   
******************************************************************** -->
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa;   </xsl:text>
  </xsl:if>
  <xsl:text>ORGANIZATION EXTERNAL </xsl:text>
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa;    </xsl:text>
  </xsl:if>
  <xsl:text>( TYPE </xsl:text>
  <xsl:value-of select="EXTTAB/TYPE"/>
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa;     </xsl:text>
  </xsl:if>
  <xsl:text> DEFAULT DIRECTORY "</xsl:text>
  <xsl:value-of select="EXTTAB/DEFAULT_DIR"/>
  <xsl:text>"</xsl:text>
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa;     </xsl:text>
  </xsl:if>
  <xsl:if test="EXTTAB/PARAM_CLOB">
   <xsl:text> ACCESS PARAMETERS</xsl:text>
   <xsl:if test="$PRETTY=1">
    <xsl:text>&#xa;     </xsl:text>
   </xsl:if>
   <xsl:text> ( </xsl:text>
   <xsl:value-of select="EXTTAB/PARAM_CLOB"/>
   <xsl:text>    )</xsl:text>
  </xsl:if>
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa;     </xsl:text>
  </xsl:if>
  <xsl:text> LOCATION</xsl:text>
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa;      </xsl:text>
  </xsl:if>
  <xsl:text> ( </xsl:text>
  <xsl:for-each select="EXTTAB/LOCATION/LOCATION_ITEM">
   <xsl:if test="DIR">
    <xsl:text>"</xsl:text>
    <xsl:value-of select="DIR"/>
    <xsl:text>":</xsl:text>
   </xsl:if>
   <xsl:text>'</xsl:text>
   <xsl:value-of select="NAME"/>
   <xsl:text>'</xsl:text>
   <xsl:if test="not(position()=last())">
    <xsl:text>, </xsl:text>
    <xsl:if test="$PRETTY=1">
     <xsl:text>&#xa;         </xsl:text>
    </xsl:if>
   </xsl:if>
  </xsl:for-each>
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa;      </xsl:text>
  </xsl:if>
  <xsl:text> )</xsl:text>
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa;   </xsl:text>
  </xsl:if>
  <xsl:text> )</xsl:text>
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa;  </xsl:text>
  </xsl:if>
  <xsl:if test="EXTTAB/REJECT_LIMIT > 0">
   <xsl:text> REJECT LIMIT </xsl:text>
   <xsl:choose>
    <xsl:when test="EXTTAB/REJECT_LIMIT = 2147483647">
     <xsl:text>UNLIMITED</xsl:text>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="EXTTAB/REJECT_LIMIT"/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:if>
  <xsl:if test="DEGREE">
   <xsl:text> PARALLEL </xsl:text>
   <xsl:value-of select="DEGREE"/>
  </xsl:if>
 </xsl:template>
 <xsl:template name="GenObjDefValue">
  <xsl:param name="SchemaObjParent" select="''"/>
  <xsl:param name="Property">0</xsl:param>
  <!-- *******************************************************************
Template: GenObjDefValue - get object table column default value 
Parameters:
  SchemaObjParent - parent of SCHEMA_OBJ name
  Property - Table PROPERTY
******************************************************************** -->
  <xsl:if test="($Property mod 2)=1">
   <!-- object table -->
   <xsl:for-each select="COL_LIST/COL_LIST_ITEM">
    <xsl:if test="DEFLENGTH != 0  
		and (32 > (PROPERTY mod 64))   
		and (1024 > (PROPERTY mod 1024))">
     <xsl:call-template name="DoParse">
      <xsl:with-param name="Verb">ALTER</xsl:with-param>
      <xsl:with-param name="ObjectType">TABLE</xsl:with-param>
      <xsl:with-param name="SchemaNode" select="$SchemaObjParent/SCHEMA_OBJ/OWNER_NAME"/>
      <xsl:with-param name="NameNode" select="$SchemaObjParent/SCHEMA_OBJ/NAME"/>
     </xsl:call-template>
     <xsl:text>&#xa;  </xsl:text>
     <xsl:text>ALTER TABLE </xsl:text>
     <xsl:apply-templates select="$SchemaObjParent/SCHEMA_OBJ"/>
     <xsl:text>MODIFY ( </xsl:text>
     <xsl:value-of select="NAME"/>
     <xsl:text> DEFAULT </xsl:text>
     <xsl:value-of select="DEFAULT_VAL"/>
     <xsl:text>)</xsl:text>
     <xsl:if test="$SQLTERMINATOR=1">
      <xsl:text>;</xsl:text>
      <!-- Terminate the SQL statement -->
     </xsl:if>
    </xsl:if>
   </xsl:for-each>
  </xsl:if>
 </xsl:template>
 <xsl:template match="TABCLUSTER">
  <!-- *******************************************************************
Template: TABCLUSTER - for cluster tables
******************************************************************** -->
  <xsl:text>CLUSTER </xsl:text>
  <xsl:apply-templates select="SCHEMA_OBJ"/>
  <xsl:text>(</xsl:text>
  <xsl:apply-templates select="COL_LIST">
   <xsl:with-param name="ADT_type">INDEX</xsl:with-param>
   <xsl:with-param name="DoLF">0</xsl:with-param>
   <xsl:with-param name="DoHidden">1</xsl:with-param>
  </xsl:apply-templates>
  <xsl:text>)</xsl:text>
 </xsl:template>
 <xsl:template match="FBA">
  <!-- *******************************************************************
Template: FBA - for flashback archive enabled tables
******************************************************************** -->
  <xsl:text>FLASHBACK ARCHIVE "</xsl:text>
  <xsl:value-of select="FA_NAME"/>
  <xsl:text>"</xsl:text>
 </xsl:template>
 <xsl:template name="GenOnCommitAction">
  <!-- *******************************************************************
Template: GenOnCommitAction - generate ON COMMIT action for temp tables
******************************************************************** -->
  <xsl:if test="(PROPERTY mod 8388608)>=4194304">
   <!-- temporary table -->
   <xsl:choose>
    <xsl:when test="(PROPERTY mod 16777216)>=8388608">
     <xsl:text>ON COMMIT PRESERVE ROWS </xsl:text>
    </xsl:when>
    <xsl:otherwise>
     <xsl:text>ON COMMIT DELETE ROWS </xsl:text>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:if>
 </xsl:template>
 <xsl:template name="GenTablePhysicalAttrs">
  <xsl:param name="MVIEW_LOG">0</xsl:param>
  <xsl:param name="Pctspace">100</xsl:param>
  <!-- *******************************************************************
Template: GenTablePhysicalAttrs - dispatch to a processing template
  depending on table characteristics:
  non-partitioned heap table - GenHTablePhysicalAttrs
  non-partition IOT - GenIOTPhysicalAttrs
  partitioned heap table - GenPHTablePhysicalAttrs
  partition IOT - GenPIOTPhysicalAttrs
      *new for 11.1*
  heap partition converted to non-part table - CvtHPartToTable
  PIOT partition converted to non-part IOT - CvtPIOTPartToTable
Current node: TABLE_T
Parameters:
  MVIEW_LOG - 1 = generate attributes for materialized view log
  Pctspace - value of the PCTSPACE param; defaults to 100
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="(PART_OBJ)">
    <!-- partitioned -->
    <xsl:choose>
     <xsl:when test="(string-length($PARTITION_NAME)!=0 or
                      string-length($SUBPARTITION_NAME)!=0)">
      <xsl:choose>
       <xsl:when test="(PROPERTY mod 128)>=64">
        <!-- convert PIOT partition to non-partitioned IOT -->
        <xsl:call-template name="CvtPIOTPartToTable">
         <xsl:with-param name="Pctspace" select="$Pctspace"/>
        </xsl:call-template>
       </xsl:when>
       <xsl:otherwise>
        <!-- convert heap partition to non-partitioned heap table -->
        <xsl:call-template name="CvtHPartToTable">
         <xsl:with-param name="Pctspace" select="$Pctspace"/>
        </xsl:call-template>
       </xsl:otherwise>
      </xsl:choose>
     </xsl:when>
     <xsl:otherwise>
      <xsl:choose>
       <xsl:when test="(PROPERTY mod 128)>=64">
        <!-- PIOT -->
        <xsl:call-template name="GenPIOTPhysicalAttrs">
         <xsl:with-param name="MVIEW_LOG" select="$MVIEW_LOG"/>
         <xsl:with-param name="Pctspace" select="$Pctspace"/>
        </xsl:call-template>
       </xsl:when>
       <xsl:otherwise>
        <!-- Partitioned heap table -->
        <xsl:call-template name="GenPHTablePhysicalAttrs">
         <xsl:with-param name="MVIEW_LOG" select="$MVIEW_LOG"/>
         <xsl:with-param name="Pctspace" select="$Pctspace"/>
        </xsl:call-template>
       </xsl:otherwise>
      </xsl:choose>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <xsl:otherwise>
    <!-- non-partitioned -->
    <xsl:choose>
     <xsl:when test="(PROPERTY mod 128)>=64">
      <!-- IOT -->
      <xsl:call-template name="GenIOTPhysicalAttrs">
       <xsl:with-param name="MVIEW_LOG" select="$MVIEW_LOG"/>
       <xsl:with-param name="Pctspace" select="$Pctspace"/>
      </xsl:call-template>
     </xsl:when>
     <xsl:otherwise>
      <!-- Non-partitioned heap table -->
      <xsl:call-template name="GenHTablePhysicalAttrs">
       <xsl:with-param name="MVIEW_LOG" select="$MVIEW_LOG"/>
       <xsl:with-param name="Pctspace" select="$Pctspace"/>
      </xsl:call-template>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="GenHTablePhysicalAttrs">
  <xsl:param name="MVIEW_LOG">0</xsl:param>
  <xsl:param name="Pctspace">100</xsl:param>
  <!-- *******************************************************************
Template: GenHTablePhysicalAttrs - Physical attrs for non-partitioned
                heap table
Current node: TABLE_T
Parameters:
  MVIEW_LOG - 1 = generate attributes for materialized view log
  Pctspace - value of the PCTSPACE param; defaults to 100
******************************************************************** -->
  <!-- Do only if SEGMENT_ATTRIBUTES is true -->
  <xsl:if test="$SEGMENT_ATTRIBUTES=1">
   <!-- table physical attributes (PCTFREE, PCTUSED, INITRANS, MAXTRANS) -->
   <xsl:if test="(PROPERTY2 mod 8)>=4 and $VERSION>=1102000000">
    <xsl:text>SEGMENT CREATION DEFERRED </xsl:text>
    <xsl:if test="$PRETTY=1">
     <xsl:text>&#xa;  </xsl:text>
    </xsl:if>
   </xsl:if>
   <xsl:apply-templates select="PCT_FREE"/>
   <xsl:if test="$MVIEW_LOG=0">
    <xsl:call-template name="DoSegCompress">
     <xsl:with-param name="Compress" select="STORAGE/FLAGS"/>
    </xsl:call-template>
   </xsl:if>
   <xsl:call-template name="DoLogging">
    <xsl:with-param name="FlagsNode" select="FLAGS"/>
   </xsl:call-template>
   <xsl:apply-templates select="STORAGE">
    <xsl:with-param name="BlkSize" select="../BLOCKSIZE | BLOCKSIZE"/>
    <xsl:with-param name="Dataobjnum" select="DATAOBJ_NUM"/>
    <xsl:with-param name="Pctspace" select="$PCTSPACE"/>
   </xsl:apply-templates>
   <!-- hack: if deferred segment creation, the STORAGE template will not
        be called (because there will be no STORAGE element;
        so do tablespace here -->
   <xsl:if test="(PROPERTY2 mod 8)>=4">
    <xsl:if test="$TABLESPACE=1">
     <xsl:apply-templates select="TS_NAME"/>
    </xsl:if>
   </xsl:if>
   <!-- LOB, VARRAY AS LOB -->
   <xsl:call-template name="DoLobColsIf"/>
  </xsl:if>
  <!-- Do unconditionally -->
  <xsl:if test="(PROPERTY mod 8)>=4">
   <!-- has nested-TABLE columns -->
   <xsl:apply-templates select="NT">
    <xsl:with-param name="Pctspace" select="$Pctspace"/>
   </xsl:apply-templates>
  </xsl:if>
  <!-- Do only if SEGMENT_ATTRIBUTES is true -->
  <xsl:if test="$SEGMENT_ATTRIBUTES=1">
   <xsl:call-template name="DoParallel">
    <xsl:with-param name="FlagsParent" select="current()"/>
    <xsl:with-param name="MVIEW_LOG" select="$MVIEW_LOG"/>
   </xsl:call-template>
  </xsl:if>
 </xsl:template>
 <xsl:template name="GenIOTPhysicalAttrs">
  <xsl:param name="MVIEW_LOG">0</xsl:param>
  <xsl:param name="Pctspace">100</xsl:param>
  <!-- *******************************************************************
Template: GenIOTPhysicalAttrs - Physical attrs for non-partitioned IOT
Current node: TABLE_T
Parameters:
  MVIEW_LOG - 1 = generate attributes for materialized view log
  Pctspace - value of the PCTSPACE param; defaults to 100
******************************************************************** -->
  <!-- Do only if SEGMENT_ATTRIBUTES is true -->
  <xsl:if test="$SEGMENT_ATTRIBUTES=1">
   <!-- table physical attributes (PCTFREE, PCTUSED, INITRANS, MAXTRANS) -->
   <xsl:apply-templates select="PCT_FREE">
    <xsl:with-param name="ADT_type">INDEX</xsl:with-param>
   </xsl:apply-templates>
   <xsl:call-template name="DoLogging">
    <xsl:with-param name="FlagsNode" select="FLAGS"/>
   </xsl:call-template>
   <xsl:apply-templates select="STORAGE">
    <xsl:with-param name="BlkSize" select="../BLOCKSIZE | BLOCKSIZE"/>
    <xsl:with-param name="Dataobjnum" select="DATAOBJ_NUM"/>
    <xsl:with-param name="Pctspace" select="$PCTSPACE"/>
   </xsl:apply-templates>
   <xsl:if test="$PRETTY=1">
    <xsl:text>&#xa;</xsl:text>
   </xsl:if>
   <xsl:text> PCTTHRESHOLD </xsl:text>
   <xsl:value-of select="PCT_THRESH"/>
  </xsl:if>
  <!-- Do unconditionally -->
  <xsl:if test="(FLAGS mod 536870912) >= 268435456">
   <xsl:text> MAPPING TABLE</xsl:text>
  </xsl:if>
  <xsl:if test="(PROPERTY mod 256)>=128">
   <!-- IOV -->
   <xsl:call-template name="DoIOV">
    <xsl:with-param name="Node" select="current()"/>
    <xsl:with-param name="Pctspace" select="$PCTSPACE"/>
   </xsl:call-template>
  </xsl:if>
  <!-- Do only if SEGMENT_ATTRIBUTES is true -->
  <xsl:if test="$SEGMENT_ATTRIBUTES=1">
   <!-- LOB, VARRAY AS LOB -->
   <xsl:call-template name="DoLobColsIf"/>
  </xsl:if>
  <!-- Do unconditionally -->
  <xsl:if test="(PROPERTY mod 8)>=4">
   <!-- has nested-TABLE columns -->
   <xsl:apply-templates select="NT">
    <xsl:with-param name="Pctspace" select="$Pctspace"/>
   </xsl:apply-templates>
  </xsl:if>
  <!-- Do only if SEGMENT_ATTRIBUTES is true -->
  <xsl:if test="$SEGMENT_ATTRIBUTES=1">
   <xsl:call-template name="DoParallel">
    <xsl:with-param name="FlagsParent" select="current()"/>
    <xsl:with-param name="MVIEW_LOG" select="$MVIEW_LOG"/>
   </xsl:call-template>
  </xsl:if>
 </xsl:template>
 <xsl:template name="GenPHTablePhysicalAttrs">
  <xsl:param name="MVIEW_LOG">0</xsl:param>
  <xsl:param name="Pctspace">100</xsl:param>
  <!-- *******************************************************************
Template: GenPHTablePhysicalAttrs - Physical attrs for partitioned heap table
Current node: TABLE_T
Parameters:
  MVIEW_LOG - 1 = generate attributes for materialized view log
  Pctspace - value of the PCTSPACE param; defaults to 100
******************************************************************** -->
  <!-- Do only if SEGMENT_ATTRIBUTES is true -->
  <xsl:if test="$SEGMENT_ATTRIBUTES=1">
   <xsl:call-template name="DoPartObjSegAttrs">
    <xsl:with-param name="ADT_type">TABLE</xsl:with-param>
   </xsl:call-template>
   <xsl:if test="$MVIEW_LOG=0">
    <xsl:call-template name="DoPartOBJCompress">
     <!-- ONLY WANT BYTE 4 AND ABOVE -->
     <xsl:with-param name="Compress" select="(PART_OBJ/PARTOBJ/SPARE2 div 4294967296)"/>
    </xsl:call-template>
   </xsl:if>
   <xsl:call-template name="DoPartObjLogging"/>
   <xsl:call-template name="DoPartObjStorage">
    <xsl:with-param name="Pctspace" select="$PCTSPACE"/>
   </xsl:call-template>
   <xsl:call-template name="DoPartObjTablespace"/>
   <!-- LOB, VARRAY AS LOB -->
   <xsl:call-template name="DoLobColsIf"/>
  </xsl:if>
  <xsl:if test="(PROPERTY mod 8)>=4">
   <!-- has nested-TABLE columns -->
   <xsl:apply-templates select="NT">
    <xsl:with-param name="Pctspace" select="$Pctspace"/>
   </xsl:apply-templates>
  </xsl:if>
  <!-- PARTITION BY... -->
  <xsl:if test="($PARTITIONING =1)">
   <xsl:if test="$PRETTY=1">
    <xsl:text>&#xa; </xsl:text>
   </xsl:if>
   <xsl:call-template name="DoPartitionClause">
    <xsl:with-param name="Pctspace" select="$PCTSPACE"/>
   </xsl:call-template>
  </xsl:if>
  <xsl:if test="$SEGMENT_ATTRIBUTES=1">
   <xsl:call-template name="DoParallel">
    <xsl:with-param name="FlagsParent" select="current()"/>
    <xsl:with-param name="MVIEW_LOG" select="$MVIEW_LOG"/>
   </xsl:call-template>
  </xsl:if>
 </xsl:template>
 <xsl:template name="GenPIOTPhysicalAttrs">
  <xsl:param name="MVIEW_LOG">0</xsl:param>
  <xsl:param name="Pctspace">100</xsl:param>
  <!-- *******************************************************************
Template: GenPIOTPhysicalAttrs - Physical attrs for partitioned IOT
Current node: TABLE_T
Parameters:
  MVIEW_LOG - 1 = generate attributes for materialized view log
  Pctspace - value of the PCTSPACE param; defaults to 100
******************************************************************** -->
  <!-- Do only if SEGMENT_ATTRIBUTES is true -->
  <xsl:if test="$SEGMENT_ATTRIBUTES=1">
   <xsl:if test="$PARTITIONING=1">
    <xsl:call-template name="DoPIOTSegAttrs">
     <xsl:with-param name="Node" select="PART_OBJ/INDPARTOBJ"/>
    </xsl:call-template>
   </xsl:if>
   <xsl:call-template name="DoPIOTLogging">
    <!-- also does storage -->
    <xsl:with-param name="Node" select="PART_OBJ/INDPARTOBJ"/>
   </xsl:call-template>
   <xsl:call-template name="DoPartObjTablespace"/>
   <xsl:if test="$PRETTY=1">
    <xsl:text>&#xa;</xsl:text>
   </xsl:if>
   <xsl:text> PCTTHRESHOLD </xsl:text>
   <xsl:value-of select="PCT_THRESH"/>
  </xsl:if>
  <xsl:if test="(FLAGS mod 536870912) >= 268435456">
   <xsl:text> MAPPING TABLE</xsl:text>
  </xsl:if>
  <xsl:if test="(PROPERTY mod 256)>=128">
   <!-- IOV -->
   <xsl:call-template name="DoIOV">
    <xsl:with-param name="Node" select="current()"/>
    <xsl:with-param name="Pctspace" select="$PCTSPACE"/>
   </xsl:call-template>
  </xsl:if>
  <xsl:if test="$SEGMENT_ATTRIBUTES=1">
   <!-- LOB, VARRAY AS LOB -->
   <xsl:call-template name="DoLobColsIf"/>
  </xsl:if>
  <xsl:if test="(PROPERTY mod 8)>=4">
   <!-- has nested-TABLE columns -->
   <xsl:apply-templates select="NT">
    <xsl:with-param name="Pctspace" select="$Pctspace"/>
   </xsl:apply-templates>
  </xsl:if>
  <!-- PARTITION BY... -->
  <xsl:if test="($PARTITIONING =1)">
   <xsl:if test="$PRETTY=1">
    <xsl:text>&#xa; </xsl:text>
   </xsl:if>
   <xsl:call-template name="DoPIOTPartitionClause">
    <xsl:with-param name="Pctspace" select="$PCTSPACE"/>
    <xsl:with-param name="PartCompress" select="NUMKEYCOLS > 0"/>
   </xsl:call-template>
  </xsl:if>
  <xsl:if test="$SEGMENT_ATTRIBUTES=1">
   <xsl:call-template name="DoParallel">
    <xsl:with-param name="FlagsParent" select="current()"/>
    <xsl:with-param name="MVIEW_LOG" select="$MVIEW_LOG"/>
   </xsl:call-template>
  </xsl:if>
 </xsl:template>
 <xsl:template name="CvtHPartToTable">
  <xsl:param name="Pctspace">100</xsl:param>
  <!-- *******************************************************************
Template: CvtHPartToTable
Current node: TABLE_T
Parameters:
  Pctspace - value of the PCTSPACE param; defaults to 100
Implicit parameters:
  PARTITION_NAME or SUBPARTITION_NAME
   (sub)partition that is the source of storage information
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="string-length($PARTITION_NAME)!=0">
    <!--
         convert partition to table
 -->
    <xsl:apply-templates select="PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/PCT_FREE"/>
    <xsl:call-template name="DoSegCompress">
     <xsl:with-param name="Compress" select="
PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/STORAGE/FLAGS"/>
    </xsl:call-template>
    <xsl:call-template name="DoLogging">
     <xsl:with-param name="FlagsNode" select="PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/FLAGS"/>
    </xsl:call-template>
    <xsl:apply-templates select="PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/STORAGE">
     <xsl:with-param name="BlkSize" select="PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/BLOCKSIZE"/>
     <xsl:with-param name="Dataobjnum" select="PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/DATAOBJ_NUM"/>
     <xsl:with-param name="Pctspace" select="$PCTSPACE"/>
    </xsl:apply-templates>
    <xsl:apply-templates select="PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/LOBS">
     <xsl:with-param name="PartListItem">PART_LIST_ITEM</xsl:with-param>
     <xsl:with-param name="Parttype" select="PART_OBJ/PARTOBJ/PARTTYPE"/>
     <xsl:with-param name="Subpartition">0</xsl:with-param>
    </xsl:apply-templates>
    <!-- 
Placeholder for equipartitioned nested tables.
If a table's nested tables are not equipartitioned with the partition,
partition transportable should fail.
-->
    <xsl:call-template name="DoParallel">
     <xsl:with-param name="FlagsParent" select="current()"/>
    </xsl:call-template>
   </xsl:when>
   <xsl:otherwise>
    <!--
         convert subpartition to table
 -->
    <xsl:apply-templates select="PART_OBJ/COMPART_LIST/COMPART_LIST_ITEM/SUBPARTS/SUBPARTS_ITEM[SCHEMA_OBJ/SUBNAME=$SUBPARTITION_NAME]/PCT_FREE"/>
    <xsl:call-template name="DoSegCompress">
     <xsl:with-param name="Compress" select="
PART_OBJ/COMPART_LIST/COMPART_LIST_ITEM/SUBPARTS/SUBPARTS_ITEM[SCHEMA_OBJ/SUBNAME=$SUBPARTITION_NAME]/STORAGE/FLAGS"/>
    </xsl:call-template>
    <xsl:call-template name="DoLogging">
     <xsl:with-param name="FlagsNode" select="
PART_OBJ/COMPART_LIST/COMPART_LIST_ITEM/SUBPARTS/SUBPARTS_ITEM[SCHEMA_OBJ/SUBNAME=$SUBPARTITION_NAME]/FLAGS"/>
    </xsl:call-template>
    <xsl:apply-templates select="PART_OBJ/COMPART_LIST/COMPART_LIST_ITEM/SUBPARTS/SUBPARTS_ITEM[SCHEMA_OBJ/SUBNAME=$SUBPARTITION_NAME]/STORAGE">
     <xsl:with-param name="BlkSize" select="PART_OBJ/COMPART_LIST/COMPART_LIST_ITEM/SUBPARTS/SUBPARTS_ITEM[SCHEMA_OBJ/SUBNAME=$SUBPARTITION_NAME]/BLOCKSIZE"/>
     <xsl:with-param name="Dataobjnum" select="PART_OBJ/COMPART_LIST/COMPART_LIST_ITEM/SUBPARTS/SUBPARTS_ITEM[SCHEMA_OBJ/SUBNAME=$SUBPARTITION_NAME]/DATAOBJ_NUM"/>
     <xsl:with-param name="Pctspace" select="$PCTSPACE"/>
    </xsl:apply-templates>
    <xsl:apply-templates select="
PART_OBJ/COMPART_LIST/COMPART_LIST_ITEM/SUBPARTS/SUBPARTS_ITEM[SCHEMA_OBJ/SUBNAME=$SUBPARTITION_NAME]/LOBS">
     <xsl:with-param name="PartListItem">SUBPARTS_ITEM</xsl:with-param>
     <xsl:with-param name="Parttype" select="PART_OBJ/PARTOBJ/SPARE2 mod 256"/>
     <xsl:with-param name="Subpartition">1</xsl:with-param>
    </xsl:apply-templates>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="CvtPIOTPartToTable">
  <xsl:param name="Pctspace">100</xsl:param>
  <!-- *******************************************************************
Template: CvtPIOTPartToTable
Current node: TABLE_T
Parameters:
  Pctspace - value of the PCTSPACE param; defaults to 100
Implicit parameters:
  PARTITION_NAME or SUBPARTITION_NAME
   (sub)partition that is the source of storage information
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="string-length($PARTITION_NAME)!=0">
    <!--
         convert partition to table
 -->
    <xsl:apply-templates select="PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/PCT_FREE">
     <xsl:with-param name="ADT_type">INDEX</xsl:with-param>
    </xsl:apply-templates>
    <xsl:call-template name="DoSegCompress">
     <xsl:with-param name="Compress" select="
PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/STORAGE/FLAGS"/>
    </xsl:call-template>
    <xsl:call-template name="DoLogging">
     <xsl:with-param name="FlagsNode" select="PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/FLAGS"/>
    </xsl:call-template>
    <xsl:apply-templates select="PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/STORAGE">
     <xsl:with-param name="BlkSize" select="PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/BLOCKSIZE"/>
     <xsl:with-param name="Dataobjnum" select="PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/DATAOBJ_NUM"/>
     <xsl:with-param name="Pctspace" select="$PCTSPACE"/>
    </xsl:apply-templates>
    <xsl:apply-templates select="PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/LOBS">
     <xsl:with-param name="PartListItem">PART_LIST_ITEM</xsl:with-param>
     <xsl:with-param name="Parttype" select="PART_OBJ/TABPARTOBJ/PARTTYPE"/>
     <xsl:with-param name="Subpartition">0</xsl:with-param>
    </xsl:apply-templates>
    <!-- 
Placeholder for equipartitioned nested tables.
If a table's nested tables are not equipartitioned with the partition,
partition transportable should fail.
-->
     <xsl:call-template name="DoIOVList">
      <xsl:with-param name="List" select="PART_OBJ/IOV_LIST"/>
      <xsl:with-param name="PNUM" select="PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/PART_NUM"/>
      <xsl:with-param name="Pctspace" select="$Pctspace"/>
     </xsl:call-template>
    <xsl:call-template name="DoParallel">
     <xsl:with-param name="FlagsParent" select="current()"/>
    </xsl:call-template>
   </xsl:when>
   <xsl:otherwise>
    <!--
         convert subpartition to table
         (Placeholder: composite partitioned IOTs will be added in 11g)
 -->
    <xsl:apply-templates select="PART_OBJ/COMPART_LIST/COMPART_LIST_ITEM/SUBPARTS/SUBPARTS_ITEM[SCHEMA_OBJ/SUBNAME=$SUBPARTITION_NAME]/PCT_FREE"/>
    <xsl:call-template name="DoSegCompress">
     <xsl:with-param name="Compress" select="
PART_OBJ/COMPART_LIST/COMPART_LIST_ITEM/SUBPARTS/SUBPARTS_ITEM[SCHEMA_OBJ/SUBNAME=$SUBPARTITION_NAME]/STORAGE/FLAGS"/>
    </xsl:call-template>
    <xsl:call-template name="DoLogging">
     <xsl:with-param name="FlagsNode" select="
PART_OBJ/COMPART_LIST/COMPART_LIST_ITEM/SUBPARTS/SUBPARTS_ITEM[SCHEMA_OBJ/SUBNAME=$SUBPARTITION_NAME]/FLAGS"/>
    </xsl:call-template>
    <xsl:apply-templates select="PART_OBJ/COMPART_LIST/COMPART_LIST_ITEM/SUBPARTS/SUBPARTS_ITEM[SCHEMA_OBJ/SUBNAME=$SUBPARTITION_NAME]/STORAGE">
     <xsl:with-param name="BlkSize" select="PART_OBJ/COMPART_LIST/COMPART_LIST_ITEM/SUBPARTS/SUBPARTS_ITEM[SCHEMA_OBJ/SUBNAME=$SUBPARTITION_NAME]/BLOCKSIZE"/>
     <xsl:with-param name="Dataobjnum" select="PART_OBJ/COMPART_LIST/COMPART_LIST_ITEM/SUBPARTS/SUBPARTS_ITEM[SCHEMA_OBJ/SUBNAME=$SUBPARTITION_NAME]/DATAOBJ_NUM"/>
     <xsl:with-param name="Pctspace" select="$PCTSPACE"/>
    </xsl:apply-templates>
    <xsl:apply-templates select="
PART_OBJ/COMPART_LIST/COMPART_LIST_ITEM/SUBPARTS/SUBPARTS_ITEM[SCHEMA_OBJ/SUBNAME=$SUBPARTITION_NAME]/LOBS">
     <xsl:with-param name="PartListItem">SUBPARTS_ITEM</xsl:with-param>
     <xsl:with-param name="Parttype" select="PART_OBJ/TABPARTOBJ/SPARE2 mod 256"/>
     <xsl:with-param name="Subpartition">1</xsl:with-param>
    </xsl:apply-templates>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="DoLobColsIf">
  <!-- *******************************************************************
Template: DoLobColsIf
Current node: TABLE_T
******************************************************************** -->
  <!-- LOB, VARRAY AS LOB -->
  <!--  PROPERTY bits:     16 = has array columns (VARRAY)
                          2048 = has internal LOB columns
                        262144 = has user-defined LOB columns
 -->
  <xsl:if test="((PROPERTY mod 32)>=16 or
                  (PROPERTY mod 4096)>=2048 or
                  (PROPERTY mod 524288)>=262144)">
   <xsl:call-template name="DoLOBCols">
    <xsl:with-param name="MetaType">
     <xsl:choose>
      <xsl:when test="(PROPERTY mod 64)>=32">PartLob</xsl:when>
      <xsl:otherwise>Lob</xsl:otherwise>
     </xsl:choose>
    </xsl:with-param>
    <xsl:with-param name="TabBlocksize" select="BLOCKSIZE"/>
   </xsl:call-template>
  </xsl:if>
  <!-- XMLType virtual columns
       If this is an XMLTYPE table...  -->
  <xsl:if test="COL_LIST/COL_LIST_ITEM[NAME='SYS_NC_ROWINFO$']/TYPEMD/SCHEMA_OBJ/NAME='XMLTYPE'">
   <!-- look for columns with the following property bits:
               /* 0x0008 =       8 = virtual column                         */
               /* 0x0020 =      32 = hidden column                          */
           /* 0x00010000 =   65536 = virtual column                         */
        but the following bits must be clear
                /* 0x0100 =     256 = system-generated column                */
                /* 0x0200 =     512 = rowinfo column of typed table/view     */
                /* 0x4000 =   16384 = dropped column                         */
        Note: virtual columns are inserted in reverse order, so we must sort.
   -->
   <xsl:for-each select="COL_LIST/COL_LIST_ITEM[(PROPERTY mod 16 >= 8) and
           (PROPERTY mod 64 >= 32) and
           (PROPERTY mod 131052 >= 65536) and
           (256 > (PROPERTY mod 512)) and
           (512 > (PROPERTY mod 1024)) and
           (16384 > (PROPERTY mod 32768))]">
    <xsl:sort select="INTCOL_NUM"  data-type="number" order="descending"/>
    <xsl:if test="position()=1">
     <xsl:if test="$PRETTY=1">
      <xsl:text>&#xa;</xsl:text>
     </xsl:if>
     <xsl:text> VIRTUAL COLUMNS (</xsl:text>
    </xsl:if>
    <xsl:text>"</xsl:text>
    <xsl:value-of select="NAME"/>
    <xsl:text>" AS (</xsl:text>
    <xsl:value-of select="DEFAULT_VAL"/>
    <xsl:text>)</xsl:text>
    <xsl:choose>
     <xsl:when test="position()!=last()">
      <xsl:text>,</xsl:text>
      <xsl:if test="$PRETTY=1">
       <xsl:text>&#xa;</xsl:text>
      </xsl:if>
     </xsl:when>
     <xsl:otherwise>)</xsl:otherwise>
    </xsl:choose>
   </xsl:for-each>
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoLOBCols">
  <xsl:param name="MetaType">Lob</xsl:param>
  <xsl:param name="TabBlocksize">0</xsl:param>
  <!-- *******************************************************************
Template: DoLOBCols
Parameters:
  MetaType
     Lob         - lob column metadata in non-partitioned table
     PartLob     - table level defaults
     LobFrag     - actual partition- or subpartition-level lob attributes
     LobComppart - partition-level defaults
  TabBlocksize - Table blocksize value
******************************************************************** -->
  <!-- exclude system-generated columns -->
  <xsl:for-each select="COL_LIST/COL_LIST_ITEM[256>(PROPERTY mod 512)]/LOBMD">
   <!-- exclude XMLSchema-based columns -->
   <xsl:choose>
    <xsl:when test="(../OPQMD/FLAGS mod 4)>=2"/>
    <xsl:when test="../PLOBMD">
     <xsl:apply-templates select="../PLOBMD">
      <xsl:with-param name="MetaType" select="$MetaType"/>
      <xsl:with-param name="TabBlocksize" select="$TabBlocksize"/>
     </xsl:apply-templates>
    </xsl:when>
    <xsl:otherwise>
     <xsl:call-template name="DoLOBStoreAs">
      <xsl:with-param name="MetaType" select="$MetaType"/>
      <xsl:with-param name="ColList" select="../.."/>
      <xsl:with-param name="Intcolnum" select="../INTCOL_NUM"/>
      <xsl:with-param name="TabBlocksize" select="$TabBlocksize"/>
     </xsl:call-template>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:for-each>
 </xsl:template>
 <xsl:template match="PLOBMD">
  <xsl:param name="MetaType">Lob</xsl:param>
  <xsl:param name="TabBlocksize">0</xsl:param>
  <!-- *******************************************************************
Template: PLOBMD
Parameters:
  MetaType
     Lob         - lob column metadata in non-partitioned table
     PartLob     - table level defaults
     LobFrag     - actual partition- or subpartition-level lob attributes
     LobComppart - partition-level defaults
  TabBlocksize - Table blocksize value
******************************************************************** -->
  <xsl:call-template name="DoLOBStoreAs">
   <xsl:with-param name="MetaType" select="$MetaType"/>
   <xsl:with-param name="ColList" select="../.."/>
   <xsl:with-param name="Intcolnum" select="../INTCOL_NUM"/>
   <xsl:with-param name="TabBlocksize" select="$TabBlocksize"/>
  </xsl:call-template>
 </xsl:template>
 <xsl:template name="CheckTypes">
  <!-- *******************************************************************
Template: CheckTypes
 Add check_type calls for all object types used directly by the table

      If transportable tablespace import and not classic export and VERS_MAJOR
      is at least 2 and VERS_MINOR is at least 2, insert check_type calls for
      object types. For this check to work, the major and minor versions were
      all given the same values in all table views that can contain object
      types (the 4 non-heap table views ku$_fhtable_view, ku$_iotable_view,
      ku$_pfhtable_view, and ku$_piotable_view).

      Do not do this for classic because it does things differently and it
      does its own type checking. Check for not classic export is for parameter
      TRANSPORTABLE_CLASSIC=0.

******************************************************************** -->
  <xsl:if test="$TRANSPORTABLE=1 and $TRANSPORTABLE_CLASSIC=0 and
              (VERS_MAJOR>=3 or (VERS_MAJOR=2 and VERS_MINOR>=2))">
   <xsl:for-each select="COL_LIST/COL_LIST_ITEM[TYPE_NUM=121]">
    <!-- Create one begin...end block for all the calls. Also, call DoParse
        once for the begin...end block. -->
    <xsl:if test="position()=1">
     <xsl:call-template name="DoParse">
      <xsl:with-param name="Verb">SYS.DBMS_METADATA.CHECK_TYPE</xsl:with-param>
      <xsl:with-param name="ObjectType">TABLE</xsl:with-param>
      <xsl:with-param name="SchemaNode" select="../../SCHEMA_OBJ/OWNER_NAME"/>
      <xsl:with-param name="NameNode" select="../../SCHEMA_OBJ/NAME"/>
     </xsl:call-template>
     <xsl:text>BEGIN </xsl:text>
     <xsl:if test="$PRETTY=1">
      <xsl:text>&#xa;</xsl:text>
     </xsl:if>
    </xsl:if>
    <!-- If there are no subtypes, then there is 1 check_type call for the 
        type. If there are subtypes, the parent type is included at the
        TYPEMD level and again in the SUBTYPE_LIST. In that case, create
        1 call for each item in the SUBTYPE_LIST, which will include the
        top level type and each subtype. -->
    <xsl:if test="not(TYPEMD/SUBTYPE_LIST/SUBTYPE_LIST_ITEM)">
     <xsl:text>SYS.DBMS_METADATA.CHECK_TYPE('</xsl:text>
     <xsl:value-of select="TYPEMD/SCHEMA_OBJ/OWNER_NAME"/>
     <xsl:text>','</xsl:text>
     <xsl:value-of select="TYPEMD/SCHEMA_OBJ/NAME"/>
     <xsl:text>','</xsl:text>
     <xsl:value-of select="TYPEMD/VERSION"/>
     <xsl:text>','</xsl:text>
     <xsl:value-of select="TYPEMD/HASHCODE"/>
     <xsl:text>','</xsl:text>
     <xsl:value-of select="TYPEMD/TYPEID"/>
     <xsl:text>'); </xsl:text>
     <xsl:if test="$PRETTY=1">
      <xsl:text>&#xa;</xsl:text>
     </xsl:if>
    </xsl:if>
    <xsl:for-each select="TYPEMD/SUBTYPE_LIST/SUBTYPE_LIST_ITEM">
     <xsl:text>SYS.DBMS_METADATA.CHECK_TYPE('</xsl:text>
     <xsl:value-of select="SCHEMA_OBJ/OWNER_NAME"/>
     <xsl:text>','</xsl:text>
     <xsl:value-of select="SCHEMA_OBJ/NAME"/>
     <xsl:text>','</xsl:text>
     <xsl:value-of select="VERSION"/>
     <xsl:text>','</xsl:text>
     <xsl:value-of select="HASHCODE"/>
     <xsl:text>','</xsl:text>
     <xsl:value-of select="TYPEID"/>
     <xsl:text>'); </xsl:text>
     <xsl:if test="$PRETTY=1">
      <xsl:text>&#xa;</xsl:text>
     </xsl:if>
    </xsl:for-each>
    <xsl:if test="position()=last()">
     <xsl:text>END;</xsl:text>
     <xsl:choose>
      <xsl:when test="$SQLTERMINATOR=1">
       <xsl:text>
/
      </xsl:text>
       <!-- Terminate the SQL statement with a CR and a "/" -->
      </xsl:when>
      <xsl:otherwise>
       <xsl:if test="$PRETTY=1">
        <xsl:text>&#xa;</xsl:text>
       </xsl:if>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:if>
   </xsl:for-each>
  </xsl:if>
 </xsl:template>
</xsl:stylesheet>
