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

<?xml version="1.0"?>
<!-- Copyright (c) 2000, 2017, Oracle and/or its affiliates. 
All rights reserved.-->
<!--
NAME
    kucolumn.xsl
DESCRIPTION
    XSLT stylesheet for XML => DDL conversion of ku$_column_list_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
    jjanosik    09/18/17 - Bug 26634972: Do not emit encryption for type 58,
                           121,122 or 123 columns
    tbhukya     06/07/17 - Bug 26173923: Use size as 32K for virtual varchar
                           column when max_string_size is set to extended
    sdavidso    06/07/17 - bug26182702 shard move chunk fails ora-14098
    jjanosik    06/06/17 - Bug 26113870: Put VECTOR ENCODE in its place
    tbhukya     05/17/17 - Bug 26047681: Generate collation for invisible 
                           virtual column
    sdavidso    02/14/17 - bug25440009 handle user name with apostrophe
    jjanosik    01/10/17 - Bug 25356360 - get the encryption clause out before
                           the not null clause and preserve for MVIEWs
    tbhukya     01/13/16 - Bug 25336873: encryption not valid at column level
                                         for varray columns
    tbhukya     01/11/16 - Bug 25335663 - Don't generate row archival hidden col
    jjanosik    12/15/16 - Bug 23856270 - Handle encryption for MView columns
    tbhukya     10/18/16 - Bug 24822718 - Sort with INTCOL_NUM when col list 
                           has invisible column
    jjanosik    09/02/16 - bug 24387072 - fix how/when the collation clause 
                           is output
    tbhukya     08/25/16 - Bug 24285300: Call EncryptAlgo for encryption algo
    tbhukya     08/04/16 - Bug 24313182: Add double quotes to collation name
    geadon      07/05/16 - disable 32k varchar by default in 12.2
    rapayne     01/30/16 - bug 22611512: fix variable Transportable
    tbhukya     09/30/15 - Bug 21886016: Generate collation when
                            max_string_size=extended and version >=12.2
    tbhukya     09/21/15 - Bug 21751519: Don't use REPLACE NULL WITH HEXTORAW 
                           for nullable column and source is 11.2
    tbhukya     06/09/15 - Bug 14696962: Use RAW type for UDT, Varray 
                           unused columns in tts
    tbhukya     09/04/15 - Bug 21492185: Don't generate collate 
                           when OMIT_COL_DATATYPE set
    tbhukya     09/03/15 - Bug 21760912: Support new encryption algorithms
    tbhukya     08/19/15 - Bug 21527254: Generate collate for virtual column
                           in alter stmt
    tbhukya     06/02/15 - Bug 21184350: Generate collate after datatype
    tbhukya     05/20/15 - Bug 21118229: Add collate for virtual column 
    bwright     04/09/15 - Bug 20755241: fix size of exttbl null bit image col
    tbhukya     02/25/15 - Proj 47173: Data bound collation
    cchiappa    02/18/15 - proj 47848: VECTOR ENCODE support
    tbhukya     01/05/15 - Bug 20319428: Declare referred params
    tbhukya     11/06/14 - Bug 19934581: Skip expression with SYS_PATH_REVERSE
    lbarton     08/06/14 - bug 19180774: parse JSON operators
    lbarton     07/02/14 - lrg 12378533: tolerate JSON operators
    sdavidso    03/14/14 - bug18359780: virtual column type incompatible
    sdavidso    03/28/14 - bug18153657: virtual col w/NOT NULL constraint
    lbarton     03/27/14 - bug 18374198: default on null
    lbarton     02/27/14 - bug 18322658: OMIT_COL_DATATYPE
    lbarton     01/02/14 - bug 17943479: REMAP_SCHEMA for virtual cols
    tbhukya     12/04/13 - Bug 13770504: Remove XMLCOL_V10P param check
    lbarton     11/06/13 - bug 17654567: row archival
    bwright     10/18/13 - Bug 17627666: Add COL_SORTKEY for consistent
                           column ordering with stream and exttbl metadata
    rapayne     09/11/13 - Bug 17331430: default on null cols MUST have a 
                           not null constraint regards of constraint filters.
    bwright     08/15/13 - Bug 17312600: Remove hard tabs from DP src code
    tbhukya     06/25/13 - Bug 16210143 : Include invisible columns in TTS mode
    lbarton     04/24/13 - bug 16716831: functional index expression as varchar
                           or clob
    rapayne     03/30/13 - bug 16561657: fix replace null support for ctas tbls
    dgagne      01/31/13 - add NULL_CONSTRAINT
    lbarton     12/19/12 - bug 14202396: implement REMAP_COLUMN_NAME in MODIFY
                           transform
    traney      09/26/12 - unusable before clause for virtual columns
    mjangir     09/19/12 - bug 14363143: unused virtual col in tts import
    traney      08/02/12 - 14407652: evaluation edition
    rapayne     06/22/12 - Nullable col support for transportable mode.
    rapayne     03/13/12 - bug 13849454: INVISIBLE attribute must come before
                           DEFAULT attribute.
    lbarton     02/16/12 - project 37414: ILM support
    rapayne     11/12/11 - project 36780: support for invisible columns
    rapayne     08/21/11 - project 36780: Identity Column support.
    sdavidso    06/07/11 - Bug 12608350 - Wrong precision for TIMESTAMP in ADT
    tbhukya     05/16/11 - Bug 12330372: Exclude M_ROW$$ column
    lbarton     04/19/11 - bug 10186633: virtual column
    ebatbout    04/01/11 - Bug 11934334: Replace getClobVal sql operator with
                           xmlserialize operator
    sdavidso    03/30/11 - support TRANSPORTABLE xml element
    tbhukya     02/21/11 - Bug 10364647: Extension to bug 9846283 fix, exclude
                           virtual column when virtual column is mix of other 
                           properties also for n/w import.
    tbhukya     10/28/10 - Bug 9846283: Exclude virtual column for network 
                           link import.
    ebatbout    12/31/09 - bug 8465341: The element, base_col_type, has a new
                           value of 4 for nested table column.
    sdavidso    12/16/09 - bug 8929002 bad column name for mView
    lbarton     11/13/08 - TSTZ support
    sdavidso    11/05/09 - bug 8477142: constraints and ref partitioning
    ebatbout    10/01/09 - Bug 8819999: Add schema input parameter for
                           SYS_SC_2_XMLT sql operator.
    tbhukya     08/03/09 - Bug 8736866: Add intg algo for encrypted column
    sdavidso    02/27/09 - bug 7567327 - ORA-904 importing xmltype
    sdavidso    01/20/09 - bug 5672035: fix quote handling for
                           remap_column_name
    ebatbout    07/02/08 - Bug 4919556: Change raw(36) to raw('length in col$')
                           since ref's can vary in length.
    spetride    04/21/08 - replace XMLTYPE.CREATEXMLFROMBINARY by SYS_SC_2_XMLT
    ebatbout    01/25/08 - Bug 6021971: Sort Lob columns by intcol_num
    tbhukya     10/03/07 - Bug 6130606: Enable BYTE length semantic for expdp
    mjangir     09/04/07 - bug 5881123: filter mviews hidden cols 
    rapayne     07/23/07 - bug ???: expand type generation.
    lbarton     02/01/07 - IMPORT_CONVENTIONAL
    lbarton     07/09/07 - bug 6005996: suppress unused columns
    jkaloger    06/13/07 - Fix version comparison checks for 11.0
    sdavidso    04/11/07 - avoid export of hierarchy related hidden columns
    lbarton     03/27/07 - bug 5859052: in ext tbls clob cols sort together
    lbarton     07/17/06 - bug 5386908: XMLTYPE_STREAM_FORMAT param 
    lbarton     09/07/06 - lrg 2453260: version compatibility
    lbarton     03/16/06 - bug 45216042: export XMLType as binary 
    htseng      05/31/06 - add column replace null with hextoraw clause 
    htseng      05/18/06 - add virtual columns support 
    lbarton     12/29/05 - REMAP_COLUMN_NAME
    lbarton     11/02/05 - Bug 4715313: reformat files for use with XMLSpy 
    htseng      03/04/05 - bug 4154125: trim the last column with default 
    rapayne     10/12/04 - Bug 3928528: add password to encrypted col desc.
    lbarton     09/16/04 - Bug 3887535: NO SALT in encryption
    lbarton     08/17/04 - lrg1728547/bug 3047454: ADT attr of unused col 
    lbarton     08/05/04 - Bug 3813945: encryption password
    lbarton     07/16/04 - add encryption support 
    htseng      02/26/04 - bug 3369569: exclude hidden column through network 
    lbarton     02/12/04 - Bug 3330599: enhance Trim_string 
    lbarton     09/02/03 - Bug 3113231: ext tbls and unused cols 
    lbarton     08/14/03 - Bug 3047175: TTS and unused cols 
    lbarton     04/28/03 - remove blob_to_ref, ref_to_blob
    lbarton     02/26/03 - emit owner with type synonym
    lbarton     02/10/03 - bugfix: blob_to_opaque should be blob_to_image
    lbarton     02/04/03 - type synonyms
    srseshad    12/06/02 - dtydef values changed for binary_float and
                           binary_double
    lbarton     12/05/02 - new image-blob operators for ext tbl
    htseng      10/01/02 - add SORT support
    htseng      09/26/02 - add floating-point datatypes support
    lbarton     09/24/02 - change spelling of SQL operators
    dgagne      08/27/02 - fix not null constraints
    lbarton     08/09/02 - transportable export
    lbarton     07/25/02 - hidden snapshot base table column
    lbarton     06/03/02 - data layer and network support
    htseng      10/12/01 - add trim_string.
    lbarton     06/01/01 - remove oradb-style imports
    lbarton     10/24/00 - sort in views, not xsl
    lbarton     10/13/00 - bugfix: NOT NULL constraints on adt and ref cols
    gclaborn    10/30/00 - Add external imports; change name
    lbarton     10/10/00 - bugfix: distinguish NCLOB from CLOB
    lbarton     09/25/00 - codepoint semantics
    lbarton     09/21/00 - bugfix: use SPARE3 for NCHAR length
    lbarton     08/18/00 - logical standby support
    lbarton     07/24/00 - use uriref in import
    lbarton     06/23/00 - TIMESTAMP, INTERVAL
    lbarton     05/15/00 - Params for new API
    lbarton     03/17/00 - Add module header
 -->
<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="kuconstr.xsl"/>
 <xsl:import href="kuseq.xsl"/>
 <xsl:import href="kusparsdx.xsl"/>
 <xsl:param name="OPERATION_TYPE" select="''"/>
 <xsl:param name="XMLTYPE_STREAM_FORMAT" select="''"/>
 <xsl:param name="CONVERT_TSTZ_COLS">0</xsl:param>
 <xsl:param name="FORCE_VIRTUAL_COLUMNS">0</xsl:param>
 <xsl:param name="CONSTRAINTS">1</xsl:param>
 <xsl:param name="NULL_CONSTRAINTS">1</xsl:param>
 <xsl:param name="ENCRYPTION_PASSWORD" select="''"/>
 <xsl:param name="SIZE_BYTE_KEYWORD">0</xsl:param>
 <xsl:param name="TRANSPORTABLE">0</xsl:param>
 <xsl:param name="EXPORT">0</xsl:param>
 <xsl:param name="MAX_STRING_EXTENDED">0</xsl:param>
 <!-- Determine whether this is a transportable mode convert.
      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 
              not(/ROWSET/ROW/TABLE_T/VIEW_AS_TABLE) and 
              .//TRANSPORTABLE="1"'>1</xsl:when>
   <xsl:otherwise>0</xsl:otherwise>
  </xsl:choose>
 </xsl:variable>
 <xsl:param name="SOURCE_VERSION">1000000000</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="COL_LIST">
  <xsl:param name="ADT_type">TABLE</xsl:param>
  <xsl:param name="DoLF">1</xsl:param>
  <xsl:param name="DoHidden">0</xsl:param>
  <xsl:param name="DoREMAP">0</xsl:param>
  <xsl:param name="InColDef">0</xsl:param>
  <xsl:param name="Network">0</xsl:param>
  <xsl:param name="Prefix" select="''"/>
  <xsl:param name="ExtTbl">0</xsl:param>
  <xsl:param name="ExtTblOps">0</xsl:param>
  <xsl:param name="ExtTblEncrypt">0</xsl:param>
  <xsl:param name="Mview">0</xsl:param>
  <xsl:param name="Partobj"/>
  <!-- *******************************************************************
