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

<?xml version="1.0"?>
<!--
NAME
    kuaclus.xsl
DESCRIPTION
    Convert sxml CLUSTER diff document to ALTER_XML document

MODIFIED        MM/DD/YY
    tbhukya     03/09/15 - Bug 22899711: Import stylesheet for Constraints 
                           template
    tbhukya     06/24/15 - Bug 21276592: Partitioned cluster
    sogugupt    12/05/14 - Bug 18596422: illegal name attribute value in xsl
    lbarton     10/08/09 - bug 8796742: translatable error messages
    lbarton     07/10/08 - bug 5709159: SQL_LIST_ITEM subelements
    rapayne     07/05/07 - bug 6031401: make column diffs  not_alterable.
    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"/>
 <xsl:import href="kuatprop.xsl"/>
 <xsl:import href="kuscnstd.xsl"/>
 <!-- Templates -->
 <xsl:template match="sxml:CLUSTER">
  <!-- *******************************************************************
Template: CLUSTER - top-level template for clusters
******************************************************************** -->
  <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">CLUSTER</xsl:element>
   <!-- Display schema.objname for CoMPareObjects 1 and 2 -->
   <xsl:call-template name="CmpObjects">
    <xsl:with-param name="ParentNode" select="."/>
   </xsl:call-template>
   <!-- Start alter list -->
   <xsl:element name="ALTER_LIST">
    <!-- Check NAME - rename is not allowed so mark as not_alterable -->
    <xsl:if test="./sxml:NAME[@value1]">
     <xsl:call-template name="CommonNotAlterable">
      <xsl:with-param name="XpathNode" select="./sxml:NAME"/>
      <xsl:with-param name="NameNode" select="./sxml:NAME"/>
      <xsl:with-param name="Reason">RENAME_CLUSTER</xsl:with-param>
      <xsl:with-param name="Message" select="$MSG_RENAME_CLUSTER"/>
     </xsl:call-template>
    </xsl:if>
    <!-- Check COL_LIST - any diffs are marked as not_alterable -->
    <xsl:for-each select="sxml:COL_LIST/sxml:COL_LIST_ITEM">
     <xsl:if test="./@src or sxml:NAME/@value1">
      <xsl:choose>
       <xsl:when test="./@src=2">
        <xsl:call-template name="CommonNotAlterable">
         <xsl:with-param name="XpathNode" select="."/>
         <xsl:with-param name="NameNode" select="./sxml:NAME"/>
         <xsl:with-param name="Reason">ADD_COLUMN</xsl:with-param>
         <xsl:with-param name="Message" select="$MSG_ADD_COLUMN"/>
        </xsl:call-template>
       </xsl:when>
       <xsl:when test="./@src=1">
        <xsl:call-template name="CommonNotAlterable">
         <xsl:with-param name="XpathNode" select="."/>
         <xsl:with-param name="NameNode" select="./sxml:NAME"/>
         <xsl:with-param name="Reason">DELETE_COLUMN</xsl:with-param>
         <xsl:with-param name="Message" select="$MSG_DELETE_COLUMN"/>
        </xsl:call-template>
       </xsl:when>
       <xsl:otherwise>
        <xsl:call-template name="CommonNotAlterable">
         <xsl:with-param name="XpathNode" select="."/>
         <xsl:with-param name="NameNode" select="./sxml:NAME"/>
         <xsl:with-param name="Reason">MODIFY_COLUMN</xsl:with-param>
         <xsl:with-param name="Message" select="$MSG_MODIFY_COLUMN"/>
        </xsl:call-template>
       </xsl:otherwise>
      </xsl:choose>
     </xsl:if>
    </xsl:for-each>
    <!-- Check PhysicalAttributes-->
    <xsl:if test="./sxml:PCTUSED/@value1 or
     ./sxml:PCTFREE/@value1 or
  ./sxml:INITRANS/@value1">
     <xsl:element name="ALTER_LIST_ITEM">
      <xsl:call-template name="AlterClusterAttr">
       <xsl:with-param name="ClusterNode" select="."/>
       <xsl:with-param name="Action">PARSE</xsl:with-param>
      </xsl:call-template>
      <xsl:call-template name="AlterClusterAttr">
       <xsl:with-param name="ClusterNode" select="."/>
       <xsl:with-param name="Action">SQL</xsl:with-param>
      </xsl:call-template>
     </xsl:element>
    </xsl:if>
    <!-- Check CACHE -->
    <xsl:if test="./sxml:CACHE/@src">
     <xsl:element name="ALTER_LIST_ITEM">
      <xsl:call-template name="AlterCache">
       <xsl:with-param name="ClusterNode" select="."/>
       <xsl:with-param name="Action">PARSE</xsl:with-param>
      </xsl:call-template>
      <xsl:call-template name="AlterCache">
       <xsl:with-param name="ClusterNode" select="."/>
       <xsl:with-param name="Action">SQL</xsl:with-param>
      </xsl:call-template>
     </xsl:element>
    </xsl:if>
    <!-- Check SIZE: can not alter size for HASH CLUSTERS -->
    <xsl:if test="./sxml:SIZE/@src or
        ./sxml:SIZE/@value1">
     <xsl:choose>
      <xsl:when test="./sxml:HASHKEYS">
       <xsl:call-template name="CommonNotAlterable">
        <xsl:with-param name="XpathNode" select="./sxml:SIZE"/>
        <xsl:with-param name="Reason">SIZE_ON_HASH_CLUSTER</xsl:with-param>
        <xsl:with-param name="Message" select="$MSG_SIZE_ON_HASH_CLUSTER"/>
       </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
       <xsl:element name="ALTER_LIST_ITEM">
        <xsl:call-template name="AlterSize">
         <xsl:with-param name="ClusterNode" select="."/>
         <xsl:with-param name="SizeNode" select="./sxml:SIZE"/>
         <xsl:with-param name="Action">PARSE</xsl:with-param>
        </xsl:call-template>
        <xsl:call-template name="AlterSize">
         <xsl:with-param name="ClusterNode" select="."/>
         <xsl:with-param name="SizeNode" select="./sxml:SIZE"/>
         <xsl:with-param name="Action">SQL</xsl:with-param>
        </xsl:call-template>
       </xsl:element>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:if>
    <!-- Check PARALLEL -->
    <xsl:if test="./sxml:PARALLEL_DEGREE/sxml:INSTANCES/@value1">
     <xsl:call-template name="CommonNotAlterable">
       <xsl:with-param name="XpathNode" select="./sxml:PARALLEL_DEGREE/sxml:INSTANCES"/>
      <xsl:with-param name="NameNode" select="./sxml:NAME"/>
      <xsl:with-param name="Reason">PARALLEL_INSTANCES</xsl:with-param>
      <xsl:with-param name="Message" select="$MSG_PARALLEL_INSTANCES"/>
     </xsl:call-template>
    </xsl:if>
    <xsl:if test="./sxml:PARALLEL/@src or
        ./sxml:PARALLEL_DEGREE/@src or
        ./sxml:PARALLEL_DEGREE/sxml:DEGREE/@value1">
     <xsl:element name="ALTER_LIST_ITEM">
      <xsl:call-template name="AlterParallel">
       <xsl:with-param name="ParallelNode" select="./sxml:PARALLEL_DEGREE"/>
       <xsl:with-param name="Action">PARSE</xsl:with-param>
      </xsl:call-template>
      <xsl:call-template name="AlterParallel">
       <xsl:with-param name="ParallelNode" select="./sxml:PARALLEL_DEGREE"/>
       <xsl:with-param name="Action">SQL</xsl:with-param>
      </xsl:call-template>
     </xsl:element>
    </xsl:if>
     <!-- alter_cluster_partitioning -->
     <xsl:call-template name="AlterClustPartition">
      <xsl:with-param name="ParentNode" select="."/>
      <xsl:with-param name="ObjType" select="'CLUSTER'"/>
     </xsl:call-template>
   </xsl:element>
  </xsl:element>
 </xsl:template>
 <xsl:template name="AlterClusterAttr">
  <xsl:param name="ClusterNode" select="''"/>
  <xsl:param name="Action" select="''"/>
  <!-- *******************************************************************
