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

<?xml version="1.0"?>
<!-- Copyright (c) 2000, 2017, Oracle and/or its affiliates. 
All rights reserved.-->
<!-- 
NAME
    kulob.xsl
DESCRIPTION
    XSLT stylesheet for XML => DDL conversion of lob 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
    tbhukya     09/26/17 - Bug 26833211: Generate Anydata column storage at
                           partition's lob fragment for hass partition
    tbhukya     08/30/17 - Bug 26717358: handle lob params compress, 
                           deduplication and cache partitioned xmltype table
    tbhukya     08/01/17 - Bug 25322579: Handle Xmltype partition lob storage
                               in departition
    mjangir     01/05/17 - bug 23753307: Lob col missing compress and
                           deduplication
    sdavidso    12/06/16 - Bug24702230 sharding move chunk fails w/long varchar
    rapayne     09/21/16 - bug 23203578: global temp tabs need to support
                           parallel attributes and lob cols.
    tbhukya     08/22/16 - Bug 24285300: encryption in xmltype storage
    tbhukya     06/13/16 - Bug 21945496: Generate opaque type storage clause for
                           subtype anydata attribute in tts
    tbhukya     04/13/16 - Bug 23035574: Encryption in lob storage param
    rapayne     01/30/16 - bug 22611512: fix variable Transportable
    jjanosik    01/20/16 - bug 19792856 - handle lobindex
    bwright     10/19/15 - Bug 21279204: Fix lob storage clause output for
                           unpacked anydata column
    tbhukya     10/13/15 - Bug 21761632: Restrict storage clause of unused
                           UDT, Named table, named array type column in tts.
    tbhukya     09/21/15 - Bug 21858261: Generate lob storage clause for 
                           unused columns.
    tbhukya     01/05/15 - Bug 20319428: Declare referred params
    lbarton     05/14/14 - bug 18746312: don't import view-as-table with
                           transportable params
    sogugupt    10/13/14   Bug 17382480: check if tablespace is false then no 
                           need to add this brackets ()
    tbhukya     04/03/13 - Bug 18424585: Do not generate log segment parameters
                           at subpartition level for varray
    mjangir     09/16/13 - bug 17402461: Generate log segment for subpartition
    bwright     08/15/13 - Bug 17312600: Remove hard tabs from DP src code
    tbhukya     07/11/13 - Bug 11737404 : Include varray clause for 
                           partition storage clause
    prthiaga    12/31/12 - XbranchMerge prthiaga_initrans_issue from
                           st_rdbms_12.1.0.1
    lbarton     11/29/12 - bug 14490476 txn prthiaga_initrans_issue:
                           partition-level lob, xmltype table, transportable
    lbarton     07/31/12 - bug 13454387: long varchar
    lbarton     12/08/11 - 36954_dpump_tabcluster_zonemap
    ebatbout    10/24/11 - 12781157: Unpacked opaque column support
    lbarton     07/13/11 - 32948_lob_storage
    sdavidso    08/08/11 - LOB_SEGNAME transform support
    sdavidso    03/30/11 - support TRANSPORTABLE xml element
    lbarton     04/26/10 - bug 9650606: more dsc details
    sdavidso    04/29/10 - bug 9633699: composite partition and specific data
                           types
    lbarton     04/19/10 - lrg 4476227: no ALLOW NOSCHEMA for lob
    sdavidso    01/27/10 - bug 8929002: bad column name for mView
    rapayne     01/10/10 - bug 9235295: suppress hidden subtype references
                           which contain TREAT AS syntax.
    lbarton     08/27/09 - bug 8820324: support all values in deferred_stg
    lbarton     08/14/09 - bug 8795792: no compress/logging in deferred stg for
                           indexes
    lbarton     06/18/09 - lrg 3543159: XMLType virtual columns
    tbhukya     06/24/09 - Bug 8282506: don't generate duplicate lob storage 
                           for list partition in transportable.
    lbarton     03/04/09 - bug 8252494: deferred segment creation
    slynn       02/04/09 - Fix bug-7023008: RETENTION NONE emitted as RETENTION
                           AUTO.
    rapayne     12/06/08 - merge BLOCKSIZE logic for CM
    slynn       05/08/08 - Fix bug-5868613: Fix Partition/subpartition
                           parameters.
    rapayne     12/31/07 - lrg 3246276 : make RETENTION AUTO the default
                                       for securefile lobs.
    ebatbout    12/12/07 - bug 6468074 : missing lob Params for SecureFile lobs
    rapayne     12/07/07 - bug : output LOB STORAGE RETENTION for
                           non-Export comsummers.
    slynn       09/13/07 - Fix bug-6414775: problems with SecureFiles.
    slynn       08/28/07 - Remove lob specification encrypt clause.
    htseng      06/07/07 - bug 6118244 - generate LOB clause for OPAQUE
                           in LobComppart 
    slynn       02/25/07 - Backout changes that removed dedup validate.
    sdavidso    02/28/07 - aviod illegal chunk clause
    slynn       02/11/07 - Fix Partitioned LOB Column Retention
    spetride    12/05/06 - binary XML: ensure lob name/attrs present
                         - corrected pos ALLOW/DIALLOW ANYSCHEMA/NONSCHEMA
    slynn       11/20/06 - Remove unimplemented keywords
    slynn       10/12/06 - smartfile->securefile
    slynn       07/31/06 - change csce keywords
    jforsyth    05/10/06 - adding encryption, compression, sharing 
    lbarton     05/18/06 - bug 5152323: xmltype in partitioned tbl and tte 
    kkunchit    11/02/05 - project-18204: inode: LOCAL/NOLOCAL support 
    mbaloglu    12/23/05 - Add SYNC/ASYNC, CACHE NOLOGGING 
    htseng      03/13/06 - binary xml support 
    htseng      03/07/06 - bug 4963080: not generate LOB STORE AS for xmltype 
                           column 
    lbarton     02/28/06 - bug 4959915: transportable lobs in list 
                           subpartition 
    lbarton     11/02/05 - Bug 4715313: reformat files for use with XMLSpy 
    htseng      08/05/05 - bug 3560220 : get correct behivor processor 
    lbarton     05/16/05 - Bug 4373204: generate correct [NO]LOGGING for lobs
    lbarton     05/04/05 - bug 4347010: exclude unused columns 
    rpfau       11/30/04 - bug 3684091 - add check and apply template of 
                           LOBINDEX in template DoXMLTypeStorage. Have callers
                           of DoXMLTypeStorage emit XMLTYPE and simplify
                           call logic.
    rpfau       06/22/04 - Redo xmltype with partitions, put it at table level
                           only and not at partition level. Also fix carriage
                           return logic for storage parameters if there is no
                           tablespace.
    rpfau       06/11/04 - Fix anytype column in partitioned table - bug
                           3618089.
    lbarton     10/31/03 - Bug 3215955: Emit XMLTYPE LOBINDEX if TRANSPORTABLE
    lbarton     05/05/03 - remove obsolete TABLESPACE clause on lob INDEX
    htseng      03/31/03 - fix TRANSPORTABLE for index
    htseng      03/26/03 - fix bug 2862458 opaque type
    bmccarth    03/28/03 - revert to NOT put out XMLTYPE on store as lob
    bmccarth    11/15/02 - fix xmltype store as clob
    bmccarth    10/14/02 - bug 2549870 remove XMLTYPE from store as clob
    lbarton     08/02/02 - transportable export
    lbarton     04/03/02 - xdb bugfix
    lbarton     01/07/02 - formatting
    dgagne      09/19/01 - create lob store as clause for template subp
    dgagne      09/06/01 - add support for range/list composite partitions
    dgagne      06/14/01 - Move storage PRETTY statements to kustorag
    lbarton     06/01/01 - remove oradb-style imports
    lbarton     12/01/00 - XMLType support
    lbarton     10/27/00 - bugfix
    gclaborn    10/30/00 - Add external imports
    lbarton     09/29/00 - use ColNameOrAttr
    lbarton     07/24/00 - use uriref in import
    lbarton     05/15/00 - Params for new API
    lbarton     04/05/00 - Creation (make separate script)
 -->