Template: COL_LIST - process a COL_LIST and its members
Parameters:
  ADT_type  - Object type
               'TABLE' - table objects (full column attributes)
               'INDEX' - index (and other) objects (col name only)
  DoLF      - 1 = emit a line feed between columns (if PRETTY=1)
  DoHidden  - 0 = exclude hidden columns
              non-0 = include hidden columns
  DoREMAP   - 0 = don't remap column names
              non-0 = okay to remap column names
  InColDef  - 1 = we are in the context of defining a column 
  Network   - 1 = NETWORK operation (INSERT into tbl SELECT from remote tbl)
  Prefix    - value of a prefix (e.g., "C1_REC.") to append to the
               column name
  ExtTbl    - for ADT_type='TABLE', what kind of operation
               0 = normal CREATE table
               1 = EXPORT, i.e., External Table unload
               2 = IMPORT, i.e., External Table load
               3 = IMPORT_CONVENTIONAL select statement
               4 = IMPORT_CONVENTIONAL import statement column names
               5 = IMPORT_CONVENTIONAL import statement values clause
                   (3-5 for conventional path load)
  ExtTblOps - do/don't use the special sql operators for external tables
              e.g., SYS_ET_BFILE_TO_RAW.
               0 = don't use
               non-0 = do use
  ExtTblEncrypt - do/don't use the ENCRYPT keyword for encrypted columns
              when ExtTbl !=0
               0 = don't use
               non-0 = do use
  Mview        1 = generate column list for materialized view
  Partobj      - PART_OBJ element if it exists
******************************************************************** -->
  <xsl:choose>
   <!-- ExtTbl=1 - External table export/import; should not come through here
    -->
   <xsl:when test="$ExtTbl>0"> ** ERROR ** </xsl:when>
   <!-- Special rules for TRANSPORTABLE:
        exclude hidden columns                            - prop bit 0x000020
        but do include unused column (data in row)        - prop bit 0x008000
          that is not virtual column                      - prop bit 0x000008
        and do include hidden snapshot base table column  - prop bit 0x100000
        and for version >=12 do include
            Nullable column                               - prop2 bit 0x000080
            and invisible column                          - prop2 bit 0x000004
        and do include RLS hidden column                  - prop bit 0x400000
               If it is not a row archival hidden column  - prop2 bit 0x000200

        Bug 14363143: duplicate segcol# issue after TTS import and that
        caused by unsed virtual col. so skiping this in tts mode. Other soln 
        to handle this as creating the col as virtual and mark unused later.
        but can't have duplicate expressions among virtual column expression.

        Bug 14696962: Unused column attributes were included in the DDL to match
        dictionary metadata and later they marked as UNUSED.
     -->
   <xsl:when test="$Transportable!=0">
    <xsl:for-each select="COL_LIST_ITEM[(PROPERTY mod 64)&lt;32
                                     or ( (PROPERTY mod 65536)>=32768
                                      and (PROPERTY mod 16)&lt;8)
                                     or (PROPERTY mod 2097152)>=1048576
                                     or ($VERSION>=1200000000  and  
                                                ((PROPERTY2 mod 256)>=128) or
                                                ((PROPERTY2 mod 8)=4))
                                     or ((PROPERTY mod 8388608)>=4194304 and
                                         (PROPERTY2 mod 1024)&lt;512)]">
     <xsl:sort select="INTCOL_NUM" data-type="number"/>
     <xsl:call-template name="DoCOL_LIST_ITEM">
      <xsl:with-param name="ADT_type" select="$ADT_type"/>
      <xsl:with-param name="DoLF" select="$DoLF"/>
      <xsl:with-param name="DoREMAP" select="$DoREMAP"/>
      <xsl:with-param name="Network" select="$Network"/>
      <xsl:with-param name="Prefix" select="$Prefix"/>
      <xsl:with-param name="Partobj" select="$Partobj"/>
     </xsl:call-template>
    </xsl:for-each>
   </xsl:when>
   <!-- exclude hidden columns                            - prop bit 0x000020
        when through Network
        bug 3369569
        also exclude virtual columns             - prop bit 0x010000 and 0x0008
        Bug 17654567: do not exclude ILM columns - PROPERTY2 bit 0x200
     -->
   <!-- Bug 12330372: Exclude M_ROW$$ column for 10g import as M_ROW$$ is 
                      hidden column and gets created with MV -->
   <xsl:when test="$Network=1">
    <xsl:for-each select="COL_LIST_ITEM[(((PROPERTY mod 64)&lt;32 or
                                          (PROPERTY2 mod 1024)>=512) and
                                       not((PROPERTY mod 16)>=8 and
                                           (PROPERTY mod 1048576)>=65536) and
                                       not(NAME='M_ROW$$' and 
                                           $VERSION&lt;1100000000)) or 
                                       (PROPERTY2 mod 8)=4]">
     <!--xsl:sort select="COL_NUM" data-type="number"/-->
     <xsl:call-template name="DoCOL_LIST_ITEM">
      <xsl:with-param name="ADT_type" select="$ADT_type"/>
      <xsl:with-param name="DoLF" select="$DoLF"/>
      <xsl:with-param name="DoREMAP" select="$DoREMAP"/>
      <xsl:with-param name="Network" select="$Network"/>
      <xsl:with-param name="Prefix" select="$Prefix"/>
      <xsl:with-param name="Partobj" select="$Partobj"/>
     </xsl:call-template>
    </xsl:for-each>
   </xsl:when>
   <!--  
        always exclude unused columns                     - prop bit 0x008000  32768
        also exclude hidden columns                       - prop bit 0x000020  00032
        (but do include hidden snapshot base table column - prop bit 0x100000  1048576
         and do include RLS hidden column                 - prop bit 0x800000)  
                If it is not a row archival hidden column - prop2 bit 0x000200
         and virtual columns that is not                  - prop bit 0x010000
             system-generated column                      - prop bit 0x000100)
        include user specified invisible cols             - prop2 bit 0x000100)    4
     -->
   <xsl:otherwise>
    <xsl:variable name="ColSelList" select="COL_LIST_ITEM[$DoHidden=1 or
                                      (((PROPERTY mod 65536)&lt;32768) and
                                       ((PROPERTY mod 64)      &lt; 32 or
                                        (PROPERTY2 mod 8) =4 or
                                        (PROPERTY mod 2097152) >=   1048576 or
                                        ((PROPERTY mod 8388608) >=   4194304 and
                                         (PROPERTY2 mod 1024)&lt;512) ) and
                                       (PROPERTY!=1048608 or $Mview=0))]"/>
    <xsl:choose>
     <!-- Bug 24822718: Sort with INTCOL_NUM when col list has invisible and 
                       hidden column. Invisible column has zero value for 
                       COL_NUM and to generate correct column order, 
                       sort with INTCOL_NUM is needed.
      -->
     <xsl:when test="($ColSelList/PROPERTY mod 64) >= 32 and 
                     ($ColSelList/PROPERTY2 mod 8) >= 4">
      <xsl:for-each select="$ColSelList">
       <xsl:sort select="INTCOL_NUM" data-type="number"/>
       <xsl:call-template name="DoCOL_LIST_ITEM">
        <xsl:with-param name="ADT_type" select="$ADT_type"/>
        <xsl:with-param name="DoLF" select="$DoLF"/>
        <xsl:with-param name="DoREMAP" select="$DoREMAP"/>
        <xsl:with-param name="InColDef" select="$InColDef"/>
        <xsl:with-param name="Network" select="$Network"/>
        <xsl:with-param name="Prefix" select="$Prefix"/>
        <xsl:with-param name="Partobj" select="$Partobj"/>
       </xsl:call-template>
      </xsl:for-each>
     </xsl:when>
     <xsl:otherwise>
      <xsl:for-each select="$ColSelList">
       <!-- xsl:sort select="COL_NUM" data-type="number"/ -->
       <xsl:call-template name="DoCOL_LIST_ITEM">
        <xsl:with-param name="ADT_type" select="$ADT_type"/>
        <xsl:with-param name="DoLF" select="$DoLF"/>
        <xsl:with-param name="DoREMAP" select="$DoREMAP"/>
        <xsl:with-param name="InColDef" select="$InColDef"/>
        <xsl:with-param name="Network" select="$Network"/>
        <xsl:with-param name="Prefix" select="$Prefix"/>
        <xsl:with-param name="Partobj" select="$Partobj"/>
       </xsl:call-template>
      </xsl:for-each>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="DoExtTblCOL_LIST">
  <xsl:param name="Scalars" select="''"/>
  <xsl:param name="Lobs" select="''"/>
  <xsl:param name="Longs" select="''"/>
  <xsl:param name="ADT_type">TABLE</xsl:param>
  <xsl:param name="DoLF">1</xsl:param>
  <xsl:param name="DoHidden">0</xsl:param>
  <xsl:param name="DoREMAP">0</xsl:param>
  <xsl:param name="Network">0</xsl:param>
  <xsl:param name="Prefix" select="''"/>
  <xsl:param name="ExtTbl">0</xsl:param>
  <xsl:param name="ExtTblOps">0</xsl:param>
  <xsl:param name="ExtTblEncrypt">0</xsl:param>
  <!-- *******************************************************************
Template: DoExtTblCOL_LIST - process a COL_LIST and its members
  for external table export or import
Parameters:
  Scalars   - the node set of scalar COL_LIST_ITEM elements
  Lobs      - the node set of lob COL_LIST_ITEM elements
  Longs     - the node set of long COL_LIST_ITEM elements
  ADT_type  - Object type
               'TABLE' - table objects (full column attributes)
               'INDEX' - index (and other) objects (col name only)
  DoLF      - 1 = emit a line feed between columns (if PRETTY=1)
  DoHidden  - 0 = exclude hidden columns
              non-0 = include hidden columns
  DoREMAP   - 0 = don't remap column names
              non-0 = okay to remap column names
  Network   - 1 = NETWORK operation (INSERT into tbl SELECT from remote tbl)
  Prefix    - value of a prefix (e.g., "C1_REC.") to append to the
               column name
  ExtTbl    - for ADT_type='TABLE', what kind of operation
               1 = EXPORT, i.e., External Table unload
               2 = IMPORT, i.e., External Table load
               3 = IMPORT_CONVENTIONAL select statement
               4 = IMPORT_CONVENTIONAL import statement column names
               5 = IMPORT_CONVENTIONAL import statement values clause
                   (3-5 for conventional path load)
  ExtTblOps - do/don't use the special sql operators for external tables
              e.g., SYS_ET_BFILE_TO_RAW.
               0 = don't use
               non-0 = do use
  ExtTblEncrypt - do/don't use the ENCRYPT keyword for encrypted columns
              when ExtTbl !=0
               0 = don't use
               non-0 = do use