Template: AlterClusterAttr - modify the cluster attributes:
    PCTFREE
    PCTUSED 
    INITRANS
    storage_clause
Parameters:
 ClusterNode
Action - PARSE or SQL 
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="$Action='PARSE' and ($PRS_NAME=1 or 
                                        $PRS_CLAUSE_TYPE=1 or
                                        $PRS_COLUMN_ATTRIBUTE=1 or
                                        $PRS_ALTERABLE=1 or
                                        $PRS_XPATH=1)">
    <xsl:element name="PARSE_LIST">
     <xsl:call-template name="AddXPathParseItem">
      <xsl:with-param name="Node" select="$ClusterNode"/>
     </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" select="sxml:NAME"/>
     </xsl:call-template>
     <xsl:call-template name="AddParseItem">
      <xsl:with-param name="ParseIt" select="$PRS_CLAUSE_TYPE"/>
      <xsl:with-param name="Item">CLAUSE_TYPE</xsl:with-param>
      <xsl:with-param name="Value1">CLUSTER_PHYSATTR</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 CLUSTER </xsl:text>
       <xsl:call-template name="SchemaName">
        <xsl:with-param name="ParentNode" select="$ClusterNode"/>
       </xsl:call-template>
       <xsl:call-template name="AlterPhysicalAttributes">
        <xsl:with-param name="ParentNode" select="$ClusterNode"/>
        <xsl:with-param name="TypeNode">MODIFY</xsl:with-param>
       </xsl:call-template>
      </xsl:element>
     </xsl:element>
    </xsl:element>
   </xsl:when>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="AlterCache">
  <xsl:param name="ClusterNode" select="''"/>
  <xsl:param name="Action" select="''"/>
  <!-- *******************************************************************