<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="kustorag.xsl"/>
 <!-- Top level params -->
 <xsl:param name="TRANSPORTABLE">0</xsl:param>
 <xsl:param name="SEGMENT_ATTRIBUTES">1</xsl:param>
 <xsl:param name="PRETTY">1</xsl:param>
 <xsl:param name="TABLESPACE">1</xsl:param>
 <xsl:param name="EXPORT">0</xsl:param>
 <xsl:param name="EXCHANGE_OUT">0</xsl:param>
 <xsl:param name="LOB_SEGNAME">1</xsl:param>
 <!--TRANSPORTABLE is valid for TABLE and TABLESPACE export, not DATABASE export.
  We define Transportable to mean the current object is moved using trasportable
  See kutable.xsl for more details.
 -->
 <xsl:variable name="Transportable">
  <xsl:choose>
   <xsl:when test="$TRANSPORTABLE = 0">0</xsl:when>
   <xsl:when test="$TRANSPORTABLE = 1">1</xsl:when>
   <xsl:when test='$TRANSPORTABLE = 2 and .//TRANSPORTABLE="1"'>1</xsl:when>
   <xsl:otherwise>0</xsl:otherwise>
  </xsl:choose>
 </xsl:variable>
 <!-- Templates -->
 <xsl:template name="DoLobColsIf">
  <xsl:param name="XMLType_table">0</xsl:param>
  <xsl:param name="ViewAsTable">0</xsl:param>
  <!-- *******************************************************************
Template: DoLobColsIf
Current node: TABLE_T
Parameters:
  XMLType_table - 1 = generate properties for xmltype table
  ViewAsTable - 1 = table XML for view-as-table
******************************************************************** -->
  <!-- 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:with-param name="XMLType_table" select="$XMLType_table"/>
    <xsl:with-param name="ViewAsTable" select="$ViewAsTable"/>
   </xsl:call-template>
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoLOBCols">
  <xsl:param name="MetaType">Lob</xsl:param>
  <xsl:param name="TabBlocksize">0</xsl:param>
  <xsl:param name="XMLType_table">0</xsl:param>
  <xsl:param name="ViewAsTable">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
  XMLType_table - 1 = generate properties for xmltype table
  ViewAsTable - 1 = table XML for view-as-table
******************************************************************** -->
  <!-- exclude system-generated columns unless unpacked Anydata col  -->
  <xsl:for-each select="COL_LIST/COL_LIST_ITEM[((256>(PROPERTY mod 512)) or 
                       (BASE_COL_TYPE=5 and (TYPE_NUM=58 and  
                        TYPEMD/SCHEMA_OBJ/OWNER_NAME='SYS' and  
                        TYPEMD/SCHEMA_OBJ/NAME='ANYDATA')))]/LOBMD">
   <!-- exclude XMLSchema-based columns -->
   <!-- if this is xmltype table, exclude the ROWINFO col (the info was
         already emitted by template 'CreXMLTypeTable') -->
   <xsl:choose>
    <xsl:when test="(../OPQMD/FLAGS mod 4)>=2"/>
    <xsl:when test="$XMLType_table=1 and ../NAME='SYS_NC_ROWINFO$'"/>
    <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:with-param name="ViewAsTable" select="$ViewAsTable"/>
     </xsl:call-template>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:for-each>
 </xsl:template>
 <xsl:template name="DoLOBStoreAs">
  <xsl:param name="MetaType">Lob</xsl:param>
  <xsl:param name="Parttype">0</xsl:param>
  <xsl:param name="Subpartition">0</xsl:param>
  <xsl:param name="ColList" select="''"/>
  <xsl:param name="Intcolnum">0</xsl:param>
  <xsl:param name="TabBlocksize">0</xsl:param>
  <xsl:param name="XMLType_storage">0</xsl:param>
  <xsl:param name="ViewAsTable">0</xsl:param>
  <!-- *******************************************************************
Template:  DoLOBStoreAs
  XML environment:

   TABLE_T
    COL_LIST
     COL_LIST_ITEM
      TYPE_NUM
      TYPEMD
       FLAGS
      LOBMD             (current node)
      OPQMD
       FLAGS

  or

   TABLE_T
    COL_LIST
     COL_LIST_ITEM
      TYPE_NUM
      TYPEMD
       FLAGS
    BLOCKSIZE
    PART_OBJ
     PART_LIST or COMPART_LIST or SUBPARTS
      PART_LIST_ITEM or COMPART_LIST_ITEM or SUBPARTS_ITEM
       LOBS
        LOBS_ITEM       (current node)
         INTCOL_NUM

  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
   Parttype      - partition type: 1 = range, 2 = hash
   Subpartition  - 0 = partition, 1 = subpartition
   ColList       - column list node
   Intcolnum     - intcolnum for lob column
   TabBlocksize  - Table blocksize value
   XMLType_storage 
                 - 1 = emit xmltype storage syntax for xmltype table
                   (i.e., not for column)
   ViewAsTable - 1 = table XML for view-as-table

  Lob name:
     For non-partitioned table, lobname is obj$.name.
     For partitioned table, for table-level default, lobname is obj$.name.
     For non-composite partitioned table, lobname at partition level
       is obj$.subname.
     For composite partitioned table, lobname at partition level
       is obj$.subname
     For composite partitioned table, lobname at subpartition level
       is obj$.subname
******************************************************************** -->
  <xsl:variable name="IntcolnumColItem" select="$ColList/COL_LIST_ITEM[INTCOL_NUM=$Intcolnum]"/>
  <xsl:variable name="ColTypeNum" select="$IntcolnumColItem/TYPE_NUM"/>
  <!-- do VARRAY or LOB or XMLTYPE clause depending on column type -->
  <xsl:variable name="Property">
   <xsl:choose>
    <xsl:when test="PROPERTY">
     <xsl:value-of select="PROPERTY"/>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="DEFPRO"/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:variable>
  <xsl:choose>
   <!-- skip all of this if column is unused and ((not transportable) or lob storege)-->
   <xsl:when test="$IntcolnumColItem/PROPERTY mod 65536>=32768 and 