Notes:
   Columns in segcol order EXCEPT
      columns that form the expansion of an XMLType stored relationally
       are omitted
      LOBs (or anything that can be stored as a lob such as varrays
       or opaques) are moved to the end but remain in segcol order
       Schema-based and binary XMLType columns are exported in self-
       describing binary as a BLOB, but they sort with all the other LOBs.
      LONGs come last no matter what
   in addition:
       exclude unused columns                            - prop bit 0x008000

       type_num 112 = CLOB
                113 = BLOB
                123 = VARRAY
                 58 = OPAQUE
                  8 = LONG
                 24 = LONG RAW
  base_col_type   1 = UDT
                  2 = XMLType stored OR or CSX
                  3 = XMLType stored as CLOB
                  4 = nested table
                  0 = other
******************************************************************** -->
  <!-- First emit safe scalar types: not lobs, not columns that
       are part of an XMLType stored relationally.
-->
  <xsl:for-each select="$Scalars">
   <xsl:sort select="SEGCOL_NUM" data-type="number"/>
   <xsl:call-template name="DoCOL_LIST_ITEM">
    <xsl:with-param name="ADT_type" select="$ADT_type"/>
    <xsl:with-param name="DoLF" select="$DoLF"/>
    <xsl:with-param name="DoREMAP" select="$DoREMAP"/>
    <xsl:with-param name="Network" select="$Network"/>
    <xsl:with-param name="Prefix" select="$Prefix"/>
    <xsl:with-param name="ExtTbl" select="$ExtTbl"/>
    <xsl:with-param name="ExtTblOps" select="$ExtTblOps"/>
    <xsl:with-param name="ExtTblEncrypt" select="$ExtTblEncrypt"/>
    <xsl:with-param name="Pos" select="position()"/>
   </xsl:call-template>
  </xsl:for-each>
  <!-- now a comma (maybe): if we did any non-lob cols...
       and now we have some lob cols... -->
  <xsl:if test="count($Scalars)>0 and count($Lobs)>0">
   <!-- ... then insert a comma between the last non-lob col
               and the first lob col -->
   <xsl:call-template name="EmitCommaLF">
    <xsl:with-param name="DoLF" select="$DoLF"/>
   </xsl:call-template>
  </xsl:if>
  <!-- LOBs (or anything that can be stored as a lob such as varrays
       or opaques, including schema-based and binary XMLType columns
       are exported in self-describing binary as a BLOB).  We must sort
       by a new-for-12.1.0.2 field, COL_SORTKEY, if it exists. This is 
       essentially the column's segcol# for all non-XMLTYPE lob columns.
       For an XMLTYPE column stored as a lob, it is the segcol# of the 
       hidden column containing the actual XMLTYPE's lob.  Columns are
       meant to be written to the dump file in segcol# order within the 
       scalar, lob, and long 'bucket's of columns.  The txn for bug 6021971 
       changed this, which caused inconsistent ordering of lob columns 
       between external tables and direct_path.  We rectify this here. -->
  <xsl:choose>
   <xsl:when test="$Lobs[COL_SORTKEY]">
    <xsl:for-each select="$Lobs">
     <xsl:sort select="COL_SORTKEY" data-type="number"/>
     <xsl:call-template name="DoCOL_LIST_ITEM">
      <xsl:with-param name="ADT_type" select="$ADT_type"/>
      <xsl:with-param name="DoLF" select="$DoLF"/>
      <xsl:with-param name="DoREMAP" select="$DoREMAP"/>
      <xsl:with-param name="Network" select="$Network"/>
      <xsl:with-param name="Prefix" select="$Prefix"/>
      <xsl:with-param name="ExtTbl" select="$ExtTbl"/>
      <xsl:with-param name="ExtTblOps" select="$ExtTblOps"/>
      <xsl:with-param name="ExtTblEncrypt" select="$ExtTblEncrypt"/>
      <xsl:with-param name="Pos" select="count($Scalars)+position()"/>
     </xsl:call-template>
    </xsl:for-each>
   </xsl:when>
   <xsl:otherwise>
    <xsl:for-each select="$Lobs">
     <xsl:sort select="SEGCOL_NUM" data-type="number"/>
     <xsl:call-template name="DoCOL_LIST_ITEM">
      <xsl:with-param name="ADT_type" select="$ADT_type"/>
      <xsl:with-param name="DoLF" select="$DoLF"/>
      <xsl:with-param name="DoREMAP" select="$DoREMAP"/>
      <xsl:with-param name="Network" select="$Network"/>
      <xsl:with-param name="Prefix" select="$Prefix"/>
      <xsl:with-param name="ExtTbl" select="$ExtTbl"/>
      <xsl:with-param name="ExtTblOps" select="$ExtTblOps"/>
      <xsl:with-param name="ExtTblEncrypt" select="$ExtTblEncrypt"/>
      <xsl:with-param name="Pos" select="count($Scalars)+position()"/>
     </xsl:call-template>
    </xsl:for-each>
   </xsl:otherwise>
  </xsl:choose>
  <!-- now a comma (maybe) -->
  <xsl:if test="(count($Scalars)+count($Lobs))>0 and count($Longs)>0">
   <xsl:call-template name="EmitCommaLF">
    <xsl:with-param name="DoLF" select="$DoLF"/>
   </xsl:call-template>
  </xsl:if>
  <!-- now LONGs (of which there can be at most 1 but, hey, whatever) -->
  <xsl:for-each select="$Longs">
   <xsl:sort select="SEGCOL_NUM" data-type="number"/>
   <xsl:call-template name="DoCOL_LIST_ITEM">
    <xsl:with-param name="ADT_type" select="$ADT_type"/>
    <xsl:with-param name="DoLF" select="$DoLF"/>
    <xsl:with-param name="DoREMAP" select="$DoREMAP"/>
    <xsl:with-param name="Network" select="$Network"/>
    <xsl:with-param name="Prefix" select="$Prefix"/>
    <xsl:with-param name="ExtTbl" select="$ExtTbl"/>
    <xsl:with-param name="ExtTblOps" select="$ExtTblOps"/>
    <xsl:with-param name="ExtTblEncrypt" select="$ExtTblEncrypt"/>
    <xsl:with-param name="Pos" select="count($Scalars)+count($Lobs)+position()"/>
   </xsl:call-template>
  </xsl:for-each>
 </xsl:template>
 <xsl:template name="DoCOL_LIST_ITEM">
  <xsl:param name="ADT_type">TABLE</xsl:param>
  <xsl:param name="DoLF">1</xsl:param>
  <xsl:param name="DoREMAP">0</xsl:param>
  <xsl:param name="InColDef">0</xsl:param>
  <xsl:param name="Network">0</xsl:param>
  <xsl:param name="Prefix" select="''"/>
  <xsl:param name="ExtTbl">0</xsl:param>
  <xsl:param name="ExtTblOps">0</xsl:param>
  <xsl:param name="ExtTblEncrypt">0</xsl:param>
  <xsl:param name="Pos">0</xsl:param>
  <xsl:param name="Partobj"/>
  <xsl:param name="Virtcol">0</xsl:param>
  <!-- *******************************************************************
Template: DoCOL_LIST_ITEM - process a COL_LIST_ITEM
Parameters:
  ADT_type  - Object type
               'TABLE' - table objects (full column attributes)
               'INDEX' - index (and other) objects (col name only)
  DoLF      - 1 = emit a line feed between columns (if PRETTY=1)
  DoREMAP   - 0 = don't remap column names
              non-0 = okay to remap column names
  InColDef  - 1 = we are in the context of defining a column 
  Network   - 1 = NETWORK operation (INSERT into tbl SELECT from remote tbl)
  Prefix    - value of a prefix (e.g., "C1_REC.") to append to the
               column name
  ExtTbl    - for ADT_type='TABLE', what kind of operation
               0 = normal CREATE table
               1 = EXPORT, i.e., External Table unload
               2 = IMPORT, i.e., External Table load
               3 = IMPORT_CONVENTIONAL select statement (column name only)
               4 = IMPORT_CONVENTIONAL import statement column names
                     (column name only)
               5 = IMPORT_CONVENTIONAL import statement values clause
                     (bind variable plus optional sql operator)
                   (3-5 for conventional path load)
  ExtTblOps - do/don't use the special sql operators for external tables
              e.g., SYS_ET_BFILE_TO_RAW.
               0 = don't use
               non-0 = do use
  ExtTblEncrypt - do/don't use the ENCRYPT keyword for encrypted columns
              when ExtTbl !=0
               0 = don't use
               non-0 = do use
  Pos        - 1-based position of item
  Partobj      - PART_OBJ element if it exists
  Virtcol      non-0 = ALTER TABLE MODIFY to restore virtual column definition
******************************************************************** -->
  <xsl:call-template name="DoCOL">
   <xsl:with-param name="ADT_type" select="$ADT_type"/>
   <xsl:with-param name="DoLF" select="$DoLF"/>
   <xsl:with-param name="DoREMAP" select="$DoREMAP"/>
   <xsl:with-param name="InColDef" select="$InColDef"/>
   <xsl:with-param name="Network" select="$Network"/>
   <xsl:with-param name="Prefix" select="$Prefix"/>
   <xsl:with-param name="ExtTbl" select="$ExtTbl"/>
   <xsl:with-param name="ExtTblOps" select="$ExtTblOps"/>
   <xsl:with-param name="ExtTblEncrypt" select="$ExtTblEncrypt"/>
   <xsl:with-param name="Pos" select="$Pos"/>
   <xsl:with-param name="Partobj" select="$Partobj"/>
   <xsl:with-param name="Virtcol" select="$Virtcol"/>
  </xsl:call-template>
  <!-- Put out a comma / LF if not the last col -->
  <xsl:if test="not(position()=last())">
   <xsl:call-template name="EmitCommaLF">
    <xsl:with-param name="DoLF" select="$DoLF"/>
   </xsl:call-template>
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoIdentityColumn">
  <xsl:param name="ColumnNode" select="''"/>
  <xsl:param name="Property" select="''"/>
  <xsl:param name="LimitValue">0</xsl:param>
  <!-- *******************************************************************
Template: DoIdentityColumn - work routine for generating attributes for 
              Identity column. 
Note: the assumption is that the current col IS an identity column
Parameters: 
    ColumnNode - IDENTITY_COLUMN
    Property   -
    LimitValue - flag for generating LIMIT VALUE rather than start with 
       syntax.
******************************************************************** -->
  <!-- generate column attributes -->
  <xsl:text> GENERATED </xsl:text>
  <xsl:choose>
   <xsl:when test="($ColumnNode/PROPERTY2  mod 128) >= 64">
    <xsl:text>BY DEFAULT</xsl:text>
    <xsl:if test="($ColumnNode/PROPERTY2 mod 32) >= 16">
     <xsl:text> ON NULL</xsl:text>
    </xsl:if>
   </xsl:when>
   <xsl:otherwise>
    <xsl:text>ALWAYS</xsl:text>
   </xsl:otherwise>
  </xsl:choose>
  <xsl:text> AS IDENTITY</xsl:text>
  <xsl:call-template name="SeqOptions">
   <xsl:with-param name="ParentNode" select="$ColumnNode/SEQUENCE"/>
   <xsl:with-param name="StartWith" select="$ColumnNode/START_WITH"/>
   <xsl:with-param name="LimitValue" select="$LimitValue"/>
  </xsl:call-template>
 </xsl:template>
 <xsl:template name="DoCOL">
  <xsl:param name="ADT_type">TABLE</xsl:param>
  <xsl:param name="DoLF">1</xsl:param>
  <xsl:param name="DoREMAP">0</xsl:param>
  <xsl:param name="InColDef">0</xsl:param>
  <xsl:param name="Network">0</xsl:param>
  <xsl:param name="Prefix" select="''"/>
  <xsl:param name="ExtTbl">0</xsl:param>
  <xsl:param name="ExtTblOps">0</xsl:param>
  <xsl:param name="ExtTblEncrypt">0</xsl:param>
  <xsl:param name="Pos">0</xsl:param>
  <xsl:param name="Partobj"/>
  <xsl:param name="Virtcol">0</xsl:param>
  <!-- *******************************************************************