Template: AlterCache - modify the CACHE attribute
Parameters:
 ClusterNode
 Action - PARSE or SQL 
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="$Action='PARSE' and ($PRS_NAME=1 or 
                                        $PRS_CLAUSE_TYPE=1 or
                                        $PRS_COLUMN_ATTRIBUTE=1 or
                                        $PRS_ALTERABLE=1 or
                                        $PRS_XPATH=1)">
    <xsl:element name="PARSE_LIST">
     <xsl:call-template name="AddXPathParseItem">
      <xsl:with-param name="Node" select="$ClusterNode/sxml:CACHE"/>
     </xsl:call-template>
     <xsl:call-template name="AddParseItem">
      <xsl:with-param name="ParseIt" select="$PRS_CLAUSE_TYPE"/>
      <xsl:with-param name="Item">CLAUSE_TYPE</xsl:with-param>
      <xsl:with-param name="Value1">CLUSTER_CACHE</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 CLUSTER </xsl:text>
       <xsl:call-template name="SchemaName">
        <xsl:with-param name="ParentNode" select="$ClusterNode"/>
       </xsl:call-template>
       <xsl:choose>
        <xsl:when test="$ClusterNode/sxml:CACHE/@src='1'">
         <xsl:text> NOCACHE </xsl:text>
        </xsl:when>
        <xsl:otherwise>
         <xsl:text> CACHE </xsl:text>
        </xsl:otherwise>
       </xsl:choose>
      </xsl:element>
     </xsl:element>
    </xsl:element>
   </xsl:when>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="AlterSize">
  <xsl:param name="ClusterNode" select="''"/>
  <xsl:param name="SizeNode" select="''"/>
  <xsl:param name="Action" select="''"/>
  <!-- *******************************************************************
Template: AlterSize- modify the SIZE attribute. 
     This is not allowed for HASH CLUSTERs
Parameters:
 ClusterNode
 SizeNode
 Action - PARSE or SQL 
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="$Action='PARSE' and ($PRS_NAME=1 or 
                                        $PRS_CLAUSE_TYPE=1 or
                                        $PRS_COLUMN_ATTRIBUTE=1 or
                                        $PRS_ALTERABLE=1 or
                                        $PRS_XPATH=1)">
    <xsl:element name="PARSE_LIST">
     <xsl:call-template name="AddXPathParseItem">
      <xsl:with-param name="Node" select="$SizeNode"/>
     </xsl:call-template>
     <xsl:call-template name="AddParseItem">
      <xsl:with-param name="ParseIt" select="$PRS_CLAUSE_TYPE"/>
      <xsl:with-param name="Item">CLAUSE_TYPE</xsl:with-param>
      <xsl:with-param name="Value1">CLUSTER_SIZE</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 CLUSTER </xsl:text>
       <xsl:call-template name="SchemaName">
        <xsl:with-param name="ParentNode" select="$ClusterNode"/>
       </xsl:call-template>
       <xsl:text> SIZE  </xsl:text>
       <xsl:value-of select="$SizeNode"/>
      </xsl:element>
     </xsl:element>
    </xsl:element>
   </xsl:when>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="AlterParallel">
  <xsl:param name="ParallelNode" select="''"/>
  <xsl:param name="Action" select="''"/>
  <!-- *******************************************************************