($Transportable=0 or 
 ( $ColTypeNum=121 or
   $ColTypeNum=122 or
   $ColTypeNum=123))"/>
   <!-- VARRAY (type#=123) -->
   <xsl:when test="$ColTypeNum=123">
    <!-- The logic is appallingly complex -->
    <xsl:choose>
     <!-- First, see if we can skip the whole thing -->
     <!-- Don't generate VARRAY foo STORE AS LOB in the following 2 cases:
       1. collection storage is specified (coltype$.flags bit #x40)
          and
          the varray has a system-generated name (obj$.flags bit #x04)
          and
          this is not a TRANSPORTABLE export 
          and either
           this is a hash partition (parttype=2) or
           the user specified SEGMENT_ATTRIBUTES=0
          AND this is NOT a SecureFile
     -->
     <xsl:when test="
        (2048 > ($Property mod 4096))
        and
        $IntcolnumColItem/TYPEMD/FLAGS mod 128 >=64
        and
        (SCHEMA_OBJ/FLAGS mod 8)>=4
        and
        $Transportable=0
        and
        ($Parttype=2 or $SEGMENT_ATTRIBUTES=0)"/>
     <!-- 
       2. no collection storage specified (coltype$.flags bit #x40)
          and
          varray has a system-generated name (obj$.flags bit #x04)
          and varray column is specified as part of partition storage
              (coltype$.flags bit #x8)
          and
           not TRANSPORTABLE export or
           the user specified SEGMENT_ATTRIBUTES=0 or
           we're at the default level
          AND this is NOT a SecureFile
     -->
     <xsl:when test="
        (2048 > ($Property mod 4096))
        and
        64>($IntcolnumColItem/TYPEMD/FLAGS mod 128)
        and
        ((SCHEMA_OBJ/FLAGS mod 8)>=4
         and
         ($IntcolnumColItem/TYPEMD/FLAGS mod 16) >= 8
        )
        and
        ($Transportable=0 or $SEGMENT_ATTRIBUTES=0 or
        $MetaType='PartLob' or $MetaType='LobComppart')"/>
     <!--
      3. If this VARRAY is in an XMLTYPE column
         and
          the varray has a system-generated name (obj$.flags bit #x04)
         and
          the storage wasn't explicitly specified.
      -->
     <xsl:when test="
        ($ColList/COL_LIST_ITEM[LOBMD/INTCOL_NUM=$Intcolnum]/OPQMD
         and
         $ColList/COL_LIST_ITEM[LOBMD/INTCOL_NUM=$Intcolnum]/OPQMD/TYPE=1)
        and
        (SCHEMA_OBJ/FLAGS mod 8)>=4
        and
        64>($IntcolnumColItem/TYPEMD/FLAGS mod 128)"/>
     <!-- we have to do it -->
     <xsl:otherwise>
      <!-- generate "VARRAY foo STORE AS LOB" -->
      <xsl:if test="$PRETTY=1">
       <xsl:text>&#xa;</xsl:text>
      </xsl:if>
      <xsl:text> VARRAY </xsl:text>
      <xsl:call-template name="ColNameOrAttr">
       <xsl:with-param name="ColItem" select="$IntcolnumColItem"/>
      </xsl:call-template>
      <xsl:text> STORE AS </xsl:text>
      <xsl:call-template name="DoSecureFile">
       <xsl:with-param name="Property" select="PROPERTY | DEFPRO"/>
       <xsl:with-param name="Parttype" select="$Parttype"/>
       <xsl:with-param name="Subpartition" select="$Subpartition"/>
      </xsl:call-template>
      <xsl:text>LOB </xsl:text>
      <!-- anything to add? -->
      <xsl:choose>
       <!-- if no collection storage specified (coltype$.flags bit #x40)
               and
               varray has a system-generated name (obj$.flags bit #x04)
               and varray column is specified as part of partition storage
                   coltype$.flags bit #x
               and NOT a SecureFile
           then do the TRANSPORTABLE attributes
         -->
       <xsl:when test="
      64>($IntcolnumColItem/TYPEMD/FLAGS mod 128)
      and
      ((SCHEMA_OBJ/FLAGS mod 8)>=4
       and
       ($IntcolnumColItem/TYPEMD/FLAGS mod 16) >= 8
      )
      and (2048 > ($Property mod 4096))">
        <xsl:if test="$Transportable=1 and $SEGMENT_ATTRIBUTES=1">
         <xsl:text>(</xsl:text>
         <xsl:apply-templates select="STORAGE">
          <xsl:with-param name="Nested">1</xsl:with-param>
          <xsl:with-param name="BlkSize" select="../BLOCKSIZE | BLOCKSIZE"/>
          <xsl:with-param name="Dataobjnum" select="SCHEMA_OBJ/DATAOBJ_NUM"/>
         </xsl:apply-templates>
         <xsl:apply-templates select="LOBINDEX"/>
         <xsl:text>) </xsl:text>
        </xsl:if>
       </xsl:when>
       <!-- collection storage is specified -->
       <xsl:otherwise>
        <xsl:call-template name="PutLobname">
         <xsl:with-param name="MetaType" select="$MetaType"/>
        </xsl:call-template>
        <!-- more decisions... -->
        <xsl:choose>
         <!-- for hash (sub)partitions emit only transportable attributes -->
         <xsl:when test="$Parttype=2">
          <xsl:if test="$Transportable=1 and $SEGMENT_ATTRIBUTES=1">
           <xsl:text>(</xsl:text>
           <xsl:apply-templates select="STORAGE">
            <xsl:with-param name="Nested">1</xsl:with-param>
            <xsl:with-param name="BlkSize" select="../BLOCKSIZE | BLOCKSIZE"/>
            <xsl:with-param name="Dataobjnum" select="SCHEMA_OBJ/DATAOBJ_NUM"/>
           </xsl:apply-templates>
           <xsl:apply-templates select="LOBINDEX"/>
           <xsl:text>) </xsl:text>
          </xsl:if>
         </xsl:when>
         <!-- for everything else except subpartitions, 
              emit the lob parameters -->
         <xsl:otherwise>
          <xsl:if test="$SEGMENT_ATTRIBUTES=1 and 
                        ($Parttype=0 or $Transportable=1 or $Subpartition=0)">
           <xsl:if test="$PRETTY=1">
            <xsl:text>&#xa;  </xsl:text>
           </xsl:if>
           <xsl:text>(</xsl:text>
           <!-- for some reason TABLESPACE is invalid for VARRAY STORE AS LOB
                in a partition;
                suppress newline before TABLESPACE -->
           <xsl:if test="$Parttype=0">
            <xsl:call-template name="DoLobTS_NAME">
             <xsl:with-param name="MetaType" select="$MetaType"/>
             <xsl:with-param name="NewLine">0</xsl:with-param>
            </xsl:call-template>
           </xsl:if>
           <!-- Lob storage parameters in sub-partition are invalid -->
           <xsl:if test="$Subpartition=0">
            <xsl:call-template name="PutLOBParams">
             <xsl:with-param name="MetaType" select="$MetaType"/>
             <xsl:with-param name="TabBlocksize" select="$TabBlocksize"/>
             <xsl:with-param name="ViewAsTable" select="$ViewAsTable"/>
            </xsl:call-template>
           </xsl:if>
           <xsl:if test="$Transportable=1">
            <xsl:apply-templates select="LOBINDEX"/>
           </xsl:if>
           <xsl:text>) </xsl:text>
          </xsl:if>
         </xsl:otherwise>
        </xsl:choose>
       </xsl:otherwise>
      </xsl:choose>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <!-- CLOB (type#=112) or BLOB (type#113) 
        or transportable and long varchar/raw -->
   <xsl:when test="($ColTypeNum=112) or
($ColTypeNum=113) or
($Transportable=1 and $EXCHANGE_OUT=0 and
  ($ColTypeNum=1 or
   $ColTypeNum=23))">
    <!-- Emit LOB STORE AS if $SEGMENT_ATTRIBUTES=1 or if
         $SEGMENT_ATTRIBUTES=0 and the user specified a lob segment name
         (meaning lob segement name is not system generated).
      -->
    <xsl:if test="
       $SEGMENT_ATTRIBUTES=1
       or
       ($SEGMENT_ATTRIBUTES=0 and 4>(SCHEMA_OBJ/FLAGS mod 8))">
     <!--
          Get the 'current' column list item using the passed in intcol_num
          value.  
      -->
     <!-- 
         Make list of all XMLType columns. XMLType column is indicated by 
         LOBMD/OPQMD/TYPE=1 in the COL_LIST_ITEM. Need to test for the
         existence of OPQMD before testing for TYPE=1 because some
         columns do not have an OPQMD entry.  
      -->
     <xsl:variable name="XMLColList" select="$ColList/COL_LIST_ITEM[OPQMD and OPQMD/TYPE=1]"/>
     <!-- 
         Make list of all columns created from unpacking an ANYDATA column
         This is indicated by BASE_COL_TYPE=5.  Because unpacking an ANYDATA
         item can only occur on an 'ALTER TABLE foo MODIFY OPAQUE TYPE 
         anydatacol STORE (XMLType, myclobtype) UNPACKED', any lob columns
         created as part of this ALTER TABLE should not be included in the
         DDL to create the table.  
      -->
     <xsl:variable name="UnpackedColList" select="$ColList/COL_LIST_ITEM[BASE_COL_TYPE and BASE_COL_TYPE=5]"/>
     <!--
           Emit LOB STORE AS for lobs that are not unpacked columns
               (and hence must be original columns of the table) for
           (1) non-XMLType columns 
           (2) XMLType columns if transportable (bug 5152323)

       -->
     <xsl:if test="not($UnpackedColList[INTCOL_NUM=$IntcolnumColItem/BASE_INTCOL_NUM])">
      <xsl:if test="(not($XMLColList[LOBMD/INTCOL_NUM=$Intcolnum])) or
          ($Transportable=1 and $MetaType='LobFrag')">
       <xsl:if test="$PRETTY=1">
        <xsl:text>&#xa;</xsl:text>
       </xsl:if>
       <xsl:text> LOB (</xsl:text>
       <xsl:choose>
        <xsl:when test="$XMLColList[LOBMD/INTCOL_NUM=$Intcolnum]">
         <!-- XMLType column -->
         <!-- If col name = XMLDATA use "XMLDATA" -->
         <!-- Else use the XMLtype col name ."XMLDATA" -->
         <xsl:if test="$IntcolnumColItem/NAME!='XMLDATA'">
          <xsl:variable name="XMLColItem" select="$ColList/COL_LIST_ITEM[COL_NUM=$IntcolnumColItem/LOBMD/COL_NUM and SEGCOL_NUM=0]"/>
          <xsl:call-template name="ColNameOrAttr">
           <xsl:with-param name="ColItem" select="$XMLColItem"/>
          </xsl:call-template>
          <xsl:text>.</xsl:text>
         </xsl:if>
         <xsl:text>"XMLDATA"</xsl:text>
        </xsl:when>
        <xsl:otherwise>
         <xsl:choose>
          <!-- Use NAME value if col. belongs to unpacked AnyData column -->
          <xsl:when test="$IntcolnumColItem/BASE_COL_TYPE=5">
           <xsl:call-template name="QuoteObject">
            <xsl:with-param name="Object" select="$IntcolnumColItem/NAME"/>
           </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
           <xsl:call-template name="ColNameOrAttr">
            <xsl:with-param name="ColItem" select="$IntcolnumColItem"/>
           </xsl:call-template>
          </xsl:otherwise>
         </xsl:choose>
        </xsl:otherwise>
       </xsl:choose>
       <xsl:text>) STORE AS </xsl:text>
       <xsl:call-template name="DoSecureFile">
        <xsl:with-param name="Property" select="PROPERTY | DEFPRO"/>
        <xsl:with-param name="Parttype" select="$Parttype"/>
        <xsl:with-param name="Subpartition" select="$Subpartition"/>
       </xsl:call-template>
       <xsl:call-template name="PutLobname">
        <xsl:with-param name="MetaType" select="$MetaType"/>
       </xsl:call-template>
       <xsl:variable name="hasLobAttributes">
        <xsl:choose>
         <xsl:when test="TS_NAME">1</xsl:when>
         <xsl:when test="DEFTS_NAME">1</xsl:when>
         <xsl:when test="$Parttype!=2 and $Subpartition=0">1</xsl:when>
         <xsl:when test="($Parttype=2 or ($Parttype=4 and $Subpartition=1)) and $Transportable=1 and (STORAGE or LOBINDEX)">1</xsl:when>
         <xsl:otherwise>0</xsl:otherwise>
        </xsl:choose>
       </xsl:variable>
       <!-- In case of tablespace is true then add () or in case of hash partitions before lob parameters add paren -->
       <xsl:if test="$hasLobAttributes!=0 and ($TABLESPACE=1 or ($Parttype!=2 and $Subpartition=0) or $Transportable=1)">
        <xsl:text>(</xsl:text>
        <xsl:call-template name="DoLobTS_NAME">
         <xsl:with-param name="MetaType" select="$MetaType"/>
        </xsl:call-template>
	<xsl:choose>
 	 <!-- don't emit lob parameters for hash partitions -->
         <xsl:when test="($Parttype!=2 and $Subpartition=0) or (($Parttype=1 or $Parttype=4) and $Subpartition=1 and $Transportable=1)">
          <xsl:call-template name="PutLOBParams">
           <xsl:with-param name="MetaType" select="$MetaType"/>
           <xsl:with-param name="TabBlocksize" select="$TabBlocksize"/>
           <xsl:with-param name="ViewAsTable" select="$ViewAsTable"/>
          </xsl:call-template>
          <!-- if the index has a user created name, include it -->
          <xsl:if test="$Transportable=1 or 4>(LOBINDEX/SCHEMA_OBJ/FLAGS mod 8)">
           <xsl:apply-templates select="LOBINDEX"/>
          </xsl:if>
         </xsl:when>
         <!-- generate transportable attributes for hash partitions -->
         <xsl:when test="$Parttype=2  and $Transportable=1">
          <xsl:apply-templates select="STORAGE">
           <xsl:with-param name="Nested">1</xsl:with-param>
           <xsl:with-param name="BlkSize" select="../BLOCKSIZE | BLOCKSIZE"/>
           <xsl:with-param name="Dataobjnum" select="SCHEMA_OBJ/DATAOBJ_NUM"/>
          </xsl:apply-templates>
          <xsl:apply-templates select="LOBINDEX"/>
         </xsl:when>
        </xsl:choose>
        <xsl:text>) </xsl:text>
       </xsl:if>
      </xsl:if>
     </xsl:if>
    </xsl:if>
   </xsl:when>
   <!-- OPAQUE (type#=58) -->
   <xsl:when test="$IntcolnumColItem/TYPE_NUM=58">
    <!-- If SEGMENT_ATTRIBUTES=0, only emit LOB STORE AS
        if the user specified a lob segment name.
     -->
    <!-- bug 9235295: Subtypes of xmltype types generate column references
          with TREAT AS syntax. This is not currently supported SQL.
          Therefore, we will suppress these col refs for now.

         Bug 21945496: In tts mode, anydata subtype attribute storage is needed
                       to avoid ora-1647 error.
     -->
    <xsl:if test="not($IntcolnumColItem/ATTRNAME and
             contains($IntcolnumColItem/ATTRNAME, 'TREAT(') and
             contains($IntcolnumColItem/ATTRNAME, ' AS ')) or $Transportable>0">
     <xsl:if test="$SEGMENT_ATTRIBUTES=1 or 4>(SCHEMA_OBJ/FLAGS mod 8)">
      <xsl:if test="$PRETTY=1">
       <xsl:text>&#xa;</xsl:text>
      </xsl:if>
      <xsl:choose>
       <xsl:when test="$IntcolnumColItem/OPQMD/TYPE=0">
        <xsl:choose>
         <xsl:when test="$MetaType='PartLob' or $MetaType='Lob'">
          <xsl:text> OPAQUE TYPE (</xsl:text>
          <xsl:choose>
           <!-- If part of unpacked AnyData col, select user specified name -->
           <xsl:when test="$IntcolnumColItem/BASE_COL_TYPE=5">
            <xsl:call-template name="QuoteObject">
             <xsl:with-param name="Object" select="$ColList/COL_LIST_ITEM[BASE_INTCOL_NUM=$Intcolnum and SEGCOL_NUM=0 and TYPEMD/SCHEMA_OBJ/OWNER_NAME='SYS' and TYPEMD/SCHEMA_OBJ/NAME='ANYDATA']/NAME"/>
            </xsl:call-template>
           </xsl:when>
           <xsl:otherwise>
            <xsl:call-template name="ColNameOrAttr">
             <xsl:with-param name="ColItem" select="$IntcolnumColItem"/>
            </xsl:call-template>
           </xsl:otherwise>
          </xsl:choose>
          <xsl:text>) STORE AS </xsl:text>
          <xsl:call-template name="DoSecureFile">
           <xsl:with-param name="Property" select="PROPERTY | DEFPRO"/>
           <xsl:with-param name="Parttype" select="$Parttype"/>
           <xsl:with-param name="Subpartition" select="$Subpartition"/>
          </xsl:call-template>
          <xsl:text>LOB </xsl:text>
         </xsl:when>
         <xsl:when test="$MetaType='LobFrag' or $MetaType ='LobComppart'">
          <!-- Need parentheses around the lob name -->
          <xsl:text> LOB (</xsl:text>
          <xsl:choose>
           <!-- If part of unpacked AnyData col, select user specified name -->
           <xsl:when test="$ColList/COL_LIST_ITEM[INTCOL_NUM=$Intcolnum and BASE_COL_TYPE=5 and TYPEMD/SCHEMA_OBJ/NAME='ANYDATA']">
            <xsl:call-template name="QuoteObject">
             <xsl:with-param name="Object" select="$ColList/COL_LIST_ITEM[BASE_INTCOL_NUM=$Intcolnum and SEGCOL_NUM=0 and TYPEMD/SCHEMA_OBJ/OWNER_NAME='SYS' and TYPEMD/SCHEMA_OBJ/NAME='ANYDATA']/NAME"/>
            </xsl:call-template>
           </xsl:when>
           <xsl:otherwise>
            <xsl:call-template name="ColNameOrAttr">
             <xsl:with-param name="ColItem" select="$IntcolnumColItem"/>
            </xsl:call-template>
           </xsl:otherwise>
          </xsl:choose>
          <xsl:text>) STORE AS </xsl:text>
          <xsl:call-template name="DoSecureFile">
           <xsl:with-param name="Property" select="PROPERTY | DEFPRO"/>
           <xsl:with-param name="Parttype" select="$Parttype"/>
           <xsl:with-param name="Subpartition" select="$Subpartition"/>
          </xsl:call-template>
         </xsl:when>
        </xsl:choose>
       </xsl:when>
       <xsl:when test="$MetaType='PartLob' and $Transportable=1
      and $IntcolnumColItem/OPQMD/LOBCOL!=0">
        <!-- transportable and xmltype col stored as lob in partitioned table -->
        <xsl:text>LOB (</xsl:text>
        <xsl:call-template name="ColNameOrAttr">
         <xsl:with-param name="ColItem" select="$IntcolnumColItem"/>
         <xsl:with-param name="InColDef">1</xsl:with-param>
        </xsl:call-template>
        <xsl:text>."XMLDATA") STORE AS </xsl:text>
        <xsl:call-template name="DoSecureFile">
         <xsl:with-param name="Property" select="PROPERTY | DEFPRO"/>
         <xsl:with-param name="Parttype" select="$Parttype"/>
         <xsl:with-param name="Subpartition" select="$Subpartition"/>
        </xsl:call-template>
       </xsl:when>
       <xsl:otherwise>
        <xsl:text> XMLTYPE</xsl:text>
        <xsl:if test="$XMLType_storage = 0">
         <xsl:text> COLUMN </xsl:text>
         <xsl:call-template name="ColNameOrAttr">
          <xsl:with-param name="ColItem" select="$IntcolnumColItem"/>
         </xsl:call-template>
        </xsl:if>
        <xsl:choose>
         <xsl:when test="$IntcolnumColItem/OPQMD/TYPE=1 and
          (($IntcolnumColItem/OPQMD/FLAGS) mod 128 >=64)">
          <xsl:text> STORE AS </xsl:text>
          <xsl:call-template name="DoSecureFile">
           <xsl:with-param name="Property" select="PROPERTY | DEFPRO"/>
           <xsl:with-param name="Parttype" select="$Parttype"/>
           <xsl:with-param name="Subpartition" select="$Subpartition"/>
          </xsl:call-template>
          <xsl:text>BINARY XML </xsl:text>
         </xsl:when>
         <xsl:otherwise>
          <xsl:text> STORE AS </xsl:text>
          <xsl:call-template name="DoSecureFile">
           <xsl:with-param name="Property" select="PROPERTY | DEFPRO"/>
           <xsl:with-param name="Parttype" select="$Parttype"/>
           <xsl:with-param name="Subpartition" select="$Subpartition"/>
          </xsl:call-template>
          <xsl:text>CLOB </xsl:text>
         </xsl:otherwise>
        </xsl:choose>
       </xsl:otherwise>
      </xsl:choose>
      <xsl:call-template name="PutLobname">
       <xsl:with-param name="MetaType" select="$MetaType"/>
      </xsl:call-template>
      <xsl:choose>
       <!--for hash partitions or any subpartition, generate just LOB_partitioning_storage syntax-->
       <xsl:when test="$Parttype=2 or $Subpartition=1">
        <xsl:choose>
         <!-- Generate lob params for hash partition in tts mode to avoid 
              ora-01647 error -->
         <xsl:when test="$Transportable=1 and $Parttype=2">
          <xsl:text>(</xsl:text>
          <xsl:call-template name="PutLOBParams">
           <xsl:with-param name="MetaType" select="$MetaType"/>
           <xsl:with-param name="TabBlocksize" select="$TabBlocksize"/>
           <xsl:with-param name="ViewAsTable" select="$ViewAsTable"/>
          </xsl:call-template>
          <xsl:apply-templates select="LOBINDEX"/>
          <xsl:if test="TS_NAME">
           <xsl:apply-templates select="TS_NAME"/>
          </xsl:if>
          <xsl:text>) </xsl:text>
         </xsl:when>
         <xsl:otherwise>
          <!-- tablespace name is all we may need -->
          <xsl:if test="TS_NAME">
           <xsl:text>(</xsl:text>
           <xsl:apply-templates select="TS_NAME"/>
           <xsl:text>) </xsl:text>
          </xsl:if>
         </xsl:otherwise>
        </xsl:choose>
       </xsl:when>
       <xsl:otherwise>
        <xsl:text>(</xsl:text>
        <xsl:choose>
         <!-- tablespace name not needed for opaques and anydata types (indicated
         by OPQMD/TYPE=0) except for hash partitioned table ($Partype=2) at
         partition level ($MetaType='LobFrag').
      -->
         <xsl:when test="$IntcolnumColItem/OPQMD/TYPE=0
         and
         not($Parttype=2 and $MetaType='LobFrag')">
          <!-- tablespace name not need -->
          <xsl:if test="$PRETTY=1">
           <xsl:text>&#xa;  </xsl:text>
          </xsl:if>
         </xsl:when>
         <xsl:when test="$MetaType='Lob' or $MetaType='LobFrag'">
          <xsl:choose>
           <xsl:when test="TS_NAME">
            <xsl:apply-templates select="TS_NAME"/>
           </xsl:when>
           <xsl:otherwise>
            <!-- No TS_NAME entry, so put out a cr -->
            <xsl:if test="$PRETTY=1">
             <xsl:text>&#xa;  </xsl:text>
            </xsl:if>
           </xsl:otherwise>
          </xsl:choose>
         </xsl:when>
         <xsl:otherwise>
          <xsl:choose>
           <xsl:when test="DEFTS_NAME">
            <xsl:apply-templates select="DEFTS_NAME"/>
           </xsl:when>
           <xsl:otherwise>
            <!-- No DEFTS_NAME entry, so put out a cr -->
            <xsl:if test="$PRETTY=1">
             <xsl:text>&#xa;  </xsl:text>
            </xsl:if>
           </xsl:otherwise>
          </xsl:choose>
         </xsl:otherwise>
        </xsl:choose>
        <!-- Put out lob parameters if not a hash partition. -->
        <xsl:choose>
         <!-- In case of departition, generate lob parameters with partition 
              metadata -->
         <xsl:when test="string-length($PARTITION_NAME)!=0 and 
                         ../../../PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]">
          <xsl:call-template name="PutLOBParams">
           <xsl:with-param name="MetaType" select="$MetaType"/>
           <xsl:with-param name="TabBlocksize" select="$TabBlocksize"/>
           <xsl:with-param name="ViewAsTable" select="$ViewAsTable"/>
           <xsl:with-param name="LobNode" select="../../../PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/LOBS/LOBS_ITEM"/>
          </xsl:call-template>
          <xsl:if test="$Transportable=1">
           <xsl:apply-templates select="../../../PART_OBJ/PART_LIST/PART_LIST_ITEM[SCHEMA_OBJ/SUBNAME=$PARTITION_NAME]/LOBS/LOBS_ITEM/LOBINDEX"/>
          </xsl:if>
         </xsl:when>
         <xsl:otherwise>
        <xsl:call-template name="PutLOBParams">
         <xsl:with-param name="MetaType" select="$MetaType"/>
         <xsl:with-param name="TabBlocksize" select="$TabBlocksize"/>
         <xsl:with-param name="ViewAsTable" select="$ViewAsTable"/>
        </xsl:call-template>
        <xsl:if test="$Transportable=1">
         <xsl:apply-templates select="LOBINDEX"/>
        </xsl:if>
        </xsl:otherwise>
        </xsl:choose>
        <xsl:text>) </xsl:text>
       </xsl:otherwise>
      </xsl:choose>
      <!-- skip [DIS]ALLOW, etc., if this it xmltype table top level -->
      <!-- also skip if transportable and xmltype col stored as lob in partitioned table -->
      <xsl:choose>
       <xsl:when test="$XMLType_storage = 1"/>
       <xsl:when test="$MetaType='PartLob' and $Transportable=1
         and $IntcolnumColItem/OPQMD/LOBCOL!=0"/>
       <xsl:when test="$IntcolnumColItem/OPQMD/TYPE=1 and 
         (($IntcolnumColItem/OPQMD/FLAGS) mod 128 >=64)">
        <xsl:choose>
         <xsl:when test="($IntcolnumColItem/OPQMD/FLAGS) mod 512 >=256">
          <xsl:text>DISALLOW NONSCHEMA </xsl:text>
         </xsl:when>
         <xsl:otherwise>
          <xsl:text>ALLOW NONSCHEMA </xsl:text>
         </xsl:otherwise>
        </xsl:choose>
        <xsl:choose>
         <xsl:when test="($IntcolnumColItem/OPQMD/FLAGS) mod 256 >=128">
          <xsl:text>ALLOW ANYSCHEMA  </xsl:text>
         </xsl:when>
         <xsl:otherwise>
          <xsl:if test="($IntcolnumColItem/OPQMD/FLAGS) mod 512 &lt;256">
           <xsl:text>DISALLOW ANYSCHEMA </xsl:text>
          </xsl:if>
         </xsl:otherwise>
        </xsl:choose>
       </xsl:when>
      </xsl:choose>
     </xsl:if>
    </xsl:if>
   </xsl:when>
  </xsl:choose>
 </xsl:template>
 <xsl:template match="TLOBS_ITEM">
  <!-- *******************************************************************
Template: TLOBS_ITEM
******************************************************************** -->
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa;   </xsl:text>
  </xsl:if>
  <xsl:text> LOB (</xsl:text>
  <xsl:value-of select="COLNAME"/>
  <xsl:text>) STORE AS </xsl:text>
  <xsl:text>"</xsl:text>
  <xsl:value-of select="LOB_SPART_NAME"/>
  <xsl:text>"</xsl:text>
  <xsl:if test="TS_NAME">
   <xsl:text>(</xsl:text>
   <xsl:apply-templates select="TS_NAME"/>
   <xsl:text>) </xsl:text>
  </xsl:if>
 </xsl:template>
 <xsl:template name="PutLobname">
  <xsl:param name="MetaType">Lob</xsl:param>
  <!-- *******************************************************************
Template: PutLobname
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
******************************************************************** -->
  <xsl:if test="4>(SCHEMA_OBJ/FLAGS mod 8) and $LOB_SEGNAME=1">
   <!-- not sys-generated name -->
   <xsl:text>"</xsl:text>
   <xsl:choose>
    <xsl:when test="$MetaType='Lob' or $MetaType='PartLob'">
     <xsl:value-of select="SCHEMA_OBJ/NAME"/>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="SCHEMA_OBJ/SUBNAME"/>
    </xsl:otherwise>
   </xsl:choose>
   <xsl:text>"</xsl:text>
  </xsl:if>
 </xsl:template>
 <xsl:template name="PutLOBParams">
  <xsl:param name="MetaType">Lob</xsl:param>
  <xsl:param name="TabBlocksize">0</xsl:param>
  <xsl:param name="ViewAsTable">0</xsl:param>
  <xsl:param name="LobNode" select="."/>
  <!-- *******************************************************************
Template: PutLOBParams
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
     LobNode     - In case of de-partition, partition lob node
   TabBlocksize  - Table blocksize value
   ViewAsTable - 1 = table XML for view-as-table
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="$MetaType='Lob' or $MetaType='LobFrag'">
    <xsl:call-template name="DoStorageInRow">
     <xsl:with-param name="Property" select="$LobNode/PROPERTY"/>
    </xsl:call-template>
    <xsl:apply-templates select="$LobNode/CHUNK">
     <xsl:with-param name="Blocksize" select="../BLOCKSIZE | $LobNode/BLOCKSIZE"/>
     <xsl:with-param name="TabBlocksize" select="$TabBlocksize"/>
    </xsl:apply-templates>
    <xsl:call-template name="DoRetention">
     <xsl:with-param name="Storage" select="$LobNode/STORAGE"/>
     <xsl:with-param name="DeferredStg" select="$LobNode/DEFERRED_STG"/>
     <xsl:with-param name="Property" select="$LobNode/PROPERTY"/>
     <xsl:with-param name="Flags" select="$LobNode/FLAGS"/>
     <xsl:with-param name="Retention" select="$LobNode/RETENTION"/>
     <xsl:with-param name="MinTime" select="$LobNode/STORAGE/GROUPS"/>
    </xsl:call-template>
    <xsl:apply-templates select="$LobNode/PCTVERSION">
     <xsl:with-param name="Flags" select="$LobNode/FLAGS"/>
     <xsl:with-param name="Property" select="$LobNode/PROPERTY"/>
    </xsl:apply-templates>
    <xsl:if test="$PRETTY=1">
     <xsl:text>&#xa; </xsl:text>
    </xsl:if>
    <!-- CACHE options -->
    <xsl:call-template name="DoCache">
     <xsl:with-param name="Flags" select="$LobNode/FLAGS | $LobNode/DEFFLAGS"/>
     <xsl:with-param name="Property" select="$LobNode/PROPERTY | $LobNode/DEFPRO"/>
     <xsl:with-param name="MetaType" select="$MetaType"/>
    </xsl:call-template>
    <!-- storage -->
    <xsl:choose>
     <xsl:when test="$LobNode/DEFERRED_STG">
      <xsl:call-template name="DoDeferredStg">
       <xsl:with-param name="DeferredStg" select="$LobNode/DEFERRED_STG"/>
       <xsl:with-param name="ADT_type">LOB</xsl:with-param>
      </xsl:call-template>
     </xsl:when>
     <xsl:otherwise>
      <xsl:apply-templates select="$LobNode/STORAGE">
       <xsl:with-param name="Nested">1</xsl:with-param>
       <xsl:with-param name="BlkSize" select="../BLOCKSIZE | $LobNode/BLOCKSIZE"/>
       <xsl:with-param name="Dataobjnum" select="$LobNode/SCHEMA_OBJ/DATAOBJ_NUM"/>
       <xsl:with-param name="ViewAsTable" select="$ViewAsTable"/>
      </xsl:apply-templates>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <!-- table level default in partitioned table -->
   <xsl:otherwise>
    <xsl:call-template name="DoStorageInRow">
     <xsl:with-param name="Property" select="$LobNode/DEFPRO"/>
    </xsl:call-template>
    <xsl:apply-templates select="DEFCHUNK">
     <xsl:with-param name="Blocksize" select="../DEFBLOCKSIZE | $LobNode/DEFBLOCKSIZE"/>
     <xsl:with-param name="TabBlocksize" select="$TabBlocksize"/>
    </xsl:apply-templates>
    <xsl:call-template name="DoRetention">
     <xsl:with-param name="Storage" select="$LobNode/STORAGE"/>
     <xsl:with-param name="DeferredStg" select="$LobNode/DEFERRED_STG"/>
     <xsl:with-param name="Property" select="$LobNode/DEFPRO"/>
     <xsl:with-param name="Flags" select="$LobNode/DEFFLAGS"/>
     <xsl:with-param name="Retention" select="$LobNode/DEFRETENTION"/>
     <xsl:with-param name="MinTime" select="$LobNode/DEFMINTIME"/>
    </xsl:call-template>
    <xsl:apply-templates select="$LobNode/DEFPCTVERSION">
     <xsl:with-param name="Flags" select="$LobNode/DEFFLAGS"/>
     <xsl:with-param name="Property" select="$LobNode/DEFPRO"/>
    </xsl:apply-templates>
    <xsl:if test="$PRETTY=1">
     <xsl:text>&#xa; </xsl:text>
    </xsl:if>
    <!-- CACHE options -->
    <xsl:call-template name="DoCache">
     <xsl:with-param name="Flags" select="$LobNode/DEFFLAGS"/>
     <xsl:with-param name="Property" select="$LobNode/DEFPRO"/>
     <xsl:with-param name="MetaType" select="$MetaType"/>
    </xsl:call-template>
    <!-- storage -->
    <xsl:call-template name="DoDefStorage">
     <xsl:with-param name="Node" select="."/>
     <xsl:with-param name="BlkSize" select="$TabBlocksize"/>
    </xsl:call-template>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="DoStorageInRow">
  <xsl:param name="Property" select="''"/>
  <!-- *******************************************************************
Template: DoStorageInRow
Parameters:
   Property: lob$.property
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="($Property mod 4)>=2">
    <xsl:text>ENABLE STORAGE IN ROW</xsl:text>
   </xsl:when>
   <xsl:otherwise>
    <xsl:text>DISABLE STORAGE IN ROW</xsl:text>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template match="CHUNK | DEFCHUNK">
  <xsl:param name="Blocksize" select="''"/>
  <xsl:param name="TabBlocksize">0</xsl:param>
  <!-- *******************************************************************
Template: CHUNK | DEFCHUNK
Parameters:
   Blocksize     - tablespace blocksize
   TabBlocksize  - Table blocksize value
******************************************************************** -->
  <xsl:if test=".!=0">
   <xsl:text> CHUNK </xsl:text>
   <xsl:choose>
    <xsl:when test="$Blocksize">
     <xsl:value-of select="(.)*$Blocksize"/>
    </xsl:when>
    <xsl:otherwise>
     <xsl:value-of select="(.)*$TabBlocksize"/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:if>
 </xsl:template>
 <xsl:template match="PCTVERSION | DEFPCTVERSION">
  <xsl:param name="Flags" select="''"/>
  <xsl:param name="Property" select="''"/>
  <!-- *******************************************************************
Template: PCTVERSION | DEFPCTVERSION (only valid with BASICFILE)
Parameters:
   Flags    - lob$.flags
   Property - lob$.property
Implicit inputs:
   LOB_STORAGE - SECUREFILE = only use securefile params
                 DEFAULT = omit explicit params; take defaults
   Transportable - ignore LOB_STORAGE if Transportable=1
******************************************************************** -->
  <xsl:if test="(32 > ($Flags mod 64)) and 
                (2048 > ($Property mod 4096) and
                ($Transportable=1 or
                ($LOB_STORAGE != 'SECUREFILE' and $LOB_STORAGE != 'DEFAULT')))">
   <xsl:text> PCTVERSION </xsl:text>
   <xsl:value-of select="."/>
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoCache">
  <xsl:param name="Flags" select="''"/>
  <xsl:param name="Property" select="''"/>
  <xsl:param name="MetaType" select="''"/>
  <!-- *******************************************************************
Template: DoCache
Parameters:
   Flags    - lob$.flags
   Property - lob$.property
 The processing in DoCache parallels that in 
     exuglb.c routine 'put_lob_params'.  See also
     KKCBLATTR_ bit definitions in rdbms/src/server/dict/if/kkb.h
     (Note that CACHE NOLOGGING is illegal - SQL Ref Manual, logging_clause)
Implicit inputs:
   LOB_STORAGE - BASICFILE = only use basicfile params
                 DEFAULT = omit explicit params; take defaults
       (CACHE is valid for both securefile/basicfile;
        COMPRESS, DEDUPLICATE, ENCRYPT are securefile only)
   Transportable - ignore LOB_STORAGE if Transportable=1
******************************************************************** -->
  <xsl:choose>
   <!-- LOGGING clause is NOT valid for Global Temp Tables -->
   <xsl:when test="(ancestor::TABLE_T/PROPERTY mod 8388608)>=4194304">
    <xsl:choose>
     <xsl:when test="($Flags mod 1024)>=512"> CACHE </xsl:when>
     <xsl:when test="($Flags mod 512)>=256"> CACHE </xsl:when>
     <xsl:when test="($Flags mod 32)>=16"> CACHE READS </xsl:when>
     <xsl:when test="($Flags mod 16)>=8"> CACHE READS </xsl:when>
     <xsl:when test="($Flags mod 4)>=2"> NOCACHE </xsl:when>
     <xsl:when test="($Flags mod 2)>=1"> NOCACHE </xsl:when>
     <xsl:otherwise> CACHE </xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <xsl:otherwise>
    <xsl:choose>
     <xsl:when test="($Flags mod 1024)>=512"> CACHE LOGGING </xsl:when>
     <xsl:when test="($Flags mod 512)>=256"> CACHE NOLOGGING </xsl:when>
     <xsl:when test="($Flags mod 32)>=16"> CACHE READS NOLOGGING </xsl:when>
     <xsl:when test="($Flags mod 16)>=8"> CACHE READS LOGGING </xsl:when>
     <xsl:when test="($Flags mod 4)>=2"> NOCACHE NOLOGGING </xsl:when>
     <xsl:when test="($Flags mod 2)>=1"> NOCACHE LOGGING </xsl:when>
     <xsl:otherwise> CACHE </xsl:otherwise>
    </xsl:choose>
   </xsl:otherwise>
  </xsl:choose>
  <xsl:if test="$VERSION>=1100000000 and ($Transportable=1 or ($LOB_STORAGE != 'BASICFILE' and $LOB_STORAGE != 'DEFAULT'))">
   <!-- CSCE: ENCRYPTION, COMPRESSION, SHARING -->
   <xsl:choose>
    <!-- Generate ENCRYPT and internal algo at table or partition level 
         lob storage as sub-partition level lob defaults to higher level -->
    <xsl:when test="($MetaType='Lob' or $MetaType='PartLob') and 
                    ($Flags mod 8192)>=4096">
     <xsl:call-template name="EncryptAlgo">
      <xsl:with-param name="EncAlg" select="../../../ENCALG"/>
      <xsl:with-param name="IntAlg" select="../../../INTALG"/>
     </xsl:call-template>
    </xsl:when>
    <!-- DECRYPT is default so don't generate it at table or partition level 
         lob storage. At sub-paritition level it can be generated as higher 
         level lob storage can have ENCRYPT -->
    <xsl:when test="($Property mod 4096)>=2048 and
                    ($Flags mod 8192)&lt;4096 and 
                    $MetaType!='Lob' and 
                    $MetaType!='PartLob' and
                    (../../../../../ENCALG or ../../../ENCALG)">DECRYPT</xsl:when>
   </xsl:choose>
   <xsl:choose>
    <xsl:when test="($Flags mod 16384)>=8192"> COMPRESS LOW </xsl:when>
    <xsl:when test="($Flags mod 32768)>=16384"> COMPRESS MEDIUM </xsl:when>
    <xsl:when test="($Flags mod 65536)>=32768"> COMPRESS HIGH </xsl:when>
    <xsl:when test="($Property mod 4096)>=2048"> NOCOMPRESS </xsl:when>
   </xsl:choose>
   <xsl:choose>
    <xsl:when test="($Flags mod 131072)>=65536"> DEDUPLICATE LOB </xsl:when>
    <xsl:when test="($Flags mod 262144)>=131072"> DEDUPLICATE OBJECT </xsl:when>
    <xsl:when test="($Property mod 4096)>=2048"> KEEP_DUPLICATES </xsl:when>
   </xsl:choose>
   <xsl:choose>
    <xsl:when test="($Flags mod 524288)>=262144"> VALIDATE </xsl:when>
   </xsl:choose>
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoXMLTypeStorage">
  <xsl:param name="Property" select="''"/>
  <!-- *******************************************************************
Template: DoXMLTypeStorage
 Emit STORE AS CLOB for XMLSchema-based object table
 current node must be LOBMD 
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="../OPQMD/FLAGS mod 128 >= 64">
    <xsl:text> STORE AS </xsl:text>
    <xsl:call-template name="DoSecureFile">
     <xsl:with-param name="Property" select="PROPERTY | DEFPRO"/>
    </xsl:call-template>
    <xsl:text>BINARY XML </xsl:text>
   </xsl:when>
   <xsl:otherwise>
    <xsl:text> STORE AS </xsl:text>
    <xsl:call-template name="DoSecureFile">
     <xsl:with-param name="Property" select="PROPERTY | DEFPRO"/>
    </xsl:call-template>
    <xsl:text>CLOB </xsl:text>
   </xsl:otherwise>
  </xsl:choose>
  <xsl:call-template name="PutLobname">
   <xsl:with-param name="MetaType">Lob</xsl:with-param>
  </xsl:call-template>
  <xsl:text> (</xsl:text>
  <xsl:choose>
   <xsl:when test="TS_NAME">
    <xsl:apply-templates select="TS_NAME"/>
   </xsl:when>
   <xsl:otherwise>
    <!-- No TS_NAME entry, so put out a cr -->
    <xsl:if test="$PRETTY=1">
     <xsl:text>&#xa;  </xsl:text>
    </xsl:if>
   </xsl:otherwise>
  </xsl:choose>
  <xsl:call-template name="PutLOBParams">
   <xsl:with-param name="MetaType">Lob</xsl:with-param>
   <xsl:with-param name="TabBlocksize" select="../BLOCKSIZE | BLOCKSIZE"/>
  </xsl:call-template>
  <!-- bug 3684091 - add this check and call for transportable. -->
  <xsl:if test="$Transportable=1">
   <xsl:apply-templates select="LOBINDEX"/>
  </xsl:if>
  <xsl:text>) </xsl:text>
 </xsl:template>
 <xsl:template match="LOBINDEX">
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa;</xsl:text>
  </xsl:if>
  <xsl:text>  INDEX </xsl:text>
  <xsl:if test="4>(SCHEMA_OBJ/FLAGS mod 8)">
   <!-- not sys-generated name -->
   <xsl:text>"</xsl:text>
   <xsl:value-of select="SCHEMA_OBJ/NAME"/>
   <xsl:text>" </xsl:text>
  </xsl:if>
  <xsl:text>(</xsl:text>
  <xsl:text> INITRANS </xsl:text>
  <xsl:value-of select="INITRANS"/>
  <xsl:text> MAXTRANS </xsl:text>
  <xsl:value-of select="MAXTRANS"/>
  <xsl:apply-templates select="STORAGE">
   <xsl:with-param name="Nested">1</xsl:with-param>
   <xsl:with-param name="BlkSize" select="../BLOCKSIZE | BLOCKSIZE"/>
   <xsl:with-param name="Dataobjnum" select="SCHEMA_OBJ/DATAOBJ_NUM"/>
  </xsl:apply-templates>
  <xsl:text>) </xsl:text>
 </xsl:template>
 <xsl:template name="DoLobTS_NAME">
  <xsl:param name="MetaType">Lob</xsl:param>
  <xsl:param name="NewLine">1</xsl:param>
  <!--*******************************************
  Template: DoLobTS_NAME
  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
   NewLine: 1 = emit newline if PRETTY is on
  Current node: LOBMD
  **********************************************-->
  <xsl:choose>
   <xsl:when test="$MetaType='Lob' or $MetaType='LobFrag'">
    <xsl:choose>
     <xsl:when test="TS_NAME">
      <xsl:apply-templates select="TS_NAME">
       <xsl:with-param name="NewLine" select="$NewLine"/>
      </xsl:apply-templates>
     </xsl:when>
     <xsl:otherwise>
      <!-- No TS_NAME entry, so put out a cr -->
      <xsl:if test="$PRETTY=1 and $NewLine=1">
       <xsl:text>&#xa;  </xsl:text>
      </xsl:if>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <xsl:otherwise>
    <xsl:choose>
     <xsl:when test="DEFTS_NAME">
      <xsl:apply-templates select="DEFTS_NAME">
       <xsl:with-param name="NewLine" select="$NewLine"/>
      </xsl:apply-templates>
     </xsl:when>
     <xsl:otherwise>
      <!-- No DEFTS_NAME entry, so put out a cr -->
      <xsl:if test="$PRETTY=1 and $NewLine=1">
       <xsl:text>&#xa;  </xsl:text>
      </xsl:if>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="DoSecureFile">
  <xsl:param name="Property" select="''"/>
  <xsl:param name="Parttype">0</xsl:param>
  <xsl:param name="Subpartition">0</xsl:param>
  <!--*******************************************
  Template: DoSecureFile
  param: Property
  Emit SECUREFILE or BASICFILE as necessary
  unless overridden by LOB_STORAGE transform param
    'SECUREFILE' = emit SECUREFILE
    'BASICFILE' = emit SECUREFILE
    'DEFAULT' = suppress keyword and take default
    'NO_CHANGE' = use value in XML document
  Implicit input:
   Transportable - ignore LOB_STORAGE if Transportable=1
  **********************************************-->
  <xsl:if test="$VERSION>=1100000000 ">
   <xsl:choose>
    <xsl:when test="$LOB_STORAGE = 'SECUREFILE' and $Transportable=0">
     <xsl:text>SECUREFILE </xsl:text>
    </xsl:when>
    <xsl:when test="$LOB_STORAGE = 'BASICFILE' and $Transportable=0">
     <xsl:text>BASICFILE </xsl:text>
    </xsl:when>
    <xsl:when test="$LOB_STORAGE = 'DEFAULT' and $Transportable=0"/>
    <xsl:when test="($Property mod 4096)>=2048">
     <xsl:text>SECUREFILE </xsl:text>
    </xsl:when>
    <xsl:otherwise>
     <xsl:text>BASICFILE </xsl:text>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoRetention">
  <xsl:param name="Storage" select="''"/>
  <xsl:param name="DeferredStg" select="''"/>
  <xsl:param name="Property" select="''"/>
  <xsl:param name="Flags" select="''"/>
  <xsl:param name="Retention" select="''"/>
  <xsl:param name="MinTime" select="''"/>
  <!--*******************************************
  Template: DoRetention
  Parameters
       Storage
       DeferredStg
       Property
       Flag
       Retention
       MinTime
  **********************************************-->
  <xsl:choose>
   <xsl:when test="($Property mod 4096)>=2048 and
                             $VERSION>=1100000000">
    <xsl:variable name="LobRet">
     <xsl:choose>
      <xsl:when test="$DeferredStg and $DeferredStg/LOBRET_STG">
       <xsl:value-of select="$DeferredStg/LOBRET_STG"/>
      </xsl:when>
      <xsl:when test="$Storage/LISTS">
       <xsl:value-of select="$Storage/LISTS"/>
      </xsl:when>
      <xsl:otherwise>
       <xsl:value-of select="$Retention"/>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:variable>
    <xsl:variable name="locMinTime">
     <xsl:choose>
      <xsl:when test="$DeferredStg and $DeferredStg/MINTIM_STG">
       <xsl:value-of select="$DeferredStg/MINTIM_STG"/>
      </xsl:when>
      <xsl:when test="$Storage/GROUPS">
       <xsl:value-of select="$Storage/GROUPS"/>
      </xsl:when>
      <xsl:otherwise>
       <xsl:value-of select="$MinTime"/>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:variable>
    <xsl:call-template name="DoSFRETENTION">
     <!-- 11glob: LISTS => RETENTION, GROUPS => MIN RENTENTION TIME -->
     <xsl:with-param name="LobRet" select="$LobRet"/>
     <xsl:with-param name="MinTime" select="$locMinTime"/>
    </xsl:call-template>
   </xsl:when>
   <xsl:when test="($Flags mod 64) >= 32">
    <!-- RETENTION was specified -->
    <!-- Don't output 'RETENTION' if $EXPORT. 
     There is a bad behavior must support.
     If you have one dbms setup with AUM, and want to import this
     database to one without AUM, we currently work because the
     'RETENTION' keyword wasn't specified on export.  This is wrong
     because that means the resulting database will use PCTVERSION, 
     but, we can't change that now.  So, don't output RETENTION if
     $EXPORT, but we also won't output PCTVERSION either.  This
     allows us the possibility of getting retention on the destination
     because RETENTION is the default if AUM is on.-->
    <xsl:if test="$EXPORT=0">
     <xsl:text> RETENTION </xsl:text>
    </xsl:if>
   </xsl:when>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="DoSFRETENTION">
  <!-- *******************************************************************
Template: DoSFRETENTION (SecureFiles ONLY)
Parameters:
 LobRet:   LOB Retention (NONE | AUTO | MIN integer | MAX)
 MinTime:  LOB MIN Retention time
Implicit inputs:
   LOB_STORAGE - BASICFILE = only use basicfile params
                 DEFAULT = omit explicit params; take defaults
   Transportable - ignore LOB_STORAGE if Transportable=1
******************************************************************** -->
  <xsl:param name="LobRet">0</xsl:param>
  <xsl:param name="MinTime">0</xsl:param>
  <xsl:if test="$VERSION>=1100000000 and  ($Transportable=1 or ($LOB_STORAGE != 'BASICFILE' and $LOB_STORAGE != 'DEFAULT'))">
   <xsl:choose>
    <!-- We need the '* 1's below to convert text to int -->
    <!-- RETENTION = NONE -->
    <xsl:when test="$LobRet = 0"> RETENTION NONE</xsl:when>
    <!-- RETENTION = AUTO -->
    <xsl:when test="$LobRet = 1"> RETENTION AUTO</xsl:when>
    <!-- RETENTION = MIN -->
    <xsl:when test="$LobRet = 2">
     <xsl:text> RETENTION MIN </xsl:text>
     <xsl:value-of select="$MinTime"/>
    </xsl:when>
    <!-- RETENTION = MAX -->
    <xsl:when test="$LobRet = 3"> RETENTION MAX</xsl:when>
    <xsl:otherwise>
     <xsl:text/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:if>
 </xsl:template>
</xsl:stylesheet>

OHA YOOOO