Template: DoCOL - work routine for DoCOL_LIST_ITEM
Parameters: see above
******************************************************************** -->
  <xsl:if test="$PRETTY=1 and $DoLF=1">
   <xsl:text>&#x9;</xsl:text>
  </xsl:if>
  <xsl:if test="string-length($Prefix)!=0">
   <xsl:value-of select="$Prefix"/>
  </xsl:if>
  <!--    Type num      Datatype        Comment
           ========     ========        =======
                114     BFILE
                  8     LONG            Import is direct path only
                 24     LONG RAW        Import is direct path only
                 58     OPAQUE
                112     character lob   10.x support of xmltype stored as clob
                123     VARRAY
                181     TIMESTAMP WITH TIME ZONE
        -->
  <xsl:if test="($ExtTbl=1 or $ExtTbl=2 or $ExtTbl=5) and $ExtTblOps!=0 and
          $ADT_type!='TABLE' and
          (TYPE_NUM=114 or
           TYPE_NUM=8 or
           TYPE_NUM=24 or
           TYPE_NUM=58 or
           TYPE_NUM=112 or
           TYPE_NUM=123 or
           TYPE_NUM=181)">
   <xsl:choose>
    <xsl:when test="$OPERATION_TYPE='EXPORT'">
     <xsl:choose>
      <xsl:when test="TYPE_NUM=114">SYS_ET_BFILE_TO_RAW(</xsl:when>
      <xsl:when test="TYPE_NUM=8">TO_LOB(</xsl:when>
      <xsl:when test="TYPE_NUM=24">TO_LOB(</xsl:when>
      <xsl:when test="TYPE_NUM=58">
       <xsl:choose>
        <xsl:when test="OPQMD/TYPE=1">
         <!-- XMLType -->
         <xsl:choose>
          <!-- flags 64  = binary XML
                         2  = schema based
                         4  = store as lob
         -->
          <xsl:when test="$XMLTYPE_STREAM_FORMAT='BLOB'">SYS_XMLT_2_SC(</xsl:when>
          <xsl:when test="$XMLTYPE_STREAM_FORMAT='CLOB'">xmlserialize(DOCUMENT </xsl:when>
          <xsl:when test="(OPQMD/FLAGS mod 128)>=64">SYS_XMLT_2_SC(</xsl:when>
          <xsl:when test="(OPQMD/FLAGS mod 4)>=2">SYS_XMLT_2_SC(</xsl:when>
          <xsl:when test="(OPQMD/FLAGS mod 8)>=4">xmlserialize(DOCUMENT </xsl:when>
         </xsl:choose>
        </xsl:when>
        <!-- not XMLType -->
        <xsl:otherwise>SYS_ET_IMAGE_TO_BLOB(SYS_OP_ITR(</xsl:otherwise>
       </xsl:choose>
      </xsl:when>
      <xsl:when test="TYPE_NUM=123">SYS_ET_IMAGE_TO_BLOB(</xsl:when>
     </xsl:choose>
    </xsl:when>
    <xsl:when test="$OPERATION_TYPE='IMPORT' or
                    $OPERATION_TYPE='IMPORT_CONVENTIONAL'">
     <xsl:choose>
      <xsl:when test="TYPE_NUM=114">SYS_ET_RAW_TO_BFILE(</xsl:when>
      <xsl:when test="TYPE_NUM=8 and $OPERATION_TYPE='IMPORT'">*** ERROR *** </xsl:when>
      <xsl:when test="TYPE_NUM=24 and $OPERATION_TYPE='IMPORT'">*** ERROR *** </xsl:when>
      <xsl:when test="TYPE_NUM=58">
       <xsl:choose>
        <xsl:when test="OPQMD/TYPE=1">
         <!-- XMLType -->
         <xsl:choose>
          <!-- flags 64  = binary XML
                         2  = schema based
                         4  = store as lob
         -->
          <xsl:when test="$XMLTYPE_STREAM_FORMAT='BLOB'">SYS_SC_2_XMLT(</xsl:when>
          <xsl:when test="$XMLTYPE_STREAM_FORMAT='CLOB'">SYS.XMLTYPE.CREATEXML(</xsl:when>
          <xsl:when test="(OPQMD/FLAGS mod 128)>=64">SYS_SC_2_XMLT(</xsl:when>
          <xsl:when test="(OPQMD/FLAGS mod 4)>=2">SYS_SC_2_XMLT(</xsl:when>
          <xsl:when test="(OPQMD/FLAGS mod 8)>=4">SYS.XMLTYPE.CREATEXML(</xsl:when>
         </xsl:choose>
        </xsl:when>
        <!-- not XMLType -->
        <xsl:otherwise>SYS_OP_ITR(SYS_ET_BLOB_TO_IMAGE(</xsl:otherwise>
       </xsl:choose>
      </xsl:when>
      <!-- CLOB column with base_col_type=3 will only occur for 10.x import.
           On 11.1 and later, xmltype import is as type=58 -->
      <xsl:when test="TYPE_NUM=112 and BASE_COL_TYPE=3">
       <xsl:text>SYS.XMLTYPE.CREATEXML(</xsl:text>
      </xsl:when>
      <xsl:when test="TYPE_NUM=123">
       <xsl:if test="$CONVERT_TSTZ_COLS='1' and TYPEMD/HAS_TSTZ='Y'">ORA_DST_CONVERT(</xsl:if>
       <xsl:text>SYS_ET_BLOB_TO_IMAGE(</xsl:text>
      </xsl:when>
      <xsl:when test="TYPE_NUM=123">SYS_ET_BLOB_TO_IMAGE(</xsl:when>
      <xsl:when test="TYPE_NUM=181 and $CONVERT_TSTZ_COLS='1'">ORA_DST_CONVERT(</xsl:when>
     </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
     <xsl:text>***ERROR: UNEXPECTED OPERATION_TYPE: </xsl:text>
     <xsl:value-of select="$OPERATION_TYPE"/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:if>
  <xsl:choose>
   <xsl:when test="$ExtTbl=5">
    <!-- build bind variable from position -->
    <xsl:text>:</xsl:text>
    <xsl:value-of select="$Pos"/>
   </xsl:when>
   <!-- For xmltype store as CLOB, in 10.x import - we insert into 
        the xmltype column (as the name of the clob column is system 
        generated and may have changed) -->
   <xsl:when test="$ExtTbl>=2 and BASE_COL_NAME and BASE_COL_TYPE and
             ( BASE_COL_TYPE=2 or BASE_COL_TYPE=3)">
    <xsl:text>"</xsl:text>
    <xsl:value-of select="BASE_COL_NAME"/>
    <xsl:text>"</xsl:text>
   </xsl:when>
   <xsl:otherwise>
    <xsl:call-template name="DoColName">
     <xsl:with-param name="DoREMAP" select="$DoREMAP"/>
     <xsl:with-param name="ExtTbl" select="$ExtTbl"/>
     <xsl:with-param name="InColDef" select="$InColDef"/>
    </xsl:call-template>
   </xsl:otherwise>
  </xsl:choose>
  <xsl:if test="($ExtTbl=1 or $ExtTbl=2 or $ExtTbl=5) and $ExtTblOps!=0 and
          $ADT_type!='TABLE' and
          (TYPE_NUM=114 or
           TYPE_NUM=8 or
           TYPE_NUM=24 or
           TYPE_NUM=58 or
           (TYPE_NUM=112 and $ExtTbl>=2) or
           TYPE_NUM=123 or
           TYPE_NUM=181)">
   <xsl:choose>
    <xsl:when test="TYPE_NUM=114 or
                    (TYPE_NUM=112 and BASE_COL_TYPE=3)">)</xsl:when>
    <xsl:when test="TYPE_NUM=8 or TYPE_NUM=24">
     <xsl:if test="$OPERATION_TYPE!='IMPORT_CONVENTIONAL'">)</xsl:if>
    </xsl:when>
    <xsl:when test="TYPE_NUM=58">
     <xsl:choose>
      <xsl:when test="$OPERATION_TYPE='EXPORT'">
       <xsl:choose>
        <xsl:when test="OPQMD/TYPE=1">
         <!-- XMLType -->
         <xsl:choose>
          <!-- flags 64  = binary XML
                         2  = schema based
                         4  = store as lob
         -->
          <xsl:when test="$XMLTYPE_STREAM_FORMAT='BLOB'">)</xsl:when>
          <xsl:when test="$XMLTYPE_STREAM_FORMAT='CLOB'"> AS CLOB) </xsl:when>
          <xsl:when test="(OPQMD/FLAGS mod 128)>=64">)</xsl:when>
          <xsl:when test="(OPQMD/FLAGS mod 4)>=2">)</xsl:when>
          <xsl:when test="(OPQMD/FLAGS mod 2)>=1">)</xsl:when>
          <xsl:when test="(OPQMD/FLAGS mod 8)>=4"> AS CLOB) </xsl:when>
         </xsl:choose>
        </xsl:when>
        <!-- not XMLType -->
        <xsl:otherwise>,1))</xsl:otherwise>
       </xsl:choose>
      </xsl:when>
      <xsl:when test="$OPERATION_TYPE='IMPORT' or
                      $OPERATION_TYPE='IMPORT_CONVENTIONAL'">
       <xsl:choose>
        <xsl:when test="OPQMD/TYPE=1">
         <!-- XMLType -->
         <xsl:choose>
          <!-- flags 64  = binary XML
                         2  = schema based
                         4  = store as lob
         -->
          <xsl:when test="$XMLTYPE_STREAM_FORMAT='BLOB'">
           <xsl:text>,'"</xsl:text>
           <xsl:call-template name="EnQuote">
            <xsl:with-param name="String" select="../../SCHEMA_OBJ/OWNER_NAME"/>
           </xsl:call-template>
           <xsl:text>"')</xsl:text>
          </xsl:when>
          <xsl:when test="$XMLTYPE_STREAM_FORMAT='CLOB'">)</xsl:when>
          <xsl:when test="(OPQMD/FLAGS mod 128)>=64">)</xsl:when>
          <xsl:when test="(OPQMD/FLAGS mod 4)>=2">
           <xsl:text>,'"</xsl:text>
           <xsl:call-template name="EnQuote">
            <xsl:with-param name="String" select="../../SCHEMA_OBJ/OWNER_NAME"/>
           </xsl:call-template>
           <xsl:text>"')</xsl:text>
          </xsl:when>
          <xsl:when test="(OPQMD/FLAGS mod 8)>=4">)</xsl:when>
         </xsl:choose>
        </xsl:when>
        <!-- not XMLType -->
        <xsl:otherwise>
         <xsl:text>,'</xsl:text>
         <xsl:call-template name="EnQuote">
          <xsl:with-param name="String" select="TYPEMD/SCHEMA_OBJ/NAME"/>
         </xsl:call-template>
         <xsl:text>','</xsl:text>
         <xsl:call-template name="EnQuote">
          <xsl:with-param name="String" select="TYPEMD/SCHEMA_OBJ/OWNER_NAME"/>
         </xsl:call-template>
         <xsl:text>'),0)</xsl:text>
        </xsl:otherwise>
       </xsl:choose>
      </xsl:when>
     </xsl:choose>
    </xsl:when>
    <xsl:when test="TYPE_NUM=123">
     <xsl:choose>
      <xsl:when test="$OPERATION_TYPE='EXPORT'">)</xsl:when>
      <xsl:when test="$OPERATION_TYPE='IMPORT' or
                      $OPERATION_TYPE='IMPORT_CONVENTIONAL'">
       <xsl:text>,'</xsl:text>
       <xsl:call-template name="EnQuote">
        <xsl:with-param name="String" select="TYPEMD/SCHEMA_OBJ/NAME"/>
       </xsl:call-template>
       <xsl:text>','</xsl:text>
       <xsl:call-template name="EnQuote">
        <xsl:with-param name="String" select="TYPEMD/SCHEMA_OBJ/OWNER_NAME"/>
       </xsl:call-template>
       <xsl:text>')</xsl:text>
       <xsl:if test="$CONVERT_TSTZ_COLS='1' and TYPEMD/HAS_TSTZ='Y'">)</xsl:if>
      </xsl:when>
     </xsl:choose>
    </xsl:when>
    <xsl:when test="TYPE_NUM=181 and
                    $CONVERT_TSTZ_COLS='1' and
                    ($OPERATION_TYPE='IMPORT' or
                     $OPERATION_TYPE='IMPORT_CONVENTIONAL')">)</xsl:when>
   </xsl:choose>
  </xsl:if>
  <xsl:choose>
   <xsl:when test="$ADT_type='TABLE'">
    <xsl:variable name="Intcol" select="INTCOL_NUM"/>
    <xsl:variable name="DeferVirtualColumn">
     <xsl:call-template name="IsDeferVirtualColumn">
      <xsl:with-param name="Partobj" select="$Partobj"/>
     </xsl:call-template>
    </xsl:variable>
    <!-- emit datatype -->
    <!-- if not a virtual column -->
    <!-- or not doing a data pump import -->
    <!-- or forced to generate the virtual column definition -->
    <!-- or doing the modify to restore the virtual column definition -->
    <xsl:if test="$DeferVirtualColumn='N' or $EXPORT=0 or $FORCE_VIRTUAL_COLUMNS=1
                 or $Virtcol!=0">
     <xsl:text> </xsl:text>
     <xsl:apply-templates select="TYPE_NUM">
      <xsl:with-param name="ExtTbl" select="$ExtTbl"/>
      <xsl:with-param name="ParentNode" select="."/>
      <xsl:with-param name="Virtcol" select="$Virtcol"/>
     </xsl:apply-templates>
    </xsl:if>
    <!-- Generate Collate name for char, varchar2, nchar, nvarchar2
         when the version is 12.2 or higher and 
               collname exists AND
               collation_clause is not never AND
               (not  ( a virtual column
                      and  datapump import 
                      and  virtual column is not forced) 
                             OR
                      a virtual column 
                      and  datapump import 
                      and Virtcol is 1) and
                Param OMIT_COL_DATATYPE is not set -->
    <xsl:if test="$VERSION>=1202000000 and COLLNAME and 
                   (TYPE_NUM=1 or TYPE_NUM=96 or
                    TYPE_NUM=8 or TYPE_NUM=112) and
                  (not ((PROPERTY mod 131072 >= 65536) and
                        $EXPORT=1 and $FORCE_VIRTUAL_COLUMNS=0) or
                   ((PROPERTY mod 131072 >= 65536) and
                    $EXPORT=1 and $Virtcol!=0)) and
                    $OMIT_COL_DATATYPE=0">
     <xsl:call-template name="DoCollation">
      <xsl:with-param name="IsDefault">0</xsl:with-param>
      <xsl:with-param name="Name" select="COLLNAME"/>
     </xsl:call-template>
    </xsl:if>
    <xsl:if test="(PROPERTY mod 268435456)>= 134217728">
     <xsl:text> SORT</xsl:text>
    </xsl:if>
    <xsl:choose>
     <!-- normal CREATE TABLE -->
     <xsl:when test="$ExtTbl=0">
      <!-- Invisible clause is not valid in ALTER TABLE stmt -->
      <xsl:if test="(PROPERTY2 mod 8) = 4 and $Virtcol=0 and $ExtTbl = 0 and $VERSION>=1200000000">
       <!-- Note: the INVISIBLE attribute must be BEFORE the DEFAULT attribute. 
                  consequently we must process the non-table (i.e., VIEW objs)
                  separately.
       -->
       <xsl:text> INVISIBLE</xsl:text>
      </xsl:if>
      <xsl:if test="DEFLENGTH !=0">
       <xsl:choose>
        <!-- virtual column -->
        <!-- Bug 10186633: Special processing needed if the virtual column  -->
        <!-- references a user-written PL/SQL function.  When creating      -->
        <!-- the table, substitute the intcol-num for the column expression;-->
        <!-- later we modify the column to supply the real column expression-->
        <xsl:when test="(PROPERTY mod 131072)>= 65536">
         <xsl:variable name="hasMAKEXML" select="contains(DEFAULT_VAL,'SYS_MAKEXML')"/>
         <xsl:variable name="hasJSON" select="contains(DEFAULT_VAL,'JSON_TABLE')"/>
         <xsl:variable name="hasSPATHR" select="contains(COL/DEFAULT_VAL,'SYS_PATH_REVERSE')"/>
         <xsl:text> GENERATED ALWAYS AS (</xsl:text>
         <xsl:choose>
          <xsl:when test="($Virtcol!=0) or $DeferVirtualColumn='N'">
           <xsl:choose>
            <!-- cannot parse SYS_MAKEXML so do not try -->
            <!-- lrg 12378533: skip expressions with JSON_TABLE operator -->
            <!-- Bug 19934581: Skip expressions with SYS_PATH_REVERSE operator
                               for a index on xml token set entity table -->
            <xsl:when test="PARSED_DEF and not ($hasMAKEXML) and not ($hasJSON) and 
                            not ($hasSPATHR)">
             <xsl:apply-templates select="PARSED_DEF"/>
            </xsl:when>
            <xsl:otherwise>
             <!--either DEFAULT_VAL or DEFAULT_VALC will be present
                 but not both-->
             <xsl:apply-templates select="DEFAULT_VAL"/>
             <xsl:apply-templates select="DEFAULT_VALC"/>
            </xsl:otherwise>
           </xsl:choose>
          </xsl:when>
          <xsl:when test="$EXPORT=1 and $Virtcol=0 
                         and $FORCE_VIRTUAL_COLUMNS=0">
           <xsl:value-of select="$Intcol"/>
          </xsl:when>
          <xsl:otherwise>
           <xsl:choose>
            <!-- cannot parse SYS_MAKEXML so do not try -->
            <xsl:when test="PARSED_DEF and not ($hasMAKEXML) and not ($hasJSON)">
             <xsl:apply-templates select="PARSED_DEF"/>
            </xsl:when>
            <xsl:otherwise>
             <!--either DEFAULT_VAL or DEFAULT_VALC will be present but not both-->
             <xsl:apply-templates select="DEFAULT_VAL"/>
             <xsl:apply-templates select="DEFAULT_VALC"/>
            </xsl:otherwise>
           </xsl:choose>
          </xsl:otherwise>
         </xsl:choose>
         <!-- lrg 5568079: remove HIDDEN/VISIBLE -->
         <xsl:text>) VIRTUAL </xsl:text>
         <!-- If the evaluation clause was specified, the VC is evaluated in the
              current edition - the only edition as far as this is concerned.-->
         <xsl:if test="$VERSION>=1200000000 and EVALEDITION_NUM
                       and EVALEDITION_NUM &gt; 0">
          <xsl:text>EVALUATE USING CURRENT EDITION </xsl:text>
         </xsl:if>
         <!-- If the unusable clause was specified, the VC is unusable before the
             current edition. -->
         <xsl:if test="$VERSION>=1200000000 and UNUSABLEBEF_NUM and
                      (UNUSABLEBEF_NUM &gt; 0 or UNUSABLEBEG_NUM &gt; 0)">
          <xsl:text>UNUSABLE BEFORE CURRENT EDITION </xsl:text>
         </xsl:if>
        </xsl:when>
        <xsl:when test="(PROPERTY2 mod 64) >= 32 or
                       (PROPERTY2 mod 128) >= 64">
         <xsl:call-template name="DoIdentityColumn">
          <xsl:with-param name="ColumnNode" select="./IDENTITY_COL"/>
          <xsl:with-param name="LimitValue">0</xsl:with-param>
         </xsl:call-template>
        </xsl:when>
        <!-- no default val for hidden snapshot base table column or
             Identity column
       -->
        <xsl:when test="(PROPERTY mod 2097152)&lt;1048576">
         <!-- default value -->
         <xsl:text> DEFAULT </xsl:text>
         <xsl:if test="(PROPERTY2 mod 32)>=16 and $VERSION >= 1200000000">ON NULL </xsl:if>
         <!--either DEFAULT_VAL or DEFAULT_VALC will be present but not both-->
         <xsl:apply-templates select="DEFAULT_VAL"/>
         <xsl:apply-templates select="DEFAULT_VALC"/>
        </xsl:when>
       </xsl:choose>
      </xsl:if>
      <!-- for transportable jobs there is some special sql for nullable columns-->
      <xsl:if test="$Transportable=1">
       <xsl:choose>
        <!-- This column has a guard column. Ensure that the guard col gets
            created in ecol$ explicitly
       -->
        <xsl:when test="(PROPERTY2 mod 512)>= 256 and 
                         BINARYDEFVAL and
                         $VERSION>=1200000000">
         <xsl:text> REPLACE NULL WITH (</xsl:text>
         <xsl:value-of select="BINARYDEFVAL"/>
         <xsl:text>)</xsl:text>
         <xsl:text> GUARD ID </xsl:text>
         <xsl:value-of select="GUARD_ID"/>
        </xsl:when>
        <!-- If this is a Guard Column ... designate as such -->
        <xsl:when test="(PROPERTY2 mod 256)>=128 and
                         $VERSION>=1200000000">
         <xsl:text> GUARD COLUMN</xsl:text>
        </xsl:when>
        <xsl:when test="(PROPERTY mod 2097152)&lt;1048576 and
                         BINARYDEFVAL and 
                         $VERSION>=1101000700">
         <!-- Syntax varied somewhat in 11.1 and 11.2 and requires explicitly
              specifying a default
          -->
         <xsl:if test="$VERSION &lt; 1200000000 and not(DEFLENGTH)">
          <xsl:text> DEFAULT NULL</xsl:text>
         </xsl:if>
         <!-- NO default value and the MODV prop bit is set we need to generate
              replace null with hextoraw() syntax. This occurs when ctas 
              from tables which have the modv property.
              NOTE: This is NOT restricted to version 12c
         -->
         <!-- Bug 21751519: In 11gR2 MODV prop bit can be set with NOT NULL 
              constraint and later NOT NULL constraint can be dropped and 
              database can be upgraded to higher versions. Don't generate 
              REPLACE NULL WITH HEXTORAW if source version is 11gR2.

              Bug 21893072: If source version is 12.1 then check for guard id 
              existence also -->
         <xsl:if test="not ((($SOURCE_VERSION>=1102000000 and 
                             $SOURCE_VERSION &lt; 1200000000) or 
                             (($SOURCE_VERSION>=1201000000 and
                              $SOURCE_VERSION &lt; 1202000000) and not(GUARD_ID))
                            ) and
                            (PROPERTY mod 2147483648) >=1073741824 and
                            NOT_NULL=0)">
          <xsl:text> REPLACE NULL WITH HEXTORAW('</xsl:text>
          <xsl:value-of select="BINARYDEFVAL"/>
          <xsl:text>')</xsl:text>
          <xsl:if test="GUARD_ID">
           <xsl:text> GUARD ID </xsl:text>
           <xsl:value-of select="GUARD_ID"/>
          </xsl:if>
         </xsl:if>
        </xsl:when>
       </xsl:choose>
      </xsl:if>
      <!-- is encryption on, don't check for: (see kuscomm.xsl)
           Type num     Datatype
           ========     ========
                 58     Opaque
                121     UDT
                122     Nested table
                123     Varray
      -->
      <xsl:variable name="CanEncrypt" 
                    select="TYPE_NUM!=58 and TYPE_NUM!=121 and
                            TYPE_NUM!=122 and TYPE_NUM!=123"/>
      <xsl:if test="(PROPERTY mod 134217728)>=67108864 and $CanEncrypt">
       <xsl:call-template name="DoColEncryption">
        <xsl:with-param name="ADT_type" select="$ADT_type"/>
        <xsl:with-param name="ExtTbl" select="$ExtTbl"/>
        <xsl:with-param name="ExtTblEncrypt" select="$ExtTblEncrypt"/>
       </xsl:call-template>
      </xsl:if>
      <!-- vector encoding -->
      <xsl:if test="(PROPERTY2 mod 65536)>=32768 and $VERSION>=1202000000">
       <xsl:text> VECTOR ENCODE</xsl:text>
      </xsl:if>
      <!-- Export always emits not null constraints unless specified -->
      <!-- Bug 18153657: More of special processing for virtual column that may-->
      <!-- reference a user-written PL/SQL function. We must supress the NO NULL constraint-->
      <!-- else the later modify column to set the expression will fail.-->
      <xsl:choose>
       <xsl:when test="($DeferVirtualColumn='N' or $EXPORT=0 or not ($Virtcol=0 and $FORCE_VIRTUAL_COLUMNS=0)) and
($CONSTRAINTS=1 or
 ($EXPORT=1 and
  $NULL_CONSTRAINTS=1 and
  (CON/CONTYPE='7' or CON/CONTYPE='11')))">
        <xsl:apply-templates select="CON"/>
       </xsl:when>
       <!-- All default on null columns have an implicit not null constraint and 
             consequently MUST exist regardless of constraint filters. If not
             present  ctc.c throws an assert. There are 2 conditions which
             require constraints which are identified by the following bits 
             defined in qcdl.h
               #define KQLDCOP_MODV         0x40000000  /* replace null vals with default */
               #define KQLDCOP2_DONNULL 0x00000010   /* default on null */
      -->
       <xsl:when test="($CONSTRAINTS=0 or $NULL_CONSTRAINTS=0) and
                          ($Transportable=1 and 
                               ((PROPERTY2 mod 32) >= 16 or 
                                (PROPERTY mod 2147483648) >= 1073741824))">
        <xsl:apply-templates select="CON"/>
       </xsl:when>
      </xsl:choose>
     </xsl:when>
     <xsl:when test="($ExtTbl=1 or $ExtTbl=2 or $ExtTbl=5)">
      <!-- is encryption on -->
      <xsl:if test="(PROPERTY mod 134217728)>=67108864 and TYPE_NUM!=123">
       <xsl:call-template name="DoColEncryption">
        <xsl:with-param name="ADT_type" select="$ADT_type"/>
        <xsl:with-param name="ExtTbl" select="$ExtTbl"/>
        <xsl:with-param name="ExtTblEncrypt" select="$ExtTblEncrypt"/>
       </xsl:call-template>
      </xsl:if>
     </xsl:when>
    </xsl:choose>
   </xsl:when>
   <xsl:otherwise>
    <!-- note: do NOT emit INVISIBLE clause if network (i.e., NOT valid
                 for  IAS statements).
    -->
    <xsl:if test="$VERSION>=1200000000 and $ExtTbl=0 and
          (PROPERTY2 mod 8) = 4 and $ADT_type!='TABLE' and $Network=0">
     <xsl:text> INVISIBLE</xsl:text>
    </xsl:if>
    <!-- is encryption on -->
    <xsl:if test="(PROPERTY mod 134217728)>=67108864 and TYPE_NUM!=123">
     <xsl:call-template name="DoColEncryption">
      <xsl:with-param name="ADT_type" select="$ADT_type"/>
      <xsl:with-param name="ExtTbl" select="$ExtTbl"/>
      <xsl:with-param name="ExtTblEncrypt" select="$ExtTblEncrypt"/>
     </xsl:call-template>
    </xsl:if>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="DoColEncryption">
  <xsl:param name="ADT_type">0</xsl:param>
  <xsl:param name="ExtTbl">0</xsl:param>
  <xsl:param name="ExtTblEncrypt">0</xsl:param>
  <!-- *******************************************************************
Template:     DoColEncryption - emit the column encryption
Current node: COL_LIST_ITEM
Parameters:
  ADT_type      - 0 = don't remap column names
                 non-0 = okay to remap column names
  ExtTbl        - for ADT_type='TABLE', what kind of operation
                0 = normal CREATE table
                1 = EXPORT, i.e., External Table unload
                2 = IMPORT, i.e., External Table load
                3 = IMPORT_CONVENTIONAL select statement
                4 = IMPORT_CONVENTIONAL import statement column names
                5 = IMPORT_CONVENTIONAL import statement values clause
		 (3-5 for conventional path load)
  ExtTblEncrypt - do/don't use the ENCRYPT keyword for encrypted columns
                when ExtTbl !=0
                 0 = don't use
                 non-0 = do use
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="$ExtTbl!=0 and $ExtTblEncrypt!=0">
    <xsl:if test="string-length($ENCRYPTION_PASSWORD)>0">
     <xsl:text> ENCRYPT USING 'AES128' IDENTIFIED BY "</xsl:text>
     <xsl:value-of select="$ENCRYPTION_PASSWORD"/>
     <xsl:text>" </xsl:text>
    </xsl:if>
   </xsl:when>
   <!-- if this is a table or materialized view, encryption is a thing -->
   <xsl:when test="$ADT_type='TABLE' or ancestor::M_VIEW_T">
    <!-- Generates encryption and internal algorithm names -->
    <xsl:call-template name="EncryptAlgo">
     <xsl:with-param name="EncAlg" select="../../ENCALG"/>
     <xsl:with-param name="IntAlg" select="../../INTALG"/>
    </xsl:call-template>
    <xsl:if test="(PROPERTY mod 1073741824)>=536870912">
     <xsl:text> NO SALT </xsl:text>
    </xsl:if>
   </xsl:when>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="DoColName">
  <xsl:param name="DoREMAP">0</xsl:param>
  <xsl:param name="ExtTbl">0</xsl:param>
  <xsl:param name="InColDef">0</xsl:param>
  <!-- *******************************************************************
Template: DoColName - emit the column name (remapped if necessary)
 Current node is COL_LIST_ITEM
Parameters:
  DoREMAP   - 0 = don't remap column names
              non-0 = okay to remap column names
  ExtTbl    - for ADT_type='TABLE', what kind of operation
               0 = normal CREATE table
               1 = EXPORT, i.e., External Table unload
               2 = IMPORT, i.e., External Table load
               3 = IMPORT_CONVENTIONAL select statement
               4 = IMPORT_CONVENTIONAL import statement column names
               5 = IMPORT_CONVENTIONAL import statement values clause
                   (3-5 for conventional path load)
  InColDef  - 1 = we are in the context of defining a column 
******************************************************************** -->
  <!-- Remap  column name if specified 
        The actual column name will appear as an alias,
        e.g., func(EMPNO) "EMPNO" -->
  <xsl:if test="$DoREMAP!=0">
   <xsl:choose>
    <xsl:when test="REMAP_COLUMN_NAME">
     <xsl:call-template name="SubstQuot">
      <xsl:with-param name="String" select="REMAP_COLUMN_NAME"/>
     </xsl:call-template>
     <xsl:text> </xsl:text>
    </xsl:when>
    <xsl:when test="NAME=$REMAP_COLUMN_NAMEO1">
     <xsl:call-template name="SubstQuot">
      <xsl:with-param name="String" select="$REMAP_COLUMN_NAMEN1"/>
     </xsl:call-template>
     <xsl:text> </xsl:text>
    </xsl:when>
    <xsl:when test="NAME=$REMAP_COLUMN_NAMEO2">
     <xsl:call-template name="SubstQuot">
      <xsl:with-param name="String" select="$REMAP_COLUMN_NAMEN2"/>
     </xsl:call-template>
     <xsl:text> </xsl:text>
    </xsl:when>
    <xsl:when test="NAME=$REMAP_COLUMN_NAMEO3">
     <xsl:call-template name="SubstQuot">
      <xsl:with-param name="String" select="$REMAP_COLUMN_NAMEN3"/>
     </xsl:call-template>
     <xsl:text> </xsl:text>
    </xsl:when>
    <xsl:when test="NAME=$REMAP_COLUMN_NAMEO4">
     <xsl:call-template name="SubstQuot">
      <xsl:with-param name="String" select="$REMAP_COLUMN_NAMEN4"/>
     </xsl:call-template>
     <xsl:text> </xsl:text>
    </xsl:when>
    <xsl:when test="NAME=$REMAP_COLUMN_NAMEO5">
     <xsl:call-template name="SubstQuot">
      <xsl:with-param name="String" select="$REMAP_COLUMN_NAMEN5"/>
     </xsl:call-template>
     <xsl:text> </xsl:text>
    </xsl:when>
    <xsl:when test="NAME=$REMAP_COLUMN_NAMEO6">
     <xsl:call-template name="SubstQuot">
      <xsl:with-param name="String" select="$REMAP_COLUMN_NAMEN6"/>
     </xsl:call-template>
     <xsl:text> </xsl:text>
    </xsl:when>
    <xsl:when test="NAME=$REMAP_COLUMN_NAMEO7">
     <xsl:call-template name="SubstQuot">
      <xsl:with-param name="String" select="$REMAP_COLUMN_NAMEN7"/>
     </xsl:call-template>
     <xsl:text> </xsl:text>
    </xsl:when>
    <xsl:when test="NAME=$REMAP_COLUMN_NAMEO8">
     <xsl:call-template name="SubstQuot">
      <xsl:with-param name="String" select="$REMAP_COLUMN_NAMEN8"/>
     </xsl:call-template>
     <xsl:text> </xsl:text>
    </xsl:when>
    <xsl:when test="NAME=$REMAP_COLUMN_NAMEO9">
     <xsl:call-template name="SubstQuot">
      <xsl:with-param name="String" select="$REMAP_COLUMN_NAMEN9"/>
     </xsl:call-template>
     <xsl:text> </xsl:text>
    </xsl:when>
    <xsl:when test="NAME=$REMAP_COLUMN_NAMEO10">
     <xsl:call-template name="SubstQuot">
      <xsl:with-param name="String" select="$REMAP_COLUMN_NAMEN10"/>
     </xsl:call-template>
     <xsl:text> </xsl:text>
    </xsl:when>
   </xsl:choose>
  </xsl:if>
  <xsl:choose>
   <xsl:when test="$ExtTbl=0">
    <xsl:call-template name="ColNameOrAttr">
     <xsl:with-param name="ColItem" select="current()"/>
     <xsl:with-param name="InColDef" select="$InColDef"/>
    </xsl:call-template>
   </xsl:when>
   <xsl:otherwise>
    <!-- For EXPORT or IMPORT always use the col name, not the attrname -->
    <xsl:text>"</xsl:text>
    <xsl:value-of select="NAME"/>
    <xsl:text>"</xsl:text>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="IsDeferVirtualColumn">
  <xsl:param name="Partobj"/>
  <!-- *******************************************************************
Template: IsDeferVirtualColumn
 checks for a virtual column existing, and that defining the virtual column 
 expression may be deferred. Deferring allows plsql to be imported.
    Transportable                               -  never defer for transportable objects
    virtual column                               - prop bit 0x010000
    with column expression                       - deflength != 0
    not system-generated column                  - prop bit 0x000100
    not hidden                                   - prop bit 0x000020
        AND not invisible column                 - prop2 bit 0x000004
    not unused                                   - prop bit 0x008000
    not (sub)partitioning column
    not PK or unique column of a reference partitioning parent table
Current node:
  COL_LIST_ITEM
Parameters:
  Partobj      - PART_OBJ element if it exists
Returns:  'Y' or 'N'
******************************************************************** -->
  <xsl:variable name="Intcol" select="INTCOL_NUM"/>
  <xsl:variable name="Con1_items" select="ancestor::TABLE_T/CON1_LIST/CON1_LIST_ITEM"/>
  <xsl:choose>
   <xsl:when test="$Transportable!=0">N</xsl:when>
   <xsl:when test="(PROPERTY mod 131072) &lt; 65536">N</xsl:when>
   <xsl:when test="DEFLENGTH=0">N</xsl:when>
   <xsl:when test="(PROPERTY mod 512)>=256">N</xsl:when>
   <xsl:when test="(PROPERTY mod 64)>=32 and (PROPERTY2 mod 8)&lt;4">N</xsl:when>
   <xsl:when test="(PROPERTY mod 65536)>=32768">N</xsl:when>
   <xsl:when test="($Partobj and $Partobj/PARTCOLS and $Partobj/PARTCOLS/PARTCOLS_ITEM[INTCOL_NUM=$Intcol]) or 
                     ($Partobj and $Partobj/SUBPARTCOLS and $Partobj/SUBPARTCOLS/SUBPARTCOLS_ITEM[INTCOL_NUM=$Intcol])">N</xsl:when>
   <xsl:when test="(($Partobj/PARTOBJ/FLAGS mod 64) >=32) and 
$Con1_items[((CONTYPE=2)or(CONTYPE=3))and COL_LIST/COL_LIST_ITEM/INTCOL_NUM=$Intcol]">N</xsl:when>
   <xsl:otherwise>Y</xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="EmitCommaLF">
  <xsl:param name="DoLF">1</xsl:param>
  <!-- *******************************************************************
Template: EmitCommaLF - Emit a comma and (optionally) a line-feed.
Parameters:
  DoLF      - 1 = emit a line feed between columns (if PRETTY=1)
******************************************************************** -->
  <xsl:text>, </xsl:text>
  <xsl:if test="$PRETTY=1 and $DoLF=1">
   <xsl:text>&#xa;</xsl:text>
  </xsl:if>
 </xsl:template>
 <xsl:template match="TYPE_NUM">
  <xsl:param name="ExtTbl">0</xsl:param>
  <xsl:param name="ParentNode">0</xsl:param>
  <xsl:param name="Virtcol">0</xsl:param>
  <!-- *******************************************************************
Template: TYPE_NUM - emit column datatype for TABLE
Parameters:
  ExtTbl    - for ADT_type='TABLE', what kind of operation
               0 = normal CREATE table
               1 = EXPORT, i.e., External Table unload
               2 = IMPORT, i.e., External Table load
               3 = IMPORT_CONVENTIONAL select statement
               4 = IMPORT_CONVENTIONAL import statement column names
               5 = IMPORT_CONVENTIONAL import statement values clause
                   (3-5 for conventional path load)
 ParentNode = Node containing TYPEMD, LENGTH, CHARSETFORM,etc
                     (i.e., it use to be ..)
Note: setting transform param OMIT_COL_DATATYPE to TRUE suppresses this.
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="$OMIT_COL_DATATYPE!='0'"/>
   <xsl:when test=".='1' or .='9'">
    <xsl:choose>
     <xsl:when test="$ParentNode/CHARSETFORM='2'">
      <xsl:text>NVARCHAR2(</xsl:text>
      <xsl:choose>
       <xsl:when test="$Virtcol!='0' and $MAX_STRING_EXTENDED='1' and 
                       $ParentNode/SPARE3='4000'">
        <xsl:text>32767</xsl:text>
       </xsl:when>
       <xsl:otherwise>
        <xsl:value-of select="$ParentNode/SPARE3"/>
       </xsl:otherwise>
      </xsl:choose>
      <xsl:text>)</xsl:text>
     </xsl:when>
     <xsl:otherwise>
      <xsl:text>VARCHAR2</xsl:text>
      <xsl:call-template name="DoCharLength">
       <xsl:with-param name="ParentNode" select="$ParentNode"/>
       <xsl:with-param name="Virtcol" select="$Virtcol"/>
      </xsl:call-template>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <xsl:when test=".='2'">
    <xsl:choose>
     <xsl:when test="($ParentNode/PRECISION_NUM) and not($ParentNode/SCALE)">FLOAT</xsl:when>
     <xsl:otherwise>NUMBER</xsl:otherwise>
    </xsl:choose>
    <xsl:call-template name="DoPrecScale">
     <xsl:with-param name="Node" select="$ParentNode"/>
    </xsl:call-template>
   </xsl:when>
   <!-- 3 - integer
      7 - packed decimal
      246 - smallint
-->
   <xsl:when test=".='3' or
                               .='246'">
    <xsl:text>INTEGER</xsl:text>
   </xsl:when>
   <!-- 7 - packed decimal -->
   <xsl:when test=".='7'">
    <xsl:text>DECIMAL</xsl:text>
    <xsl:call-template name="DoPrecScale">
     <xsl:with-param name="Node" select="$ParentNode"/>
     <xsl:with-param name="TypeObj">1</xsl:with-param>
    </xsl:call-template>
   </xsl:when>
   <xsl:when test=".='4' or 
                               .='22'">
    <xsl:text>FLOAT</xsl:text>
    <xsl:call-template name="DoPrecScale">
     <xsl:with-param name="Node" select="$ParentNode"/>
    </xsl:call-template>
   </xsl:when>
   <xsl:when test=".='8'">
    <xsl:choose>
     <xsl:when test="$ExtTbl=0">LONG</xsl:when>
     <xsl:otherwise>CLOB</xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <xsl:when test=".='12'">DATE</xsl:when>
   <xsl:when test=".='100'">
    <xsl:text>BINARY_FLOAT</xsl:text>
   </xsl:when>
   <xsl:when test=".='101'">
    <xsl:text>BINARY_DOUBLE</xsl:text>
   </xsl:when>
   <xsl:when test=".='178'">
    <xsl:text>TIME (</xsl:text>
    <xsl:value-of select="../SCALE"/>
    <xsl:text>)</xsl:text>
   </xsl:when>
   <xsl:when test=".='179'">
    <xsl:text>TIME (</xsl:text>
    <xsl:value-of select="../SCALE"/>
    <xsl:text>) WITH TIME ZONE</xsl:text>
   </xsl:when>
   <xsl:when test=".='180'">
    <xsl:text>TIMESTAMP (</xsl:text>
    <xsl:value-of select="../SPARE1"/>
    <xsl:text>)</xsl:text>
   </xsl:when>
   <xsl:when test=".='181'">
    <xsl:text>TIMESTAMP (</xsl:text>
    <xsl:value-of select="../SPARE1"/>
    <xsl:text>) WITH TIME ZONE</xsl:text>
   </xsl:when>
   <xsl:when test=".='231'">
    <xsl:text>TIMESTAMP (</xsl:text>
    <xsl:value-of select="../SPARE1"/>
    <xsl:text>) WITH LOCAL TIME ZONE</xsl:text>
   </xsl:when>
   <xsl:when test=".='182'">
    <xsl:text>INTERVAL YEAR (</xsl:text>
    <xsl:value-of select="../PRECISION_NUM"/>
    <xsl:text>) TO MONTH</xsl:text>
   </xsl:when>
   <xsl:when test=".='183'">
    <xsl:text>INTERVAL DAY (</xsl:text>
    <xsl:value-of select="$ParentNode/PRECISION_NUM"/>
    <xsl:text>) TO SECOND (</xsl:text>
    <xsl:value-of select="$ParentNode/SCALE"/>
    <xsl:text>)</xsl:text>
   </xsl:when>
   <xsl:when test=".='21'">
    <xsl:text>REAL</xsl:text>
   </xsl:when>
   <xsl:when test=".='23' or .='95'">
    <xsl:text>RAW</xsl:text>
    <xsl:apply-templates select="$ParentNode/LENGTH"/>
   </xsl:when>
   <xsl:when test=".='24'">
    <xsl:choose>
     <xsl:when test="$ExtTbl=0">LONG RAW</xsl:when>
     <xsl:otherwise>BLOB</xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <xsl:when test=".='69'">
    <xsl:text>ROWID</xsl:text>
   </xsl:when>
   <xsl:when test=".='208'">
    <xsl:text>UROWID (</xsl:text>
    <xsl:value-of select="$ParentNode/LENGTH"/>
    <xsl:text>)</xsl:text>
   </xsl:when>
   <xsl:when test=".='96'">
    <xsl:choose>
     <xsl:when test="../CHARSETFORM='2'">
      <xsl:text>NCHAR(</xsl:text>
      <xsl:value-of select="$ParentNode/SPARE3"/>
      <xsl:text>)</xsl:text>
     </xsl:when>
     <xsl:otherwise>
      <xsl:text>CHAR</xsl:text>
      <xsl:call-template name="DoCharLength">
       <xsl:with-param name="ParentNode" select="$ParentNode"/>
      </xsl:call-template>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <xsl:when test=".='105'">MLSLABEL</xsl:when>
   <xsl:when test=".='111'">
    <xsl:choose>
     <xsl:when test="$ExtTbl=0">
      <xsl:for-each select="$ParentNode/TYPEMD">
       <xsl:text>REF </xsl:text>
       <xsl:apply-templates select="SCHEMA_OBJ"/>
      </xsl:for-each>
     </xsl:when>
     <xsl:otherwise>
      <xsl:text>RAW(</xsl:text>
      <xsl:value-of select="$ParentNode/LENGTH"/>
      <xsl:text>)</xsl:text>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <xsl:when test=".='112'">
    <xsl:choose>
     <xsl:when test="$ParentNode/CHARSETFORM='2'">NCLOB</xsl:when>
     <xsl:otherwise>CLOB</xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <xsl:when test=".='113'">BLOB</xsl:when>
   <xsl:when test=".='114'">
    <xsl:choose>
     <xsl:when test="$ExtTbl=0">BFILE</xsl:when>
     <xsl:otherwise>RAW(530)</xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <!--    Type num     Datatype
           ========     ========
                108     NTY
        -->
   <xsl:when test=".='108'">
    <xsl:if test="($ParentNode/PROPERTIES mod 65536)>=32768">
     <xsl:text>REF </xsl:text>
    </xsl:if>
    <xsl:apply-templates select="$ParentNode/TYPEMD/SCHEMA_OBJ">
     <xsl:with-param name="TrailingBlank">0</xsl:with-param>
    </xsl:apply-templates>
   </xsl:when>
   <!--    Type num     Datatype
           ========     ========
                121     UDT
                122     Nested table
                123     Varray
                 58     Opaque
        -->
   <xsl:when test=".='121' or .='122' or .='123' or .='58'">
    <xsl:choose>
     <xsl:when test="$ExtTbl=0">
      <xsl:choose>
       <xsl:when test="$ParentNode/TYPEMD">
        <xsl:for-each select="$ParentNode/TYPEMD">
         <xsl:choose>
          <xsl:when test="SYN_NAME">
           <xsl:if test="SYN_OWNER!='PUBLIC'">
            <xsl:text>"</xsl:text>
            <xsl:value-of select="SYN_OWNER"/>
            <xsl:text>".</xsl:text>
           </xsl:if>
           <xsl:text>"</xsl:text>
           <xsl:value-of select="SYN_NAME"/>
           <xsl:text>"</xsl:text>
          </xsl:when>
          <xsl:otherwise>
           <xsl:choose>
            <!-- Once UDT column is marked as unused. Its corresponding UDT may
                 not exists in DB and it won't be exported. To avoid import 
                 time error, unused column is generated as RAW type for unused 
                 UDT and varray type columns and this column is marked unused 
                 after table successful creation in tts mode -->
            <!-- When extended varchar/raw is disabled, RAW is limited
                 to 2000 bytes while VARCHAR is limited to 4000, so use
                 VARCHAR data type for extra capacity -->
            <xsl:when test="$Transportable=1 and (../PROPERTY mod 65536)>=32768 and
                            ../TYPE_NUM!=58">
             <xsl:text>VARCHAR2(</xsl:text>
             <xsl:value-of select="$ParentNode/LENGTH"/>
             <xsl:text> BYTE)</xsl:text>
            </xsl:when>
            <xsl:otherwise>
             <xsl:apply-templates select="SCHEMA_OBJ"/>
            </xsl:otherwise>
           </xsl:choose>
          </xsl:otherwise>
         </xsl:choose>
        </xsl:for-each>
       </xsl:when>
       <xsl:otherwise>
        <!-- TYPE_SPEC have a <SCHEMA_OBJ> rather than a <TYPEMD> -->
        <xsl:apply-templates select="$ParentNode/SCHEMA_OBJ">
         <xsl:with-param name="TrailingBlank">0</xsl:with-param>
        </xsl:apply-templates>
       </xsl:otherwise>
      </xsl:choose>
     </xsl:when>
     <xsl:otherwise>
      <xsl:choose>
       <xsl:when test=".='121'">
        <xsl:choose>
         <xsl:when test="$ParentNode/LENGTH and $ParentNode/LENGTH>2">
          <xsl:text>RAW(</xsl:text>
          <xsl:value-of select="$ParentNode/LENGTH"/>
          <xsl:text>)</xsl:text>
         </xsl:when>
         <xsl:otherwise>
          <xsl:text>RAW(2)</xsl:text>
         </xsl:otherwise>
        </xsl:choose>
       </xsl:when>
       <xsl:when test=".='122'">RAW(16)</xsl:when>
       <xsl:when test=".='123'">BLOB</xsl:when>
       <xsl:when test=".='58'">
        <xsl:choose>
         <xsl:when test="$ParentNode/OPQMD/TYPE=1">
          <!-- XMLType -->
          <xsl:choose>
           <!-- flags 64  = binary XML
                         2  = schema based
                         4  = store as lob
         -->
           <xsl:when test="$XMLTYPE_STREAM_FORMAT='BLOB'">BLOB</xsl:when>
           <xsl:when test="$XMLTYPE_STREAM_FORMAT='CLOB'">CLOB</xsl:when>
           <xsl:when test="($ParentNode/OPQMD/FLAGS mod 128)>=64">BLOB</xsl:when>
           <xsl:when test="($ParentNode/OPQMD/FLAGS mod 4)>=2">BLOB</xsl:when>
           <xsl:otherwise>CLOB</xsl:otherwise>
          </xsl:choose>
         </xsl:when>
         <!-- not XMLType -->
         <xsl:otherwise>BLOB</xsl:otherwise>
        </xsl:choose>
       </xsl:when>
       <xsl:otherwise>*** INTERNAL ERROR ***</xsl:otherwise>
      </xsl:choose>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <xsl:otherwise>
    <xsl:text>***UNSUPPORTED DATA TYPE (</xsl:text>
    <xsl:value-of select="current()"/>
    <xsl:text>)***</xsl:text>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="DoCharLength">
  <xsl:param name="ParentNode">0</xsl:param>
  <xsl:param name="Virtcol">0</xsl:param>
  <!-- *******************************************************************
Template: DoCharLength - emit the length of a character datatype
           (CHAR, NCHAR, VARCHAR, NVARCHAR) and, optionally,
           the CHAR or BYTE keyword
Paremeter:
          ParentNode 
******************************************************************** -->
  <xsl:text>(</xsl:text>
  <xsl:choose>
   <!-- character-length semantics -->
   <xsl:when test="($ParentNode/PROPERTY mod 16777216)>=8388608">
    <xsl:choose>
     <xsl:when test="$Virtcol!='0' and $MAX_STRING_EXTENDED='1' and ../SPARE3='4000'">
      <xsl:text>32767</xsl:text>
     </xsl:when>
     <xsl:otherwise>
      <xsl:value-of select="../SPARE3"/>
     </xsl:otherwise>
    </xsl:choose>
    <xsl:text> CHAR</xsl:text>
   </xsl:when>
   <!-- byte-length semantics -->
   <xsl:otherwise>
    <xsl:choose>
     <xsl:when test="$Virtcol!='0' and $MAX_STRING_EXTENDED='1' and 
                     $ParentNode/LENGTH='4000'">
      <xsl:text>32767</xsl:text>
     </xsl:when>
     <xsl:otherwise>
      <xsl:value-of select="$ParentNode/LENGTH"/>
     </xsl:otherwise>
    </xsl:choose>
    <xsl:if test="$SIZE_BYTE_KEYWORD=1 or $EXPORT=1">
     <xsl:text> BYTE</xsl:text>
    </xsl:if>
   </xsl:otherwise>
  </xsl:choose>
  <xsl:text>)</xsl:text>
 </xsl:template>
 <xsl:template match="LENGTH">
  <!-- *******************************************************************
Template: LENGTH - used for length of RAWs
******************************************************************** -->
  <xsl:text>(</xsl:text>
  <xsl:value-of select="."/>
  <xsl:if test="(../SCALE) and not(../SCALE='0')">
   <xsl:text>,</xsl:text>
   <xsl:value-of select="../SCALE"/>
  </xsl:if>
  <xsl:text>)</xsl:text>
 </xsl:template>
 <xsl:template name="DoPrecScale">
  <xsl:param name="Node" select="''"/>
  <xsl:param name="TypeObj">0</xsl:param>
  <!-- *******************************************************************
Template: DoPrecScale
     This template used for  NUMBER(x,y) and FLOAT(z)
     There are 4 cases (see below)
Parameters:
 Node - parent node of SCALE, PRECISION_NUM, etc.
 TypeObj - TYPE definitions do not allow wildcarding PRECISION (e.g., NUMBER(*,2)
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="($Node/PRECISION_NUM)">
    <!--
     precision  scale   result
        Y         Y     NUMBER(prec,scale)
        Y         N     FLOAT(prec)
 -->
    <xsl:text>(</xsl:text>
    <xsl:value-of select="($Node/PRECISION_NUM)"/>
    <xsl:if test="($Node/SCALE)">
     <xsl:text>,</xsl:text>
     <xsl:value-of select="$Node/SCALE"/>
    </xsl:if>
    <xsl:text>)</xsl:text>
   </xsl:when>
   <xsl:when test="($Node/PRECISION)">
    <!--
     precision  scale   result
        Y         Y     NUMBER(prec,scale)
        Y         N     FLOAT(prec)
 -->
    <xsl:text>(</xsl:text>
    <xsl:value-of select="($Node/PRECISION)"/>
    <xsl:if test="($Node/SCALE)">
     <xsl:text>,</xsl:text>
     <xsl:value-of select="$Node/SCALE"/>
    </xsl:if>
    <xsl:text>)</xsl:text>
   </xsl:when>
   <xsl:otherwise>
    <!--
     precision  scale   result
        N         Y     NUMBER(*,scale)
        N         N     NUMBER
 -->
    <xsl:if test="($Node/SCALE) and $TypeObj!=1">
     <xsl:text>(*,</xsl:text>
     <xsl:value-of select="$Node/SCALE"/>
     <xsl:text>)</xsl:text>
    </xsl:if>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template match="DEFAULT_VAL | DEFAULT_VALC">
  <!-- *******************************************************************
Template: DEFAULT_VAL[C] - column default
******************************************************************** -->
  <xsl:call-template name="Trim_string">
   <xsl:with-param name="String" select="."/>
   <xsl:with-param name="TrimAllWS">1</xsl:with-param>
  </xsl:call-template>
 </xsl:template>
 <xsl:template name="Trim_string">
  <xsl:param name="String"/>
  <xsl:param name="TrimAllWS">0</xsl:param>
  <!-- *******************************************************************
Template: Trim_string - trim trailing white space, then output string
     Parameters:   String = the string to trim
                   TrimAllWS = 0: only trim trailing space (default)
                               1: trim all trailing whitespace
     TrimAllWS is designed to handle default values that are stored
     in the dictionary with a trailing new-line, e.g.,

       create table foo( a number default 1
                    );

     The default value is stored as "1<NL>".
     Since pretty-printing introduces a new-line before the trailing right
     paren, failure to trim the new-line in the default value can cause
     a blank line in the generated DDL:

       CREATE TABLE "FOO" (
         "A" NUMBER DEFAULT 1

         );

     Trimming the new-line fixes the problem in this case, but it doesn't
     if the column default value includes a comment and the column is not the
     last item before the right paren: in that case the comma separator
     appears right after the comment, i.e., it becomes part of the comment.  
     (Since XSL does not allow the string "dash-dash" inside xsl comments,
     in this and subsequent examples the comment string is represented "- -").

       create table foo(a number default 1 - - this is a comment
                    , constraint bar foreign key ...
                    );

     We would generate

       CREATE TABLE "FOO" (
         "A" NUMBER DEFAULT 1 - - this is a comment,
         CONSTRAINT "BAR" FOREIGN KEY ...
         );

     The code below causes the least harm but is still not perfect, e.g.,

       create table foo(a number default 1 - - this is a comment
                    );

     still results in a blank line

       CREATE TABLE "FOO" (
         "A" NUMBER DEFAULT 1 - - this is a comment

         );

     (All this would be much easier if xsl allowed us to keep state.)
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="$TrimAllWS=1 and contains($String,'--')=0 and
 string-length(normalize-space(substring($String,string-length($String),1)))=0">
    <xsl:call-template name="Trim_string">
     <xsl:with-param name="String" select="substring($String,1,string-length($String)-1)"/>
     <xsl:with-param name="TrimAllWS">1</xsl:with-param>
    </xsl:call-template>
   </xsl:when>
   <xsl:when test="substring($String,string-length($String),1)=' '">
    <xsl:value-of select="substring($String,1,string-length($String)-1)"/>
   </xsl:when>
   <xsl:otherwise>
    <xsl:value-of select="$String"/>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template match="CON">
  <!-- *******************************************************************
Template: CON - emit not-null constraint
******************************************************************** -->
  <xsl:if test="CONTYPE='7' or CONTYPE='11'">
   <xsl:call-template name="DoConstraint">
    <xsl:with-param name="TAB_CONSTRAINT">0</xsl:with-param>
   </xsl:call-template>
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoParseLongPosition">
  <xsl:param name="Scalars" select="''"/>
  <xsl:param name="Lobs" select="''"/>
  <xsl:param name="Longs" select="''"/>
  <!-- *******************************************************************
Template: DoParseLongPosition
Parameters:
  Scalars   - the node set of scalar COL_LIST_ITEM elements
  Lobs      - the node set of lob COL_LIST_ITEM elements
  Longs     - the node set of long COL_LIST_ITEM elements
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="count($Longs)!=0">
    <xsl:value-of select="count($Scalars)+count($Lobs)+1"/>
   </xsl:when>
   <xsl:otherwise>0</xsl:otherwise>
  </xsl:choose>
 </xsl:template>
</xsl:stylesheet>

OHA YOOOO