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

<?xml version="1.0"?>
<!-- 
 Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.

NAME
    kuscommcx.xsl - THIS FILE GENERATED MECHANICALLY FROM kuscommc.xsl
DESCRIPTION
    Templates for common and utility functions for both SXML-DDL conversion
    and ALTERXML generation.

MODIFIED        MM/DD/YY
    tbhukya     03/21/17 - Bug 25747729: Fix table and index compression
    sdavidso    03/01/17 - bug25440009 handle user name with apostrophe
    tbhukya     11/15/15 - Bug 22171671: add element maxtrans
    tbhukya     09/28/15 - Bug 21822338: Support INDEX COMPRESS
    tbhukya     09/08/15 - Bug 21769074: Use old encryption syntax for 
                           versions less than 12.2
    tbhukya     01/05/15 - Bug 20319428: Declare referred params
    dvekaria    06/17/14 - Bug 18744847: Inc COMPRESS Y value.
    abodge      06/09/14 - CM MODIFIED: Add SQL terminator to comments
    lbarton     02/06/14 - bug 17943479: make template name unique
                           move Datatype to kuscommc
    bwright     08/16/13 - Bug 17312600: Remove hard tabs from DP src code
    lbarton     05/23/13 - bug 15872712: ILM policies
    rapayne     03/12/13 - bug 15924364: new oltp compression syntax
    rapayne     11/09/12 - bug 15839049: name change for row level locking:
                           ROW LEVEL LOCKING <- ROW_LEVEL_LOCKING
    lbarton     09/19/11 - project 32935: row level locking
    tbhukya     01/24/10 - Bug 11667496:support FLASH_CACHE and CELL_FLASH_CACHE
                         - for 11.2 and higher versions only
    rapayne     11/01/09 - bug 8714709: process STORAGE(ENCRYPT) if appropriate.
    rapayne     10/10/09 - CM_SYNC: add PRS_COLUMN_ATTRIBUTE for CM 
    lbarton     07/10/09 - bug 8494344: archive compression
    rapayne     05/22/09 - bug 8391296: finish support for FLASH_CACHE and CELL_FLASH_CACHE
    adalee      04/16/09 - add FLASH_CACHE and CELL_FLASH_CACHE
    rapayne     01/12/09 - add CommentsOn template for CM.
    lbarton     07/08/08 - bug 5709159: move EscapeString to kuscommc
    rapayne     03/10/08 - Add SingleQuotedName template.
    lbarton     01/24/08 - Bug 6724820: move VERSION param to kuscommc
    lbarton     01/18/08 - Bug 6724820: table compression
    rapayne     11/01/07 - fix ddl generation for PUBLIC SYNONYMS,
    lbarton     10/09/06 - Initial version
 -->
