MINI MINI MANI MO
<?xml version="1.0"?>
<!-- Copyright (c) 2005, 2016, Oracle and/or its affiliates.
All rights reserved.-->
<!--
NAME
kuscommd.xsl
DESCRIPTION
Templates for common and utility functions (SXML-DDL conversion)
MODIFIED MM/DD/YY
jjanosik 09/12/16 - Bug 24387072: add common collation clause template
rapayne 12/15/15 - bug 22165030: fix imc SERVICE name after txn aditigu_sv2.
rapayne 10/20/15 - Bug 22014893: inmemory SERVICE names need to be
quoted.
aditigu 03/03/15 - Bug 20433683: Unspecified IMC attrs should be null
rapayne 03/05/14 - bug 18155007: INMEMORY support.
rapayne 08/15/08 - fix undefined templates reported via the java based
xsl engine.
lbarton 10/09/06 - import kuscommc
slynn 10/15/06 - smartfile->securefile
htseng 07/31/06 - LOBRETENTION support/lrg 2433400
lbarton 11/18/05 - bug 4724986: STORAGE param
rapayne 11/02/05 - Bug 4715313: Reformat with XMLSpy
lbarton 08/10/05 - lbarton_mddiff
lbarton 01/24/05 - 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 -->
<xsl:import href="kuscommc.xsl"/>
<xsl:import href="kuspard.xsl"/>
<xsl:import href="kuscnstd.xsl"/>
<!-- Top-level parameters -->
<xsl:param name="COLLATION_CLAUSE">NEVER</xsl:param>
<!-- All DDL is text, and this is the only way to correctly render '<' -->
<xsl:output method="text"/>
<!-- Templates -->
<!-- *******************************************************************
Top level template for all objects
******************************************************************** -->
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="RESULTSET | ROWSET">
<xsl:for-each select="ROW">
<xsl:apply-templates/>
</xsl:for-each>
</xsl:template>
<xsl:template name="DoTerminator">
<xsl:param name="Text"/>
<!-- *******************************************************************
Template: DoTerminator - Emits terminating / with or without preceding lf
Parameters:
Text: text of last line
******************************************************************** -->
<xsl:if test="$SQLTERMINATOR=1">
<!-- test whether Text ends in lf; if not, insert lf before / -->
<xsl:choose>
<xsl:when test="substring($Text,string-length($Text),1)!=
substring(normalize-space($Text),
string-length(normalize-space($Text)),1)">/</xsl:when>
<xsl:otherwise>
/</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template match="sxml:INMEMORY">
<!-- *******************************************************************
Template: INMEMORY
Description: Generate an INMEMORY clause for in memory columnar support InMemory
Parameters:
InMemory: 1 if object had 'in memory' set; 2 if NO INMEMORY
Priority: 0 = NONE, 1 = LOW, 2 = MEDIUM, 4 = HIGH, 6 = CRITICAL, otherwise "(unknown)"
Compression: 0 = no compression clause,
1 = NO MEMCOMPRESS,
2 = FOR DML
3 = FOR QUERY LOW,
4 = FOR QUERY HIGH,
5 = FOR CAPACITY LOW,
6 = FOR CAPACITY HIGH
Distribute: 0 = <none>, 1 = DISTRIBUTE AUTO, 3 = BY ROWID RANGE
5 = BY PARTITION, 7 = BY SUBPARTITION
Duplicate: 1 = NO DUPLICATE, 2 = DUPLICATE, 3 = DUPLICATE ALL
********************************************************************
The DDL syntax is common, but actual metadata is stored differently for
allocted segmetns, unallocated segments, partition default,
composite partition default, template subapartitions, and tablespaces-->
<xsl:if test="sxml:STATE != 'NONE'">
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
<xsl:if test="sxml:STATE = 'DISABLE'">
<xsl:text> NO</xsl:text>
</xsl:if>
<xsl:text> INMEMORY </xsl:text>
<xsl:if test="sxml:STATE = 'ENABLE'">
<xsl:if test="sxml:PRIORITY">
<xsl:text>PRIORITY </xsl:text>
<xsl:value-of select="sxml:PRIORITY"/>
</xsl:if>
<xsl:choose>
<xsl:when test="sxml:COMPRESSION = 'NONE'">
<xsl:text> NO MEMCOMPRESS </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:if test="sxml:COMPRESSION">
<xsl:text> MEMCOMPRESS </xsl:text>
<xsl:value-of select="sxml:COMPRESSION"/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="sxml:DISTRIBUTE or sxml:FOR_SERVICE">
<xsl:text> DISTRIBUTE </xsl:text>
<xsl:value-of select="sxml:DISTRIBUTE"/>
</xsl:if>
<xsl:if test="sxml:FOR_SERVICE">
<xsl:text> FOR SERVICE </xsl:text>
<xsl:choose>
<xsl:when test="sxml:FOR_SERVICE = 'NONE' or
sxml:FOR_SERVICE = 'DEFAULT' or
sxml:FOR_SERVICE = 'ALL'">
<xsl:value-of select="sxml:FOR_SERVICE"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="QuotedName">
<xsl:with-param name="NameNode" select="sxml:FOR_SERVICE"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="sxml:DUPLICATE">
<xsl:text> </xsl:text>
<xsl:value-of select="sxml:DUPLICATE"/>
</xsl:if>
</xsl:if>
</xsl:if>
<xsl:apply-templates select="sxml:IM_COL_LIST"/>
</xsl:template>
<xsl:template match="sxml:IM_COL_LIST">
<!-- *******************************************************************
Template: IN_COL_LIST
Description:
Compression: 0 = BASIC, 1 = FOR CAPACITY LOW, 2 = FOR QUERY, 3 = FOR CAPACITY HIGH
******************************************************************** -->
<!-- Also, generate any selective column inmemory clauses-->
<xsl:for-each select="sxml:IM_COL_LIST_ITEM">
<xsl:sort order="ascending" select="sxml:COLUMN_NAME"/>
<xsl:variable name="Col" select="sxml:COLUMN_NAME"/>
<xsl:if test="$PRETTY=1 and position()=1">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="sxml:COMPRESSION = 'NO MEMCOMPRESS'">
<xsl:text>INMEMORY </xsl:text>
</xsl:when>
<xsl:when test="sxml:COMPRESSION != 'NO INMEMORY'">
<xsl:text>INMEMORY MEMCOMPRESS </xsl:text>
</xsl:when>
</xsl:choose>
<xsl:value-of select="sxml:COMPRESSION"/>
<xsl:text> ("</xsl:text>
<xsl:value-of select="sxml:COLUMN_NAME"/>
<xsl:text>") </xsl:text>
<xsl:if test="$PRETTY=1 and position()!=last()">
<xsl:text>
 </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="DoCollation">
<xsl:param name="IsDefault" select="''"/>
<xsl:param name="Name" select="''"/>
<xsl:param name="CheckPretty" select="0"/>
<!-- *******************************************************************
Template: DoCollation
Description: Utility routine to generate collation clause for objects.
Parameters:
IsDefault: Is this a default collation or collate clause
Name: The collation name from the XML
CheckPretty: check pretty transform param to add leading newline
Note: changes here should probably also be made in kucommon.xsl
-->
<!-- NOTE: BypassCollation is here to support pre 12.2.0.2 behavior in the
test system only. The value NO_NLS should only be used for testing. -->
<!-- the clause is set to the value for the column or
whatever the user specified (collation_clause != always) -->
<xsl:variable name='BypassCollation'>
<xsl:choose>
<xsl:when test="$COLLATION_CLAUSE = 'NEVER'">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:when test="$COLLATION_CLAUSE = 'NO_NLS' and
$Name = 'USING_NLS_COMP'">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$BypassCollation = '0'">
<xsl:if test="$CheckPretty=1 and $PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
<xsl:variable name='CollationClause'>
<xsl:choose>
<xsl:when test="$COLLATION_CLAUSE = ''">
<xsl:value-of select="$Name"/>
</xsl:when>
<xsl:when test="$COLLATION_CLAUSE != 'ALWAYS' and
$COLLATION_CLAUSE != 'NO_NLS'">
<xsl:value-of select="$COLLATION_CLAUSE"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$Name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$IsDefault = '1'">
<xsl:text> DEFAULT COLLATION </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> COLLATE </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="QuotedName">
<xsl:with-param name="NameNode" select="$CollationClause"/>
</xsl:call-template>
<xsl:if test="$IsDefault = '1'">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
OHA YOOOO