MINI MINI MANI MO
<?xml version="1.0"?>
<!--
Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
NAME
kuaseq.xsl
DESCRIPTION
Convert sxml SEQUENCE diff document to ALTER_XML document
MODIFIED MM/DD/YY
bwright 03/24/15 - Bug 20771546: Support for scalable sequence
sogugupt 12/05/14 - Bug 18596422: illegal name attribute value in xsl
slynn 04/11/11 - Project 25215: Sequence enhancements.
lbarton 01/13/10 - bug 8796742: translatable error messages
lbarton 07/10/08 - bug 5709159: SQL_LIST_ITEM subelements
lbarton 12/29/06 - more features
rapayne 06/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 -->
<xsl:import href="kuacomm.xsl"/>
<!-- Templates -->
<xsl:template match="sxml:SEQUENCE">
<!-- *******************************************************************
Template: SEQUENCE - top-level template for sequences.
******************************************************************** -->
<xsl:element name="ALTER_XML" namespace="http://xmlns.oracle.com/ku">
<xsl:attribute name="version">1.0</xsl:attribute>
<!-- Object type -->
<xsl:element name="OBJECT_TYPE">SEQUENCE</xsl:element>
<!-- Display schema.objname for CoMPareObjects 1 and 2 -->
<xsl:call-template name="CmpObjects">
<xsl:with-param name="ParentNode" select="."/>
</xsl:call-template>
<!-- Alter list -->
<xsl:element name="ALTER_LIST">
<!-- NOT_ALTERABLE cases -->
<xsl:if test="sxml:NAME/@value1">
<xsl:call-template name="CommonNotAlterable">
<xsl:with-param name="XpathNode" select="./sxml:NAME"/>
<xsl:with-param name="Reason">SEQUENCE_ATTRIBUTE</xsl:with-param>
<xsl:with-param name="Message" select="$MSG_SEQUENCE_ATTRIBUTE"/>
<xsl:with-param name="Subst">NAME</xsl:with-param>
</xsl:call-template>
</xsl:if>
<xsl:if test="sxml:START_WITH/@value1">
<xsl:if test="1200000000>$VERSION">
<!-- before 12c, START WITH wasn't allowed in ALTER -->
<xsl:call-template name="CommonNotAlterable">
<xsl:with-param name="XpathNode" select="./sxml:START_WITH"/>
<xsl:with-param name="Reason">SEQUENCE_ATTRIBUTE</xsl:with-param>
<xsl:with-param name="Message" select="$MSG_SEQUENCE_ATTRIBUTE"/>
<xsl:with-param name="Subst">START_WITH</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:if>
<xsl:if test="sxml:INCREMENT/@value1 or
sxml:MINVALUE/@value1 or
sxml:MAXVALUE/@value1 or
sxml:CYCLE/@src or
sxml:CACHE/@value1 or
sxml:ORDER/@src or
sxml:PARTITION/@src or
sxml:PARTITION/@value1 or
sxml:START_WITH/@value1">
<xsl:element name="ALTER_LIST_ITEM">
<xsl:call-template name="AlterSeq">
<xsl:with-param name="Action">PARSE</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="AlterSeq">
<xsl:with-param name="Action">SQL</xsl:with-param>
</xsl:call-template>
</xsl:element>
</xsl:if>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template name="AlterSeq">
<xsl:param name="Action" select="''"/>
<!-- *******************************************************************
Template: AlterSeq
Parameters:
Action - PARSE or SQL
******************************************************************** -->
<xsl:choose>
<xsl:when test="$Action='PARSE' and ($PRS_NAME=1 or
$PRS_XPATH=1)">
<xsl:element name="PARSE_LIST">
<xsl:call-template name="AddXPathParseItem">
<xsl:with-param name="Node" select="."/>
</xsl:call-template>
<xsl:call-template name="AddParseItem">
<xsl:with-param name="ParseIt" select="$PRS_NAME"/>
<xsl:with-param name="Item">NAME</xsl:with-param>
<xsl:with-param name="Value1">
<xsl:choose>
<xsl:when test="sxml:NAME[@value1]">
<xsl:value-of select="sxml:NAME/@value1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="sxml:NAME"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:element>
</xsl:when>
<xsl:when test="$Action='SQL'">
<xsl:element name="SQL_LIST">
<xsl:element name="SQL_LIST_ITEM">
<xsl:element name="TEXT">
<xsl:text>ALTER SEQUENCE </xsl:text>
<xsl:call-template name="SchemaName">
<xsl:with-param name="ParentNode" select="."/>
</xsl:call-template>
<xsl:if test="sxml:INCREMENT[@value1]">
<xsl:text> INCREMENT BY </xsl:text>
<xsl:value-of select="sxml:INCREMENT"/>
</xsl:if>
<xsl:if test="sxml:MINVALUE[@value1]">
<xsl:text> MINVALUE </xsl:text>
<xsl:value-of select="sxml:MINVALUE"/>
</xsl:if>
<xsl:if test="sxml:MAXVALUE[@value1]">
<xsl:choose>
<xsl:when test="sxml:MAXVALUE='999999999999999999999999999'">
<xsl:text> NOMAXVALUE </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> MAXVALUE </xsl:text>
<xsl:value-of select="sxml:MAXVALUE"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="sxml:CYCLE/@src='1'"> NOCYCLE</xsl:if>
<xsl:if test="sxml:CYCLE/@src='2'"> CYCLE</xsl:if>
<xsl:if test="sxml:CACHE[@value1]">
<xsl:choose>
<xsl:when test="sxml:CACHE='0'">
<xsl:text> NOCACHE</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> CACHE </xsl:text>
<xsl:value-of select="sxml:CACHE"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="sxml:ORDER/@src='1'"> NOORDER</xsl:if>
<xsl:if test="sxml:ORDER/@src='2'"> ORDER</xsl:if>
<!-- If SCALE is only in the new document, only generate
an alter if the new value is other than the default
of NOSCALE. Or if both the old and new document have
different values for SCALE, then generate the alter to
set SCALE to the new value -->
<xsl:if test="($VERSION>=1202000000) and
((sxml:SCALE/@src='2' and sxml:SCALE!='NOSCALE') or
sxml:SCALE/@value1)">
<xsl:choose>
<xsl:when test="sxml:SCALE='NOSCALE'">
<xsl:text> NOSCALE </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> SCALE </xsl:text>
<xsl:value-of select="sxml:SCALE"/>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="sxml:START_WITH[@value1]">
<!-- In 12c, we have RESTART to allow new START WITH values -->
<xsl:text> RESTART START WITH </xsl:text>
<xsl:value-of select="sxml:START_WITH"/>
</xsl:if>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
OHA YOOOO