<xsl:stylesheet version="1.0" xmlns:sxml="http://xmlns.oracle.com/ku" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <!-- Top level imports -->
 <!-- Top-level parameters -->
 <xsl:param name="CM_MODE">0</xsl:param>
 <xsl:param name="STATISTICS">0</xsl:param>
 <xsl:param name="VERSION">9999999999</xsl:param>
 <xsl:param name="PRS_DDL">0</xsl:param>
 <xsl:param name="PRS_DELIM">\{]`</xsl:param>
 <xsl:param name="PRS_COLUMN_ATTRIBUTE">0</xsl:param>
 <xsl:param name="STORAGE">1</xsl:param>
 <xsl:param name="PRETTY">1</xsl:param>
 <xsl:param name="SQLTERMINATOR">0</xsl:param>
 <xsl:param name="SEGMENT_ATTRIBUTES">1</xsl:param>
 <!-- Templates -->
 <xsl:template name="EscapeStringSxD">
  <xsl:param name="TheString" select="''"/>
  <!-- *******************************************************************
Template: EscapeStringSxD - emit a string escaping embedded single quotes
Parameters:
 TheString
******************************************************************** -->
  <xsl:variable name="SingleQuote">'</xsl:variable>
  <xsl:choose>
   <xsl:when test="contains($TheString,$SingleQuote)">
    <xsl:value-of select="substring-before($TheString,$SingleQuote)"/>
    <xsl:text>''</xsl:text>
    <xsl:call-template name="EscapeStringSxD">
     <xsl:with-param name="TheString" select="substring-after($TheString,$SingleQuote)"/>
    </xsl:call-template>
   </xsl:when>
   <xsl:otherwise>
    <xsl:value-of select="$TheString"/>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="SchemaName">
  <xsl:param name="ParentNode" select="''"/>
  <!-- *******************************************************************
Template: SchemaName
 This template puts out "<schema>"."<name>"
Parameters:
 ParentNode - parent of SCHEMA and NAME
******************************************************************** -->
  <xsl:if test="$ParentNode/SCHEMA">
   <xsl:call-template name="SourceName">
    <xsl:with-param name="NameNode" select="$ParentNode/SCHEMA"/>
   </xsl:call-template>
   <xsl:text>.</xsl:text>
  </xsl:if>
  <xsl:call-template name="SourceName">
   <xsl:with-param name="NameNode" select="$ParentNode/NAME"/>
  </xsl:call-template>
 </xsl:template>
 <xsl:template name="QuotedSchemaName">
  <xsl:param name="Schema" select="''"/>
  <xsl:param name="Name" select="''"/>
  <!-- *******************************************************************
Template: QuotedSchemaName
 This template puts out "<schema>"."<name>"
Parameters:
 Schema - SCHEMA name
 Name - object name
******************************************************************** -->
  <xsl:if test="$Schema">"<xsl:value-of select="$Schema"/>
   <xsl:text>".</xsl:text>
  </xsl:if>"<xsl:value-of select="$Name"/>"</xsl:template>
 <xsl:template name="SourceName">
  <xsl:param name="NameNode" select="''"/>
  <!-- *******************************************************************
Template: SourceName: emit the source name or schema.
 The schema/name values are from the value1 attribute, if present,
 otherwise the element content.  This lets the template handle the
 case of comparing object1 and object2 where the objects have different
 names or schemas.  The alter templates should always generate ALTERs
 to object1.  But if the objects have different names or schemas,
 object1's name and schema are in the value1 attribute rather than the
 element content, e.g.,
      <NAME value1="EMP1">EMP2</NAME>
Parameters:
 NameNode - NAME or SCHEMA node
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="$NameNode/@value1">
    <xsl:call-template name="QuotedName">
     <xsl:with-param name="NameNode" select="$NameNode/@value1"/>
    </xsl:call-template>
   </xsl:when>
   <xsl:otherwise>
    <xsl:call-template name="QuotedName">
     <xsl:with-param name="NameNode" select="$NameNode"/>
    </xsl:call-template>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="QuotedName">
  <xsl:param name="NameNode" select="''"/>
  <!-- *******************************************************************
Template: QuotedName
Parameters:
 NameNode - NAME node
******************************************************************** -->
  <xsl:if test="(not(contains($NameNode,'&quot;')))">"</xsl:if>
  <xsl:value-of select="$NameNode"/>
  <xsl:if test="(not(contains($NameNode,'&quot;')))">"</xsl:if>
 </xsl:template>
 <xsl:template name="SingleQuotedNameSxD">
  <xsl:param name="NameNode" select="''"/>
  <!-- *******************************************************************
Template: SingleQuotedNameSxD - for Sxml-DDL conversion
Parameters:
 NameNode - NAME node
******************************************************************** -->
  <xsl:variable name="apos" select='"&apos;"'/>
  <xsl:if test="(not(contains($NameNode, $apos)))">'</xsl:if>
  <xsl:value-of select="$NameNode"/>
  <xsl:if test="(not(contains($NameNode, $apos)))">'</xsl:if>
 </xsl:template>
 <xsl:template name="TargetSchemaName">
  <xsl:param name="ParentNode" select="''"/>
  <!-- *******************************************************************
Template: TargetSchemaName
 This template puts out "<schema>"."<name>"
 It always uses the element text() value, never the @value1 attribute
Parameters:
 ParentNode - parent of SCHEMA and NAME
******************************************************************** -->
  <xsl:if test="$ParentNode/SCHEMA[not(@src='1')]">
   <xsl:call-template name="QuotedName">
    <xsl:with-param name="NameNode" select="$ParentNode/SCHEMA"/>
   </xsl:call-template>
   <xsl:text>.</xsl:text>
  </xsl:if>
  <xsl:call-template name="QuotedName">
   <xsl:with-param name="NameNode" select="$ParentNode/NAME"/>
  </xsl:call-template>
 </xsl:template>
 <xsl:template name="ColumnList">
  <xsl:param name="ColListNode" select="''"/>
  <xsl:param name="NoLog">0</xsl:param>
  <!-- *******************************************************************
Template: ColumnList
 This template puts out "<schema>"."<name>"
Parameters:
 ColListNode - COL_LIST
 NoLog - non-0 = output NO LOG if present
******************************************************************** -->
  <xsl:text>(</xsl:text>
  <xsl:for-each select="$ColListNode/COL_LIST_ITEM">
   <xsl:call-template name="QuotedName">
    <xsl:with-param name="NameNode" select="NAME"/>
   </xsl:call-template>
   <xsl:if test="($NoLog!=0) and NOLOG"> NO LOG</xsl:if>
   <xsl:if test="position()!=last()">,</xsl:if>
  </xsl:for-each>
  <xsl:text>)</xsl:text>
 </xsl:template>
 <xsl:template match="PARALLEL">
  <!-- *******************************************************************
Template: PARALLEL
******************************************************************** -->
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa; </xsl:text>
  </xsl:if>
  <xsl:text> PARALLEL </xsl:text>
  <xsl:if test="not(.='AUTOMATIC')">
   <xsl:value-of select="."/>
  </xsl:if>
 </xsl:template>
 <xsl:template match="PARALLEL_DEGREE">
  <!-- *******************************************************************
Template: PARALLEL_DEGREE (old syntax)
******************************************************************** -->
  <xsl:if test="$PRETTY=1">
   <xsl:text>&#xa; </xsl:text>
  </xsl:if>
  <xsl:text> PARALLEL ( DEGREE </xsl:text>
  <xsl:value-of select="DEGREE"/>
  <xsl:if test="INSTANCES">
   <xsl:text> INSTANCES </xsl:text>
   <xsl:value-of select="INSTANCES"/>
  </xsl:if>
  <xsl:text>) </xsl:text>
 </xsl:template>
 <xsl:template name="SegmentAttributes">
  <xsl:param name="ParentNode" select="''"/>
  <!-- *******************************************************************
Template: SegmentAttributes
Parameters:
 ParentNode - Parent of PCTFREE, STORAGE, TABLESPACE, etc.
******************************************************************** -->
  <xsl:call-template name="PhysicalAttributes">
   <xsl:with-param name="ParentNode" select="$ParentNode"/>
  </xsl:call-template>
  <xsl:if test="$ParentNode/TABLESPACE">
   <xsl:if test="$PRETTY=1">
    <xsl:text>&#xa; </xsl:text>
   </xsl:if>
   <xsl:text> TABLESPACE "</xsl:text>
   <xsl:value-of select="$ParentNode/TABLESPACE"/>
   <xsl:text>" </xsl:text>
  </xsl:if>
  <!-- TBS: LOGGING -->
 </xsl:template>
 <xsl:template name="PhysicalAttributes">
  <xsl:param name="ParentNode" select="''"/>
  <!-- *******************************************************************
Template: PhysicalAttributes
Parameters:
 ParentNode - Parent of PCTFREE, STORAGE, TABLESPACE, etc.
******************************************************************** -->
  <xsl:if test="$ParentNode/PCTFREE">
   <xsl:text> PCTFREE </xsl:text>
   <xsl:value-of select="$ParentNode/PCTFREE"/>
  </xsl:if>
  <xsl:if test="$ParentNode/PCTUSED">
   <xsl:text> PCTUSED </xsl:text>
   <xsl:value-of select="$ParentNode/PCTUSED"/>
  </xsl:if>
  <xsl:if test="$ParentNode/INITRANS">
   <xsl:text> INITRANS </xsl:text>
   <xsl:value-of select="$ParentNode/INITRANS"/>
  </xsl:if>
  <xsl:if test="$ParentNode/MAXTRANS">
   <xsl:text> MAXTRANS </xsl:text>
   <xsl:value-of select="$ParentNode/MAXTRANS"/>
  </xsl:if>
  <xsl:if test="$ParentNode/LOGGING">
   <xsl:choose>
    <xsl:when test="$ParentNode/LOGGING='Y'"> LOGGING</xsl:when>
    <xsl:when test="$ParentNode/LOGGING='N'"> NOLOGGING</xsl:when>
   </xsl:choose>
  </xsl:if>
  <xsl:if test="$ParentNode/STORAGE">
   <xsl:call-template name="Storage">
    <xsl:with-param name="StorageNode" select="$ParentNode/STORAGE"/>
   </xsl:call-template>
  </xsl:if>
 </xsl:template>
 <xsl:template name="Storage">
  <xsl:param name="StorageNode" select="''"/>
  <!-- *******************************************************************
Template: Storage
Parameters:
 StorageNode - STORAGE
******************************************************************** -->
  <xsl:if test="$STORAGE!=0">
   <xsl:if test="$PRETTY=1">
    <xsl:text>&#xa; </xsl:text>
   </xsl:if>
   <xsl:text> STORAGE(</xsl:text>
   <xsl:if test="$StorageNode/INITIAL">
    <xsl:text>INITIAL </xsl:text>
    <xsl:value-of select="$StorageNode/INITIAL"/>
    <xsl:text> </xsl:text>
   </xsl:if>
   <xsl:if test="$StorageNode/NEXT">
    <xsl:text>NEXT </xsl:text>
    <xsl:value-of select="$StorageNode/NEXT"/>
    <xsl:text> </xsl:text>
   </xsl:if>
   <xsl:if test="$StorageNode/MINEXTENTS">
    <xsl:text>MINEXTENTS </xsl:text>
    <xsl:value-of select="$StorageNode/MINEXTENTS"/>
    <xsl:text> </xsl:text>
   </xsl:if>
   <xsl:if test="$StorageNode/MAXEXTENTS">
    <xsl:text>MAXEXTENTS </xsl:text>
    <xsl:value-of select="$StorageNode/MAXEXTENTS"/>
    <xsl:text> </xsl:text>
   </xsl:if>
   <xsl:if test="$PRETTY=1">
    <xsl:text>&#xa;  </xsl:text>
   </xsl:if>
   <xsl:if test="$StorageNode/PCTINCREASE">
    <xsl:text>PCTINCREASE </xsl:text>
    <xsl:value-of select="$StorageNode/PCTINCREASE"/>
    <xsl:text> </xsl:text>
   </xsl:if>
   <xsl:if test="$StorageNode/LOBRETENTION">
    <xsl:text>LOBRETENTION </xsl:text>
    <xsl:value-of select="$StorageNode/LOBRETENTION"/>
    <xsl:text> </xsl:text>
   </xsl:if>
   <xsl:if test="$StorageNode/LOBMINRETENT">
    <xsl:text>MIN </xsl:text>
    <xsl:value-of select="$StorageNode/LOBMINRETENT"/>
    <xsl:text> </xsl:text>
   </xsl:if>
   <xsl:if test="$StorageNode/MAXSIZE">
    <xsl:text>MAXSIZE </xsl:text>
    <xsl:value-of select="$StorageNode/MAXSIZE"/>
    <xsl:text> </xsl:text>
   </xsl:if>
   <xsl:if test="$StorageNode/FREELISTS">
    <xsl:text>FREELISTS </xsl:text>
    <xsl:value-of select="$StorageNode/FREELISTS"/>
    <xsl:text> </xsl:text>
   </xsl:if>
   <xsl:if test="$StorageNode/FREELIST_GROUPS">
    <xsl:text>FREELIST GROUPS </xsl:text>
    <xsl:value-of select="$StorageNode/FREELIST_GROUPS"/>
    <xsl:text> </xsl:text>
   </xsl:if>
   <xsl:if test="$StorageNode/BUFFER_POOL">
    <xsl:text>BUFFER_POOL </xsl:text>
    <xsl:value-of select="$StorageNode/BUFFER_POOL"/>
    <xsl:text> </xsl:text>
   </xsl:if>
   <xsl:if test="$VERSION>=1102000000">
    <xsl:if test="$StorageNode/FLASH_CACHE">
     <xsl:text>FLASH_CACHE </xsl:text>
     <xsl:value-of select="$StorageNode/FLASH_CACHE"/>
     <xsl:text> </xsl:text>
    </xsl:if>
    <xsl:if test="$StorageNode/CELL_FLASH_CACHE">
     <xsl:text>CELL_FLASH_CACHE </xsl:text>
     <xsl:value-of select="$StorageNode/CELL_FLASH_CACHE"/>
    </xsl:if>
   </xsl:if>
   <xsl:text>)</xsl:text>
  </xsl:if>
 </xsl:template>
 <xsl:template name="DoCompressDDL">
  <xsl:param name="Compress" select="''"/>
  <xsl:param name="TableCompress" select="''"/>
  <xsl:param name="CompressLevel" select="''"/>
  <xsl:param name="RowLevelLocking" select="''"/>
  <xsl:param name="IndexCompress" select="''"/>
  <xsl:param name="OmitRowLevelLocking" select="false()"/>
  <!-- *******************************************************************
Template: DoCompressDDL - emit compression syntax
Parameters:
  Compress - COMPRESS node
  CompressLevel - COMPRESS_LEVEL node
  RowLevelLocking - ROW LEVEL LOCKING node
Note: DDL syntax differs depending on version
   11.2         11.1         10.x
   ========     ====         ====
   OLTP         ALL
   BASIC        DIRECT_LOAD  omitted
   QUERY        NO
   ARCHIVE      NO
    Row level locking is only valid for QUERY/ARCHIVE and only in 12c or later.

******************************************************************** -->
  <!-- When segment_attributes are disabled then we should not emit the COMPRESS clause -->
  <xsl:if test="$SEGMENT_ATTRIBUTES=1">
   <xsl:choose>
    <xsl:when test="$Compress='ALL' or $Compress='OLTP' or $Compress='ROW STORE COMPRESS ADVANCED' or $Compress='ROW STORE COMPRESS ADVANCED INPLACE' or $Compress='Y'">
     <xsl:choose>
      <xsl:when test="$VERSION>=1200000000 and $Compress='ROW STORE COMPRESS ADVANCED INPLACE'"> ROW STORE COMPRESS ADVANCED INPLACE</xsl:when>
      <xsl:when test="$VERSION>=1200000000"> ROW STORE COMPRESS ADVANCED</xsl:when>
      <xsl:when test="$VERSION>=1102000000"> COMPRESS FOR OLTP</xsl:when>
      <xsl:when test="$VERSION>=1100000000"> COMPRESS FOR ALL OPERATIONS</xsl:when>
      <xsl:otherwise> COMPRESS</xsl:otherwise>
     </xsl:choose>
    </xsl:when>
    <xsl:when test="$TableCompress='OLTP' or $TableCompress='QUERY_LOW' or $TableCompress='QUERY_HIGH' or
                    $TableCompress='ARCHIVE_LOW' or $TableCompress='ARCHIVE_HIGH' or
                    $IndexCompress=' ADVANCED HIGH' or $IndexCompress=' ADVANCED LOW'">
     <xsl:if test="$TableCompress">
      <xsl:choose>
       <xsl:when test="$TableCompress='OLTP'"> TABLE COMPRESS FOR OLTP</xsl:when>
       <xsl:when test="$TableCompress='QUERY_LOW'"> TABLE COMPRESS FOR QUERY LOW</xsl:when>
       <xsl:when test="$TableCompress='QUERY_HIGH'"> TABLE COMPRESS FOR QUERY HIGH</xsl:when>
       <xsl:when test="$TableCompress='ARCHIVE_LOW'"> TABLE COMPRESS FOR ARCHIVE LOW</xsl:when>
       <xsl:when test="$TableCompress='ARCHIVE_HIGH'"> TABLE COMPRESS FOR ARCHIVE HIGH</xsl:when>
      </xsl:choose>
     </xsl:if>
     <xsl:if test="$IndexCompress">
      <xsl:text> INDEX COMPRESS</xsl:text>
      <xsl:value-of select="$IndexCompress"/>
     </xsl:if>
    </xsl:when>
    <xsl:when test="$Compress='DIRECT_LOAD' or $Compress='BASIC'">
     <xsl:choose>
      <xsl:when test="$VERSION>=1102000000"> COMPRESS BASIC</xsl:when>
      <xsl:when test="$VERSION>=1100000000"> COMPRESS FOR DIRECT LOAD</xsl:when>
      <xsl:otherwise> COMPRESS</xsl:otherwise>
     </xsl:choose>
    </xsl:when>
    <xsl:when test="$Compress='QUERY' or $Compress='ARCHIVE'">
     <xsl:choose>
      <xsl:when test="$VERSION>=1102000000">
       <xsl:if test="$VERSION>=1200000000">
        <xsl:text> COLUMN STORE</xsl:text>
       </xsl:if>
       <xsl:text> COMPRESS FOR </xsl:text>
       <xsl:value-of select="$Compress"/>
       <xsl:choose>
        <xsl:when test="$CompressLevel = 'LOW'"> LOW</xsl:when>
        <xsl:otherwise> HIGH</xsl:otherwise>
       </xsl:choose>
       <xsl:if test="$VERSION>=1200000000">
        <xsl:choose>
         <xsl:when test="$OmitRowLevelLocking"/>
         <xsl:when test="$RowLevelLocking"> ROW LEVEL LOCKING</xsl:when>
         <xsl:otherwise> NO ROW LEVEL LOCKING</xsl:otherwise>
        </xsl:choose>
       </xsl:if>
      </xsl:when>
      <xsl:otherwise> NOCOMPRESS</xsl:otherwise>
     </xsl:choose>
    </xsl:when>
    <xsl:when test="$Compress='N'">
     <xsl:choose>
      <xsl:when test="../ENCRYPT and $VERSION&lt;1202000000"> STORAGE (ENCRYPT)</xsl:when>
      <xsl:otherwise> NOCOMPRESS</xsl:otherwise>
     </xsl:choose>
    </xsl:when>
   </xsl:choose>
  </xsl:if>
 </xsl:template>
 <xsl:template match="KEYCOMPRESS">
  <!-- *******************************************************************
Template: KEYCOMPRESS
******************************************************************** -->
  <xsl:choose>
   <xsl:when test=".='N'"> NOCOMPRESS</xsl:when>
   <xsl:otherwise>
    <xsl:text> COMPRESS </xsl:text>
    <xsl:value-of select="."/>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template match="SORT">
  <!-- *******************************************************************
Template: SORT
******************************************************************** -->
  <xsl:text> SORT</xsl:text>
 </xsl:template>
 <xsl:template match="XMLSCHEMA | ELEMENT">
  <!-- *******************************************************************
Template: XMLSCHEMA, ELEMENT
******************************************************************** -->
  <xsl:text> </xsl:text>
  <xsl:value-of select="local-name(.)"/>
  <xsl:text> "</xsl:text>
  <xsl:value-of select="."/>
  <xsl:text>"</xsl:text>
 </xsl:template>
 <xsl:template match="ID">
  <!-- *******************************************************************
Template: ID
******************************************************************** -->
  <xsl:text> </xsl:text>
  <xsl:value-of select="local-name(.)"/>
  <xsl:text> </xsl:text>
  <xsl:value-of select="."/>
  <xsl:text> </xsl:text>
 </xsl:template>
 <xsl:template name="CreSyn">
  <!-- *******************************************************************
Template: CreSyn
Current node: SYNONYM
  This template puts out
   - CREATE SYNONYM name
******************************************************************** -->
  <xsl:text> CREATE OR REPLACE </xsl:text>
  <xsl:choose>
   <xsl:when test="./SCHEMA = 'PUBLIC' and 
                    ./SCHEMA[not(@src='1')]">
    <xsl:text>PUBLIC SYNONYM </xsl:text>
    <xsl:call-template name="QuotedName">
     <xsl:with-param name="NameNode" select="./NAME"/>
    </xsl:call-template>
   </xsl:when>
   <xsl:otherwise>
    <xsl:text>SYNONYM </xsl:text>
    <xsl:call-template name="TargetSchemaName">
     <xsl:with-param name="ParentNode" select="."/>
    </xsl:call-template>
   </xsl:otherwise>
  </xsl:choose>
  <xsl:text> FOR </xsl:text>
  <xsl:if test="string-length(OBJECT_SCHEMA)!=0">
   <xsl:text>"</xsl:text>
   <xsl:value-of select="OBJECT_SCHEMA"/>
   <xsl:text>".</xsl:text>
  </xsl:if>
  <xsl:text>"</xsl:text>
  <xsl:value-of select="OBJECT_NAME"/>
  <xsl:text>"</xsl:text>
  <xsl:if test="string-length(DB_LINK)!=0">
   <xsl:text>@"</xsl:text>
   <xsl:value-of select="DB_LINK"/>
   <xsl:text>"</xsl:text>
  </xsl:if>
 </xsl:template>
 <xsl:template name="CommentsOn">
  <xsl:param name="ParentNode" select="."/>
  <xsl:param name="ObjectType" select="''"/>
  <!-- *******************************************************************
Template: CommentsOn
Current node: Parent of COMMENTS
  This template puts out
   COMMENT ON...
******************************************************************** -->
  <xsl:if test="$ParentNode/COMMENTS/OBJECT_COMMENT">
   <xsl:text>&#xa; </xsl:text>
   <xsl:text> COMMENT ON </xsl:text>
   <xsl:value-of select="$ObjectType"/>
   <xsl:text> </xsl:text>
   <xsl:call-template name="SchemaName">
    <xsl:with-param name="ParentNode" select="."/>
   </xsl:call-template>
   <xsl:text> IS '</xsl:text>
   <xsl:value-of select="$ParentNode/COMMENTS/OBJECT_COMMENT"/>
   <xsl:text>'</xsl:text>
   <xsl:if test="$SQLTERMINATOR=1">
    <xsl:text>;</xsl:text>
   </xsl:if>
  </xsl:if>
  <xsl:for-each select="$ParentNode/COMMENTS/COLUMN_COMMENT">
   <xsl:text>&#xa; </xsl:text>
   <xsl:text> COMMENT ON COLUMN </xsl:text>
   <xsl:call-template name="SchemaName">
    <xsl:with-param name="ParentNode" select="$ParentNode"/>
   </xsl:call-template>
   <xsl:text>.</xsl:text>
   <xsl:call-template name="QuotedName">
    <xsl:with-param name="NameNode" select="COL_LIST_ITEM"/>
   </xsl:call-template>
   <xsl:text> IS '</xsl:text>
   <xsl:value-of select="COMMENT"/>
   <xsl:text>'</xsl:text>
   <xsl:if test="$SQLTERMINATOR=1">
    <xsl:text>;</xsl:text>
   </xsl:if>
  </xsl:for-each>
 </xsl:template>
 <xsl:template name="Datatype">
  <xsl:param name="TypeObj">0</xsl:param>
  <!-- *******************************************************************
Template: Datatype - emit column datatype
Current node: COL_LIST/COL_LIST_ITEM
TypeObj - Number table columns allow col1 number(*,2)
     However, this is not support for type columns.
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="DATATYPE='CHAR' or
                   DATATYPE='VARCHAR2' or
                   DATATYPE='NCHAR' or
                   DATATYPE='NVARCHAR2' or
                   DATATYPE='RAW' or
                   DATATYPE='UROWID'">
    <xsl:value-of select="DATATYPE"/>
    <xsl:if test="LENGTH">
     <xsl:text>(</xsl:text>
     <xsl:value-of select="LENGTH"/>
     <xsl:apply-templates select="CHAR_SEMANTICS"/>
     <xsl:text>)</xsl:text>
    </xsl:if>
   </xsl:when>
   <xsl:when test="DATATYPE='NUMBER' or
                   DATATYPE='FLOAT' or
                   DATATYPE='DECIMAL'">
    <xsl:value-of select="DATATYPE"/>
    <!-- if PRECISION and its not a TYPE object -->
    <xsl:if test="(PRECISION and not (PRECISION/@src='1')) or
                  (SCALE and not (SCALE/@src='1') and $TypeObj ='0')">
     <xsl:text>(</xsl:text>
     <xsl:choose>
      <xsl:when test="PRECISION and not (PRECISION/@src='1')">
       <xsl:value-of select="PRECISION"/>
      </xsl:when>
      <xsl:otherwise>*</xsl:otherwise>
     </xsl:choose>
     <xsl:if test="SCALE and not (SCALE/@src='1') and 
                        (DATATYPE='NUMBER' or DATATYPE='DECIMAL')">
      <xsl:text>,</xsl:text>
      <xsl:value-of select="SCALE"/>
     </xsl:if>
     <xsl:text>)</xsl:text>
    </xsl:if>
   </xsl:when>
   <xsl:when test="DATATYPE='TIME' or
                   DATATYPE='TIMESTAMP'">
    <xsl:value-of select="DATATYPE"/>
    <xsl:if test="SCALE and not(SCALE/@src='1')">
     <xsl:text>(</xsl:text>
     <xsl:value-of select="SCALE"/>
     <xsl:text>)</xsl:text>
    </xsl:if>
   </xsl:when>
   <xsl:when test="DATATYPE='TIME_WITH_TIMEZONE'">
    <xsl:text>TIME </xsl:text>
    <xsl:if test="SCALE and not(SCALE/@src='1')">
     <xsl:text>(</xsl:text>
     <xsl:value-of select="SCALE"/>
     <xsl:text>) </xsl:text>
    </xsl:if>
    <xsl:text>WITH TIME ZONE</xsl:text>
   </xsl:when>
   <xsl:when test="DATATYPE='TIMESTAMP_WITH_TIMEZONE'">
    <xsl:text>TIMESTAMP </xsl:text>
    <xsl:if test="SCALE and not(SCALE/@src='1')">
     <xsl:text>(</xsl:text>
     <xsl:value-of select="SCALE"/>
     <xsl:text>) </xsl:text>
    </xsl:if>
    <xsl:text>WITH TIME ZONE</xsl:text>
   </xsl:when>
   <xsl:when test="DATATYPE='INTERVAL_YEAR_TO_MONTH'">
    <xsl:text>INTERVAL YEAR </xsl:text>
    <xsl:if test="PRECISION and not(PRECISION/@src='1')">
     <xsl:text>(</xsl:text>
     <xsl:value-of select="PRECISION"/>
     <xsl:text>) </xsl:text>
    </xsl:if>
    <xsl:text>TO MONTH</xsl:text>
   </xsl:when>
   <xsl:when test="DATATYPE='INTERVAL_DAY_TO_SECOND'">
    <xsl:text>INTERVAL DAY </xsl:text>
    <xsl:if test="PRECISION  and not(PRECISION/@src='1')">
     <xsl:text>(</xsl:text>
     <xsl:value-of select="PRECISION"/>
     <xsl:text>) </xsl:text>
    </xsl:if>
    <xsl:text>TO SECOND</xsl:text>
    <xsl:if test="SCALE and not(SCALE/@src='1')">
     <xsl:text> (</xsl:text>
     <xsl:value-of select="SCALE"/>
     <xsl:text>) </xsl:text>
    </xsl:if>
   </xsl:when>
   <xsl:when test="DATATYPE='TIMESTAMP_WITH_LOCAL_TIMEZONE'">
    <xsl:text>TIMESTAMP </xsl:text>
    <xsl:if test="SCALE and not(SCALE/@src='1')">
     <xsl:text>(</xsl:text>
     <xsl:value-of select="SCALE"/>
     <xsl:text>) </xsl:text>
    </xsl:if>
    <xsl:text>WITH LOCAL TIME ZONE</xsl:text>
   </xsl:when>
   <xsl:when test="DATATYPE='UDT' or
                   DATATYPE='NESTED_TABLE' or
                   DATATYPE='VARRAY' or
                   DATATYPE='OPAQUE' or
                   DATATYPE='XMLTYPE' or
                   DATATYPE='REF'">
    <xsl:if test="DATATYPE='REF'">REF </xsl:if>
    <xsl:choose>
     <xsl:when test="$CM_MODE=1">
      <xsl:call-template name="TargetSchemaName">
       <xsl:with-param name="ParentNode" select="TYPE_PROPERTIES"/>
      </xsl:call-template>
     </xsl:when>
     <xsl:otherwise>
      <xsl:call-template name="SchemaName">
       <xsl:with-param name="ParentNode" select="TYPE_PROPERTIES"/>
      </xsl:call-template>
     </xsl:otherwise>
    </xsl:choose>
   </xsl:when>
   <xsl:when test="DATATYPE='LONG_RAW'">LONG RAW</xsl:when>
   <xsl:otherwise>
    <xsl:value-of select="DATATYPE"/>
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="ParseDDL">
  <!-- *******************************************************************
Template: ParseDDL - if PRS_DDL is true, emit the delimiter
******************************************************************** -->
  <xsl:if test="$PRS_DDL=1">
   <xsl:value-of select="$PRS_DELIM"/>
   <xsl:text>C</xsl:text>
  </xsl:if>
 </xsl:template>
</xsl:stylesheet>

OHA YOOOO