MINI MINI MANI MO
<?xml version="1.0"?>
<!--
NAME
kuseq.xsl
DESCRIPTION
XSLT stylesheet for XML => DDL conversion of ku$_sequence_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
bwright 03/24/15 - Bug 20771546: Support for scalable sequence
tbhukya 03/19/15 - Bug 20722522: Generate XMLTOKENSET for sequence
sogugupt 02/25/15 - Bug 18973146: Correct the KEEP|NOKEEP condition
dvekaria 03/14/14 - Bug 18401399: Specify Global or Session.
lbarton 02/05/14 - bug 17943479: rename doSeqOptions to avoid
ambiguity
bwright 08/16/13 - Bug 17312600: Remove hard tabs from DP src code
rapayne 03/02/12 - bug 13785140: correctly handling version
when processing PARTITION clause.
rapayne 08/05/11 - Project 36780: Identity Column support
slynn 04/11/11 - Project 25215: Sequence Enhancements.
rapayne 11/02/05 - Bug 4715313: Reformat with XMLSpy
htseng 08/02/02 - add grantee parse param
htseng 07/26/02 - add more pparse params
htseng 09/19/01 - Merged htseng_add_xsl_stylesheets
htseng 05/31/01 - Creation
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Import required scripts -->
<xsl:import href="kucommon.xsl"/>
<!-- Top-level parameters -->
<xsl:param name="PRETTY">1</xsl:param>
<xsl:param name="SQLTERMINATOR">1</xsl:param>
<!-- params for parse -->
<xsl:param name="PRS_DDL">0</xsl:param>
<xsl:param name="PRS_DELIM">\{]`</xsl:param>
<xsl:param name="PRS_VERB">0</xsl:param>
<xsl:param name="PRS_OBJECT_TYPE">0</xsl:param>
<xsl:param name="PRS_SCHEMA">0</xsl:param>
<xsl:param name="PRS_NAME">0</xsl:param>
<xsl:param name="PRS_GRANTEE">0</xsl:param>
<xsl:param name="PRS_GRANTOR">0</xsl:param>
<xsl:param name="PRS_BASE_OBJECT_SCHEMA">0</xsl:param>
<xsl:param name="PRS_BASE_OBJECT_NAME">0</xsl:param>
<xsl:param name="PRS_BASE_OBJECT_TYPE">0</xsl:param>
<xsl:template match="SEQUENCE_T">
<xsl:call-template name="DoParse">
<xsl:with-param name="Verb">CREATE</xsl:with-param>
<xsl:with-param name="ObjectType">SEQUENCE</xsl:with-param>
<xsl:with-param name="SchemaNode" select="SCHEMA_OBJ/OWNER_NAME"/>
<xsl:with-param name="NameNode" select="SCHEMA_OBJ/NAME"/>
</xsl:call-template>
<xsl:text> CREATE SEQUENCE </xsl:text>
<xsl:apply-templates select="SCHEMA_OBJ"/>
<!-- Call SeqOptions to generated any create sequence qualifiers.-->
<xsl:call-template name="SeqOptions">
<xsl:with-param name="ParentNode" select="."/>
<xsl:with-param name="StartWith" select="./HIGHWATER"/>
</xsl:call-template>
<xsl:if test="$SQLTERMINATOR=1">
<xsl:text>;</xsl:text>
<!-- Terminate the SQL statement -->
</xsl:if>
</xsl:template>
<xsl:template name="SeqOptions">
<xsl:param name="ParentNode">0</xsl:param>
<xsl:param name="StartWith">0</xsl:param>
<xsl:param name="LimitValue">0</xsl:param>
<!-- *******************************************************************
Template: SeqOptions
Description: Common routines to generate appropriate SEQUENCE object options.
This template is called within this modules and kucolumn.xsl
Parameters:
ParentNode - <SEQUENCE | IDENTITY_COLUMN> node
StartWith - startwith value. For SEQUENCE object this value comes from the
highwater node whereas for TABLES START_WITH is fetched from
the identity_column dictionary table idnseq$.
Sequence - 1 if called from this module
******************************************************************** -->
<xsl:text> MINVALUE </xsl:text>
<xsl:value-of select="$ParentNode/MINVALUE"/>
<xsl:text> MAXVALUE </xsl:text>
<xsl:value-of select="$ParentNode/MAXVALUE"/>
<xsl:text> INCREMENT BY </xsl:text>
<xsl:value-of select="$ParentNode/INCRE"/>
<xsl:text> START WITH </xsl:text>
<xsl:choose>
<xsl:when test="$LimitValue='1'">
<xsl:text> LIMIT VALUE </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$StartWith"/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$ParentNode/CACHE=0">
<xsl:text> NOCACHE </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> CACHE </xsl:text>
<xsl:value-of select="$ParentNode/CACHE"/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$ParentNode/SEQ_ORDER=1">
<xsl:text> ORDER </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> NOORDER </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$ParentNode/CYCLE=1">
<xsl:text> CYCLE </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> NOCYCLE </xsl:text>
</xsl:otherwise>
</xsl:choose>
<!-- Generate XMLTOKENSET if it is part of token set entity -->
<xsl:if test="($ParentNode/FLAGS mod 2048)>=1024">
<xsl:text>XMLTOKENSET</xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="($ParentNode/FLAGS mod 1024)>=512">
<xsl:text> KEEP </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> NOKEEP </xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$VERSION>=1202000000">
<xsl:choose>
<xsl:when test="($ParentNode/FLAGS mod 32)>=16">
<xsl:text> SCALE </xsl:text>
<xsl:choose>
<xsl:when test="($ParentNode/FLAGS mod 4096)>=2048">
<xsl:text> EXTEND </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> NOEXTEND </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:text> NOSCALE </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="local-name($ParentNode)='SEQUENCE_T'">
<xsl:choose>
<xsl:when test="($ParentNode/FLAGS mod 128)>=64">
<xsl:text> SESSION </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> GLOBAL </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
OHA YOOOO