MINI MINI MANI MO
<?xml version="1.0"?>
<!--
NAME
kuview.xsl
DESCRIPTION
XSLT stylesheet for XML => DDL conversion of md$_view_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
tbhukya 04/12/17 - Bug 25791822: Generate constraints in object view
tbhukya 03/22/17 - Bug 25715449: Constraint with READ ONLY
jjanosik 08/19/16 - bug 24387072 - fix how/when the collation clause
is output
tbhukya 08/04/16 - Bug 24313182: Add double quotes to collation name
tbhukya 02/02/16 - Bug 22646022: Remove incorrect colon
tbhukya 09/30/15 - Bug 21886016: Generate collation when
max_string_size=extended and version >=12.2
tbhukya 03/15/15 - Proj 47173: Data bound collation
bwright 08/21/13 - Bug 17312600: Remove hard tabs from DP src code
rapayne 01/20/13 - bug 15917102: remove trailing spaces when processing
UNDERTEXT. This allows generated ddl from xml and
sxml to match in tkmadfview2 test.
rapayne 11/02/12 - bug 15832675: support for BEQUEATH CURRENT_USER.
traney 08/02/12 - 14407652: [non]editionable
rapayne 03/16/12 - bug 13849454: correct ADT_Type in calls out to
COL_LIST
lbarton 01/26/12 - gravipat_bug-12667763: CONTAINER_DATA keyword
akrugli 09/07/06 - Column Map Views got rechristened as Editioning
Views
rapayne 06/07/06 - add support for editioning views.
sdavidso 11/02/05 - fix inconsistent stylesheet format
lbarton 08/06/03 - Bug 3056720: support long view text
htseng 12/18/02 - add EXPORT parameter
htseng 08/02/02 - add grantee parse param
htseng 07/29/02 - add more parse params
htseng 08/07/02 - add condition to generate CONSTRAINT or not
lbarton 05/06/02 - support subviews
lbarton 10/25/01 - xdb support
dgagne 07/16/01 - update for constraints on views
lbarton 06/01/01 - remove oradb-style imports
lbarton 11/10/00 - support long views
lbarton 10/26/00 - fix sqlterminator bug
gclaborn 10/30/00 - Add external imports; change name
lbarton 07/24/00 - use uriref in import
lbarton 07/03/00 - fix sqlterminator bug
lbarton 06/02/00 - support parsing
lbarton 05/15/00 - Created
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Import required scripts -->
<xsl:import href="kucommon.xsl"/>
<xsl:import href="kucolumn.xsl"/>
<xsl:import href="kutable.xsl"/>
<!-- Top-level parameters -->
<xsl:param name="PRETTY">1</xsl:param>
<xsl:param name="SQLTERMINATOR">1</xsl:param>
<xsl:param name="FORCE">1</xsl:param>
<xsl:param name="CONSTRAINTS">1</xsl:param>
<xsl:param name="EXPORT">0</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="VIEW_T">
<xsl:call-template name="DoParse">
<xsl:with-param name="Verb">CREATE</xsl:with-param>
<xsl:with-param name="ObjectType">VIEW</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 </xsl:text>
<xsl:if test="$EXPORT=0">
<xsl:text>OR REPLACE </xsl:text>
</xsl:if>
<xsl:if test="$FORCE=1">FORCE </xsl:if>
<xsl:call-template name="Editionable">
<xsl:with-param name="SchemaObjNode" select="SCHEMA_OBJ"/>
</xsl:call-template>
<!-- Editioning Views -->
<xsl:if test="(PROPERTY mod 64)>=32">EDITIONING </xsl:if>
<xsl:text>VIEW </xsl:text>
<xsl:apply-templates select="SCHEMA_OBJ"/>
<xsl:choose>
<xsl:when test="(PROPERTY mod 2)>=1">
<!-- object view -->
<xsl:text>OF </xsl:text>
<xsl:call-template name="QuoteObject">
<xsl:with-param name="Schema" select="OWNER_NAME"/>
<xsl:with-param name="Object" select="NAME"/>
</xsl:call-template>
<xsl:if test="$CONSTRAINTS=1 and
(CON0_LIST and CON0_LIST/CON0_LIST_ITEM or
CON1_LIST and CON1_LIST/CON1_LIST_ITEM or
CON2_LIST and CON2_LIST/CON2_LIST_ITEM) and
not(NAME='XMLTYPE' and OWNER_NAME='SYS' and
COL_LIST2/COL_LIST2_ITEM[NAME='SYS_NC_ROWINFO$']/OPQMD/SCHEMA_ELMT)">
<xsl:text>(</xsl:text>
<xsl:call-template name="GenTableConstraints">
<xsl:with-param name="SchemaObjParent" select="current()"/>
<xsl:with-param name="ListParent" select="current()"/>
<xsl:with-param name="InColList">1</xsl:with-param>
<xsl:with-param name="CommaNeeded">0</xsl:with-param>
<xsl:with-param name="Property" select="PROPERTY"/>
</xsl:call-template>
<xsl:text>)</xsl:text>
</xsl:if>
<xsl:if test="NAME='XMLTYPE' and OWNER_NAME='SYS' and
COL_LIST2/COL_LIST2_ITEM[NAME='SYS_NC_ROWINFO$']/OPQMD/SCHEMA_ELMT">
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
<xsl:apply-templates select="COL_LIST2/COL_LIST2_ITEM[NAME='SYS_NC_ROWINFO$']/OPQMD/SCHEMA_ELMT"/>
</xsl:if>
<xsl:if test="OIDTEXTLENGTH > 0">
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
<xsl:text> WITH OBJECT IDENTIFIER (</xsl:text>
<xsl:value-of select="OIDTEXT"/>
<xsl:text>)</xsl:text>
</xsl:if>
<xsl:if test="UNDERTEXTLENGTH > 0">
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
<xsl:text> </xsl:text>
<xsl:value-of select="normalize-space(UNDERTEXT)"/>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<!-- relational view -->
<xsl:if test="PROPERTY2 and (PROPERTY2 mod 268435456)>=134217728">
<xsl:text> CONTAINER_DATA </xsl:text>
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
</xsl:if>
<xsl:text>(</xsl:text>
<xsl:apply-templates select="COL_LIST">
<xsl:with-param name="ADT_type">VIEW</xsl:with-param>
<xsl:with-param name="DoLF">0</xsl:with-param>
<xsl:with-param name="DoHidden">1</xsl:with-param>
</xsl:apply-templates>
<xsl:if test="$CONSTRAINTS=1">
<xsl:call-template name="GenTableConstraints">
<xsl:with-param name="SchemaObjParent" select="current()"/>
<xsl:with-param name="ListParent" select="current()"/>
<xsl:with-param name="InColList">1</xsl:with-param>
<xsl:with-param name="CommaNeeded">1</xsl:with-param>
<xsl:with-param name="Property" select="PROPERTY"/>
</xsl:call-template>
</xsl:if>
<xsl:text>)</xsl:text>
</xsl:otherwise>
</xsl:choose>
<!-- Generate collation clause when version is 12.2 or higher
and dflcollname exists -->
<xsl:if test="$VERSION>=1202000000 and
SCHEMA_OBJ and SCHEMA_OBJ/DFLCOLLNAME">
<xsl:call-template name="DoCollation">
<xsl:with-param name="IsDefault">1</xsl:with-param>
<xsl:with-param name="Name" select="SCHEMA_OBJ/DFLCOLLNAME"/>
</xsl:call-template>
</xsl:if>
<!-- If version > 12.1 and the BEQUEATH flag is set then
add the appropriate clause
-->
<xsl:if test="(SCHEMA_OBJ/FLAGS mod 16) >= 8 and $VERSION>=1200000000">
<xsl:text> BEQUEATH CURRENT_USER </xsl:text>
</xsl:if>
<xsl:text> AS </xsl:text>
<xsl:if test="$PRETTY=1">
<xsl:text>
 </xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="TEXTVCNT">
<xsl:for-each select="TEXTVCNT/TEXTVCNT_ITEM">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="TEXT"/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="(WITH_OPTION/FLAGS mod 16)>=8"/>
<xsl:otherwise>
<xsl:if test="string-length(WITH_OPTION/NAME)!=0">
<!-- Space before constraint is not needed as space is included in
above TEXT value -->
<xsl:text>CONSTRAINT "</xsl:text>
<xsl:value-of select="WITH_OPTION/NAME"/>
<xsl:text>"</xsl:text>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$SQLTERMINATOR=1">
<xsl:text>;</xsl:text>
<!-- Terminate the SQL statement -->
</xsl:if>
</xsl:template>
</xsl:stylesheet>
OHA YOOOO