Template: AlterParallel - modify the PARALLEL attribute
Parameters:
 ParallelNode
 Action - PARSE or SQL 
******************************************************************** -->
  <xsl:choose>
   <xsl:when test="$Action='PARSE' and ($PRS_NAME=1 or 
                                        $PRS_CLAUSE_TYPE=1 or
                                        $PRS_COLUMN_ATTRIBUTE=1 or
                                        $PRS_ALTERABLE=1 or
                                        $PRS_XPATH=1)">
    <xsl:element name="PARSE_LIST">
     <xsl:call-template name="AddXPathParseItem">
      <xsl:with-param name="Node" select="$ParallelNode"/>
     </xsl:call-template>
     <xsl:choose>
      <xsl:when test="$ParallelNode/@src='2'">
       <xsl:call-template name="AddParseItem">
        <xsl:with-param name="ParseIt" select="$PRS_CLAUSE_TYPE"/>
        <xsl:with-param name="Item">CLAUSE_TYPE</xsl:with-param>
        <xsl:with-param name="Value1">ADD_PARALLEL</xsl:with-param>
       </xsl:call-template>
      </xsl:when>
      <xsl:when test="$ParallelNode/@src='1'">
       <xsl:call-template name="AddParseItem">
        <xsl:with-param name="ParseIt" select="$PRS_CLAUSE_TYPE"/>
        <xsl:with-param name="Item">CLAUSE_TYPE</xsl:with-param>
        <xsl:with-param name="Value1">REMOVE_PARALLEL</xsl:with-param>
       </xsl:call-template>
      </xsl:when>
      <xsl:when test="$ParallelNode/sxml:DEGREE/@value1">
       <xsl:call-template name="AddParseItem">
        <xsl:with-param name="ParseIt" select="$PRS_CLAUSE_TYPE"/>
        <xsl:with-param name="Item">CLAUSE_TYPE</xsl:with-param>
        <xsl:with-param name="Value1">MODIFY_PARALLEL</xsl:with-param>
       </xsl:call-template>
      </xsl:when>
     </xsl:choose>
    </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 CLUSTER </xsl:text>
       <xsl:call-template name="SchemaName">
        <xsl:with-param name="ParentNode" select="."/>
       </xsl:call-template>
       <xsl:choose>
        <xsl:when test="$ParallelNode/@src='2' or $ParallelNode/sxml:DEGREE/@value1">
         <xsl:text> PARALLEL </xsl:text>
         <xsl:value-of select="$ParallelNode/sxml:DEGREE"/>
        </xsl:when>
        <xsl:when test="$ParallelNode/@src='1'">
         <xsl:text> NOPARALLEL</xsl:text>
        </xsl:when>
       </xsl:choose>
      </xsl:element>
     </xsl:element>
    </xsl:element>
   </xsl:when>
  </xsl:choose>
 </xsl:template>
 <xsl:template name="AlterClustPartition">
  <xsl:param name="ParentNode" select="''"/>
  <xsl:param name="ObjType" select="''"/>
  <!-- *******************************************************************
       Template: AlterMVPartition
       Current node:
       Parameters:
          ParentNode - CLUSTER
          ObjType    - 'CLUSTER'
       ******************************************************************** -->
  <!-- useful variables -->
  <xsl:variable name="PartitionType">
   <xsl:choose>
    <xsl:when test="$ParentNode/sxml:RANGE_PARTITIONING">RANGE</xsl:when>
   </xsl:choose>
  </xsl:variable>
  <xsl:variable name="PartitioningNode" select="$ParentNode/sxml:RANGE_PARTITIONING"/>
  <xsl:if test="$ParentNode/sxml:RANGE_PARTITIONING/@src or
                $PartitioningNode//sxml:COL_LIST//@src or
                $PartitioningNode//sxml:COL_LIST//@value1 or 
                $PartitioningNode//sxml:PARTITION_LIST//@src or
                $PartitioningNode//sxml:PARTITION_LIST//@value1">
   <xsl:call-template name="CommonNotAlterable">
    <xsl:with-param name="XpathNode" select="$ParentNode"/>
    <xsl:with-param name="NameNode" select="sxml:NAME"/>
    <xsl:with-param name="Reason">MODIFY_COLUMN</xsl:with-param>
    <xsl:with-param name="Message" select="$MSG_MODIFY_COLUMN"/>
   </xsl:call-template>
  </xsl:if>
 </xsl:template>
</xsl:stylesheet>

OHA YOOOO