home *** CD-ROM | disk | FTP | other *** search
/ ftp.tcs3.com / ftp.tcs3.com.tar / ftp.tcs3.com / DRIVERS / Audio / Office2010 / ProPlus.WW / ProPsWW.cab / AS_ClientSql90_xsl_32.C16C67A1_5ADC_4C44_B6AE_A40000020FCC < prev    next >
Extensible Markup Language  |  2009-03-29  |  40KB  |  916 lines

  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0" xmlns:mssqlcrt="urn:sql-microsoft-com:sqlcrt" xmlns:mssqldbg="urn:sql-microsoft-com:sqldbg">
  3.     <xsl:output method="xml" indent="yes"/>
  4.  
  5.     <!-- This ALWAYS GENERATED file contains the definitions for the cartridges
  6.                  Microsoft Cartridge Interfaces (Analysis Services 2005)
  7.                  (C) Copyright 1988 - 2003 By Microsoft Corporation.      -->
  8.  
  9.  
  10.     <!-- Area of Custom parametrizations: these may be modified by customers for specific query customizations  -->
  11.     <!-- post-select-query-hint will append the customer-defined string at the end of the generated SELECT statement - e.g. WITH UR -->
  12.     <xsl:param name="post-select-query-hint"></xsl:param>
  13.  
  14.   <!-- SQL Server 90 pluggable cartridge                              -->
  15.  
  16.   <!-- Area of STANDARD parametrizations: these are externally passed   -->
  17.   <xsl:param name="in_CanUseParams">yes</xsl:param>
  18.   <xsl:param name="in_IdentStartQuotingCharacter">[</xsl:param>
  19.   <xsl:param name="in_IdentEndQuotingCharacter">]</xsl:param>
  20.   <xsl:param name="in_StringStartQuotingCharacter">N'</xsl:param>
  21.   <xsl:param name="in_StringEndQuotingCharacter">'</xsl:param>
  22.  
  23.   <!-- Area of CORE parametrizations: These are externally checked      -->
  24.   <mssqlcrt:provider type="prefix" managed="yes" native="yes">Microsoft SQL Server.09</mssqlcrt:provider>
  25.   <mssqlcrt:provider type="prefix" managed="yes" native="yes">Microsoft SQL Server.10</mssqlcrt:provider>
  26.   <mssqlcrt:parameter-style native="unnamed" managed="named"/>
  27.  
  28.   <mssqlcrt:capabilities>
  29.     <mssqlcrt:supports-datepart-year/>
  30.     <mssqlcrt:supports-datepart-quarter/>
  31.     <mssqlcrt:supports-datepart-month/>
  32.     <mssqlcrt:supports-datepart-dayofyear/>
  33.     <mssqlcrt:supports-datepart-day/>
  34.     <mssqlcrt:supports-datepart-week/>
  35.     <mssqlcrt:supports-datepart-dayofweek/>
  36.     <mssqlcrt:supports-datepart-hour/>
  37.     <mssqlcrt:supports-datepart-minute/>
  38.     <mssqlcrt:supports-datepart-second/>
  39.     <mssqlcrt:supports-datepart-millisecond/>
  40.     <mssqlcrt:supports-multiple-distinct-count/>
  41.     <mssqlcrt:supports-update/>
  42.     <mssqlcrt:supports-insert/>
  43.     <mssqlcrt:supports-subselect/>
  44.     <mssqlcrt:supports-table-alias/>
  45.     <mssqlcrt:supports-column-alias/>
  46.     <mssqlcrt:supports-cast/>
  47.     <mssqlcrt:supports-remote-query/>
  48.     <mssqlcrt:supports-top-clause/>
  49.     <mssqlcrt:supports-union/>
  50.     <mssqlcrt:supports-union-all/>
  51.     <mssqlcrt:supports-fast-writeback>TABLOCK,FIRE_TRIGGERS</mssqlcrt:supports-fast-writeback>
  52.     <mssqlcrt:supports-recursive-select>1</mssqlcrt:supports-recursive-select>
  53.     <mssqlcrt:supports-materialized-view>2</mssqlcrt:supports-materialized-view>
  54.     <!-- mssqlcrt:supports-materialized-view-prevalidation -->
  55.  
  56.     <mssqlcrt:limit-materialized-view-column-count>16</mssqlcrt:limit-materialized-view-column-count>
  57.     <!--
  58.             This cartridge is used as the default cartridge for unknown providers
  59.             So even though SQL supports larger aliases (at least 128), we'll use a smaller
  60.             alias for the other providers
  61.         -->
  62.     <mssqlcrt:limit-table-identifier-length>64</mssqlcrt:limit-table-identifier-length>
  63.     <mssqlcrt:limit-column-identifier-length>64</mssqlcrt:limit-column-identifier-length>
  64.  
  65.     <!-- Map from MSDAInitialize connection string to SQLOLEDB connection string -->
  66.     <mssqlcrt:remote-connection-string-mappings>
  67.       <mssqlcrt:remote-connection-string-mapping>
  68.         <mssqlcrt:datasource-property>Provider</mssqlcrt:datasource-property>
  69.         <mssqlcrt:remote-property></mssqlcrt:remote-property>
  70.       </mssqlcrt:remote-connection-string-mapping>
  71.       <mssqlcrt:remote-connection-string-mapping>
  72.         <mssqlcrt:datasource-property>Data Source</mssqlcrt:datasource-property>
  73.         <mssqlcrt:remote-property>Server</mssqlcrt:remote-property>
  74.       </mssqlcrt:remote-connection-string-mapping>
  75.       <mssqlcrt:remote-connection-string-mapping>
  76.         <mssqlcrt:datasource-property>Initial Catalog</mssqlcrt:datasource-property>
  77.         <mssqlcrt:remote-property>Database</mssqlcrt:remote-property>
  78.       </mssqlcrt:remote-connection-string-mapping>
  79.       <mssqlcrt:remote-connection-string-mapping>
  80.         <mssqlcrt:datasource-property>User ID</mssqlcrt:datasource-property>
  81.         <mssqlcrt:remote-property>UID</mssqlcrt:remote-property>
  82.       </mssqlcrt:remote-connection-string-mapping>
  83.       <mssqlcrt:remote-connection-string-mapping>
  84.         <mssqlcrt:datasource-property>Password</mssqlcrt:datasource-property>
  85.         <mssqlcrt:remote-property>PWD</mssqlcrt:remote-property>
  86.       </mssqlcrt:remote-connection-string-mapping>
  87.       <mssqlcrt:remote-connection-string-mapping>
  88.         <mssqlcrt:datasource-property>Integrated Security=SSPI</mssqlcrt:datasource-property>
  89.         <mssqlcrt:remote-property>Trusted_Connection=yes</mssqlcrt:remote-property>
  90.       </mssqlcrt:remote-connection-string-mapping>
  91.     </mssqlcrt:remote-connection-string-mappings>
  92.   </mssqlcrt:capabilities>
  93.  
  94.   <mssqlcrt:schema-classes>
  95.     <mssqlcrt:schema-class>
  96.       <mssqlcrt:managed-provider>System.Data.SqlClient</mssqlcrt:managed-provider>
  97.       <mssqlcrt:type>Microsoft.DataWarehouse.Design.SqlSchema, Microsoft.DataWarehouse</mssqlcrt:type>
  98.       <mssqlcrt:query-designer>
  99.         <mssqlcrt:type>Microsoft.DataWarehouse.Controls.SqlClientQueryDesigner, Microsoft.DataWarehouse</mssqlcrt:type>
  100.       </mssqlcrt:query-designer>
  101.     </mssqlcrt:schema-class>
  102.     <mssqlcrt:schema-class>
  103.       <mssqlcrt:managed-provider>System.Data.OleDb</mssqlcrt:managed-provider>
  104.       <mssqlcrt:type>Microsoft.DataWarehouse.Design.OleDbSchema, Microsoft.DataWarehouse</mssqlcrt:type>
  105.       <mssqlcrt:query-designer>
  106.         <mssqlcrt:type>Microsoft.DataWarehouse.Controls.OleDbQueryDesigner, Microsoft.DataWarehouse</mssqlcrt:type>
  107.       </mssqlcrt:query-designer>
  108.     </mssqlcrt:schema-class>
  109.     <mssqlcrt:schema-class>
  110.       <mssqlcrt:managed-provider>System.Data.Odbc</mssqlcrt:managed-provider>
  111.       <mssqlcrt:type>Microsoft.DataWarehouse.Design.OdbcSchema, Microsoft.DataWarehouse</mssqlcrt:type>
  112.     </mssqlcrt:schema-class>
  113.   </mssqlcrt:schema-classes>
  114.     <!-- Area of internal parametrizations                                -->
  115.     <!-- overrideOfUseParams:
  116.              yes      = use always parametric queries
  117.              no       = never use parametric queries
  118.              nosubsel = use as yes, but not on subselects
  119.              auto     = use the value of in_CanUseParams to determine     -->
  120.     <xsl:variable name="overrideOfUseParams">auto</xsl:variable>
  121.     <!-- shouldProduceDebug:
  122.              yes      = produce debug information
  123.              no       = do not produce debug information                  -->
  124.     <xsl:variable name="shouldProduceDebug">yes</xsl:variable>
  125.  
  126.     <!-- Area of global variables initializations                         -->
  127.     <xsl:variable name="UseParams">
  128.         <xsl:choose>
  129.             <xsl:when test="normalize-space($overrideOfUseParams) = 'yes' or (normalize-space($overrideOfUseParams) = 'auto' and normalize-space($in_CanUseParams)='yes')">yes</xsl:when>
  130.             <xsl:when test="normalize-space($overrideOfUseParams) = 'nosubsel'">nosubsel</xsl:when>
  131.             <xsl:otherwise>no</xsl:otherwise>
  132.         </xsl:choose>
  133.     </xsl:variable>
  134.     <xsl:variable name="ProduceDebug" select="$shouldProduceDebug"/>
  135.     <xsl:variable name="IdentifierStartQuotingCharacter" select="normalize-space($in_IdentStartQuotingCharacter)"/>
  136.     <xsl:variable name="IdentifierEndQuotingCharacter" select="normalize-space($in_IdentEndQuotingCharacter)"/>
  137.     <xsl:variable name="StringStartQuotingCharacter" select="normalize-space($in_StringStartQuotingCharacter)"/>
  138.     <xsl:variable name="StringEndQuotingCharacter" select="normalize-space($in_StringEndQuotingCharacter)"/>
  139.  
  140.     <!-- Generated statement packaging                                    -->
  141.     <xsl:template match="/">
  142.         <xsl:element name="Statement">
  143.  
  144.             <!-- Generate query                                           -->
  145.             <xsl:element name="Text">
  146.                 <xsl:apply-templates select="./Statement/*[1]"/>
  147.             </xsl:element>
  148.  
  149.             <!-- Generate parameters                                      -->
  150.             <xsl:if test="count(./Statement/Parameters/Parameter)!=0 and ((normalize-space($UseParams)='yes') or (normalize-space($UseParams)='nosubsel'))">
  151.                 <xsl:element name="Parameters">
  152.                     <xsl:choose>
  153.                         <xsl:when test="/Statement/*[1]//Parameter/@ParamName">
  154.                             <xsl:for-each select="./Statement/Parameters/Parameter">
  155.                                 <xsl:element name="Parameter">
  156.                                     <xsl:attribute name="ref">
  157.                                         <xsl:value-of select="./@id"/>
  158.                                     </xsl:attribute>
  159.                                 </xsl:element>
  160.                             </xsl:for-each>
  161.                         </xsl:when>
  162.                         <xsl:otherwise>
  163.                             <xsl:for-each select="./Statement/*[1]//Parameter">
  164.                                 <xsl:element name="Parameter">
  165.                                     <xsl:attribute name="ref">
  166.                                         <xsl:value-of select="./@ref"/>
  167.                                     </xsl:attribute>
  168.                                 </xsl:element>
  169.                             </xsl:for-each>
  170.                         </xsl:otherwise>
  171.                     </xsl:choose>
  172.                 </xsl:element>
  173.             </xsl:if>
  174.  
  175.             <!-- Generate debug info                                      -->
  176.             <xsl:if test="$ProduceDebug='yes'">
  177.                 <xsl:element name="mssqldbg:DebugInfo">
  178.                     <xsl:element name="mssqldbg:GenerateParametricInfo">
  179.                         <xsl:attribute name="mssqldbg:Value">
  180.                             <xsl:value-of select="$UseParams"/>
  181.                         </xsl:attribute>
  182.                         <xsl:element name="mssqldbg:External">
  183.                             <xsl:value-of select="$in_CanUseParams"/>
  184.                         </xsl:element>
  185.                         <xsl:element name="mssqldbg:Internal">
  186.                             <xsl:value-of select="$overrideOfUseParams"/>
  187.                         </xsl:element>
  188.                     </xsl:element>
  189.                 </xsl:element>
  190.             </xsl:if>
  191.  
  192.         </xsl:element>
  193.     </xsl:template>
  194.  
  195.     <!-- Union statement                                                  -->
  196.     <xsl:template match="Union">
  197.         <xsl:if test="name(..) != 'Statement' and name(..) != 'Insert'">
  198.             (
  199.         </xsl:if>
  200.             <xsl:call-template name="print-children-list">
  201.                 <xsl:with-param name="operator" select="' UNION '"/>
  202.             </xsl:call-template>
  203.         <xsl:if test="name(..) != 'Statement' and name(..) != 'Insert'">
  204.             )
  205.         </xsl:if>
  206.     </xsl:template>
  207.  
  208.     <!-- Union All statement                                                  -->
  209.     <xsl:template match="UnionAll">
  210.         <xsl:if test="name(..) != 'Statement' and name(..) != 'Insert'">
  211.             (
  212.         </xsl:if>
  213.             <xsl:call-template name="print-children-list">
  214.                 <xsl:with-param name="operator" select="' UNION ALL '"/>
  215.             </xsl:call-template>
  216.         <xsl:if test="name(..) != 'Statement' and name(..) != 'Insert'">
  217.             )
  218.         </xsl:if>
  219.     </xsl:template>
  220.  
  221.     <!-- Top clause                                                       -->
  222.     <xsl:template match="Top">
  223.         TOP <xsl:value-of select="."/><xsl:text> </xsl:text>
  224.     </xsl:template>
  225.  
  226.     <!-- Select statement                                                 -->
  227.     <xsl:template match="Select">
  228.         <xsl:choose>
  229.             <xsl:when test="count(./ColumnExpressions/IsValidForIndexing) != 0">
  230.                 SELECT OBJECTPROPERTY( object_id('<xsl:apply-templates select="./Sources/View"/>'), 'isindexable' )
  231.             </xsl:when>
  232.             <xsl:when test="name(..) != 'Statement' and count(.//Recursion) != 0">
  233.                 <xsl:apply-templates select="./Sources/As/*[2]"/>
  234.             </xsl:when>
  235.             <xsl:otherwise>
  236.                 <xsl:choose>
  237.                     <xsl:when test="name(..) != 'Statement' and name(..) != 'Insert' and name(..) != 'Union' and name(..) != 'UnionAll'">
  238.                         (
  239.                     </xsl:when>
  240.                     <xsl:when test="name(..) = 'Statement' and count(.//Recursion) != 0">
  241.                         ; WITH 
  242.                         <xsl:for-each select=".//Recursion">
  243.                             <xsl:apply-templates select="."/>
  244.                             <xsl:if test="position()!=last()">, </xsl:if>
  245.                         </xsl:for-each>
  246.                     </xsl:when>
  247.                 </xsl:choose>
  248.  
  249.                 SELECT <xsl:apply-templates select="./Top"/>
  250.                     <xsl:apply-templates select="./Distinct"/>
  251.                     <xsl:apply-templates select="./ColumnExpressions"/>
  252.                     <xsl:if test="count(../Phase) != 0">, COUNT_BIG(*) AS [COUNT_BIG_7673aff6-2445-4ef6-a4c9-7bf3d93bd42a] </xsl:if>
  253.                     <xsl:apply-templates select="./Sources"/>
  254.                     <xsl:apply-templates select="./Where"/>
  255.                     <xsl:apply-templates select="./GroupBy"/>
  256.                     <xsl:apply-templates select="./OrderBy"/>
  257.                 
  258.                     <xsl:if test="name(..) = 'Statement'">
  259.                         <xsl:text> </xsl:text><xsl:value-of select="$post-select-query-hint"/>
  260.                     </xsl:if>
  261.                 <xsl:if test="name(..) != 'Statement' and name(..) != 'Insert' and name(..) != 'Union' and name(..) != 'UnionAll'">
  262.                     )
  263.                 </xsl:if>
  264.             </xsl:otherwise>
  265.         </xsl:choose>
  266.     </xsl:template>
  267.  
  268.     <!-- Recursion fragment                                               -->
  269.     <xsl:template match="Recursion">
  270.         <xsl:variable name="cte-name">
  271.             <xsl:choose>
  272.                 <xsl:when test="count(../Distinct) = 0 and name(../../..) != 'Union'">
  273.                     [<xsl:value-of select="./Name"/>]
  274.                 </xsl:when>
  275.                 <xsl:otherwise>
  276.                     [<xsl:value-of select="./Name"/>_e2__A9259451]
  277.                 </xsl:otherwise>
  278.             </xsl:choose>
  279.         </xsl:variable>
  280.         <xsl:value-of select="$cte-name"/>
  281.         ( <xsl:apply-templates select="./ColumnExpressions"/> )
  282.         AS
  283.         (
  284.         SELECT
  285.         <xsl:call-template name="print-children-list">
  286.                         <xsl:with-param name="value-node" select="./ColumnExpressions"/>
  287.                     </xsl:call-template>
  288.                 <xsl:apply-templates select="./Sources"/>
  289.                 <xsl:apply-templates select="./Where"/>
  290.             UNION ALL
  291.                 SELECT
  292.                     <xsl:call-template name="print-children-list">
  293.                         <xsl:with-param name="value-node" select="./ColumnExpressions"/>
  294.                         <xsl:with-param name="prefix" select="'[e2__A9259451-8A3F-4821-A7F0-10C7E3632D25]'"/>
  295.                     </xsl:call-template>
  296.                 FROM <xsl:apply-templates select="./Sources/As/*[1]"/> AS [e2__A9259451-8A3F-4821-A7F0-10C7E3632D25], <xsl:value-of select="$cte-name"/>
  297.                 WHERE
  298.                     (
  299.                     <xsl:call-template name="print-children-pair-list">
  300.                         <xsl:with-param name="value-node1" select="./Child"/>
  301.                         <xsl:with-param name="value-node2" select="./Parent"/>
  302.                         <xsl:with-param name="prefix1" select="$cte-name"/>
  303.                         <xsl:with-param name="prefix2" select="'[e2__A9259451-8A3F-4821-A7F0-10C7E3632D25]'"/>
  304.                     </xsl:call-template>
  305.                     )
  306.                     AND
  307.                     <xsl:call-template name="print-children-pair-list">
  308.                         <xsl:with-param name="value-node1" select="./Child"/>
  309.                         <xsl:with-param name="value-node2" select="./Child"/>
  310.                         <xsl:with-param name="prefix1" select="$cte-name"/>
  311.                         <xsl:with-param name="prefix2" select="'[e2__A9259451-8A3F-4821-A7F0-10C7E3632D25]'"/>
  312.                         <xsl:with-param name="connector" select="'<>'"/>
  313.                     </xsl:call-template>
  314.         )
  315.         <xsl:if test="count(../Distinct) != 0">
  316.             ,<xsl:value-of select="./Name"/>
  317.             ( <xsl:apply-templates select="./ColumnExpressions"/> )
  318.             AS ( 
  319.                 SELECT * FROM <xsl:value-of select="$cte-name"/>
  320.             )
  321.         </xsl:if>
  322.         <xsl:if test="name(../../..) = 'Union'">
  323.             ,<xsl:value-of select="./Name"/>
  324.             ( <xsl:apply-templates select="./ColumnExpressions"/> )
  325.             AS ( 
  326.                 SELECT * FROM <xsl:value-of select="$cte-name"/>
  327.                 UNION
  328.                 <xsl:apply-templates select="../../../*[2]"/>
  329.             )
  330.         </xsl:if>
  331.     </xsl:template>
  332.  
  333.     <!-- Update statement                                                 -->
  334.     <xsl:template match="Update">
  335.         UPDATE <xsl:apply-templates select="./Target"/>
  336.             <xsl:apply-templates select="./Where"/>
  337.     </xsl:template>
  338.  
  339.     <!-- Insert statement                                                 -->
  340.     <xsl:template match="Insert">
  341.         INSERT INTO <xsl:apply-templates select="./Target"/>
  342.         <xsl:apply-templates select="./Select"/>
  343.     </xsl:template>
  344.  
  345.     <!-- Delete statement                                                 -->
  346.     <xsl:template match="Delete">
  347.         DELETE FROM <xsl:apply-templates select="./Target"/>
  348.             <xsl:apply-templates select="./Where"/>
  349.     </xsl:template>
  350.  
  351.     <!-- Drop statement                                                   -->
  352.     <xsl:template match="Drop">
  353.         DROP <xsl:apply-templates select="./*"/>
  354.     </xsl:template>
  355.  
  356.     <!-- Create statement                                                 -->
  357.     <xsl:template match="Create">
  358.         CREATE 
  359.         <xsl:variable name="phase"><xsl:value-of select="./Phase"/></xsl:variable>
  360.         <xsl:choose>
  361.             <xsl:when test="number($phase)=1">
  362.                 VIEW <xsl:apply-templates select="./View"/> ( <xsl:apply-templates select="./*[4]"/>, [COUNT_BIG_7673aff6-2445-4ef6-a4c9-7bf3d93bd42a] ) WITH SCHEMABINDING AS <xsl:apply-templates select="./*[5]"/>
  363.             </xsl:when>
  364.             <xsl:when test="number($phase)=2">
  365.                 UNIQUE CLUSTERED INDEX <xsl:apply-templates select="./Index"/> ON <xsl:apply-templates select="./View"/> ( <xsl:apply-templates select="./*[4]"/> )
  366.             </xsl:when>
  367.             <xsl:otherwise>
  368.                 <xsl:apply-templates select="./*[1]"/>
  369.                 <xsl:choose>
  370.                     <xsl:when test="name(./*[1]) = 'Table'"> ( <xsl:apply-templates select="./*[2]"/> )</xsl:when>
  371.                 </xsl:choose>
  372.             </xsl:otherwise>
  373.         </xsl:choose>
  374.     </xsl:template>
  375.  
  376.     <!-- Remote query (OPENROWSET)                                        -->
  377.     <xsl:template match="RemoteQuery">
  378.         OPENROWSET
  379.         (
  380.             <xsl:call-template name="quote-string"><xsl:with-param name="string" select="./Provider"/></xsl:call-template>,
  381.             <xsl:choose>
  382.                 <xsl:when test="./DataSource">
  383.                     <xsl:call-template name="quote-string"><xsl:with-param name="string" select="./DataSource"/></xsl:call-template>;<xsl:call-template name="quote-string"><xsl:with-param name="string" select="./UserName"/></xsl:call-template>;<xsl:call-template name="quote-string"><xsl:with-param name="string" select="./Password"/></xsl:call-template>,
  384.                 </xsl:when>
  385.                 <xsl:otherwise>
  386.                     <xsl:call-template name="quote-string"><xsl:with-param name="string" select="./ConnectionString"/></xsl:call-template>,
  387.                 </xsl:otherwise>
  388.             </xsl:choose>
  389.             <xsl:call-template name="quote-string"><xsl:with-param name="string" select="./*[last()]"/></xsl:call-template>
  390.         )
  391.     </xsl:template>
  392.  
  393.     <xsl:template match="Distinct">
  394.         DISTINCT
  395.     </xsl:template>
  396.  
  397.     <!-- As construction for SQL 90 takes care of CTEs                    -->
  398.     <xsl:template match="As">
  399.         <xsl:choose>
  400.             <xsl:when test="count(.//Recursion) != 0">
  401.                 <xsl:apply-templates select="./*[2]"/>
  402.             </xsl:when>
  403.             <xsl:otherwise>
  404.                 <xsl:apply-templates select="./*[1]"/> AS <xsl:apply-templates select="./*[2]"/>
  405.             </xsl:otherwise>
  406.         </xsl:choose>
  407.     </xsl:template>
  408.  
  409.     <xsl:template match="Sources">
  410.         FROM <xsl:call-template name="print-children-list"/>
  411.     </xsl:template>
  412.  
  413.     <xsl:template match="ColumnDefinitions">
  414.         <xsl:call-template name="print-children-list"/>
  415.     </xsl:template>
  416.  
  417.     <xsl:template match="GroupBy">
  418.         GROUP BY <xsl:call-template name="print-children-list"/>
  419.     </xsl:template>
  420.  
  421.     <xsl:template match="OrderBy">
  422.         ORDER BY <xsl:call-template name="print-children-list"/>
  423.     </xsl:template>
  424.  
  425.     <xsl:template match="Where">
  426.         WHERE <xsl:apply-templates select="./*"/>
  427.     </xsl:template>
  428.  
  429.     <xsl:template match="Having">
  430.         HAVING <xsl:apply-templates select="./*"/>
  431.     </xsl:template>
  432.  
  433.     <xsl:template match="ColumnExpressions">
  434.         <xsl:call-template name="print-children-list"/>
  435.     </xsl:template>
  436.  
  437.     <xsl:template match="ColumnUpdates">
  438.         <xsl:call-template name="print-children-list"/>
  439.     </xsl:template>
  440.  
  441.     <xsl:template match="Assign">
  442.         <xsl:apply-templates select="./*[1]"/>=<xsl:apply-templates select="./*[2]"/>
  443.     </xsl:template>
  444.  
  445.     <xsl:template match="Insert/Target">
  446.         <xsl:apply-templates select="./Table"/>
  447.         (
  448.             <xsl:call-template name="print-list">
  449.                 <xsl:with-param name="value-node" select="./ColumnUpdates/*/*[1]"/>
  450.             </xsl:call-template>
  451.         )
  452.         <xsl:if test="./*[2]/Assign">
  453.             VALUES
  454.             (
  455.                 <xsl:call-template name="print-list">
  456.                     <xsl:with-param name="value-node" select="./ColumnUpdates/*/*[2]"/>
  457.                 </xsl:call-template>
  458.             )
  459.         </xsl:if>
  460.     </xsl:template>
  461.  
  462.     <xsl:template match="Update/Target">
  463.         <xsl:apply-templates select="./Table"/>
  464.         SET <xsl:apply-templates select="./ColumnUpdates"/>
  465.     </xsl:template>
  466.  
  467.     <xsl:template match="Delete/Target">
  468.         <xsl:apply-templates select="./Table"/>
  469.     </xsl:template>
  470.  
  471.     <xsl:template match="Insert/Target/ColumnUpdates/Assign/SQLColumn[1]">
  472.         <!-- The table name is not printed for LHS of assignments in insert -->
  473.         <xsl:apply-templates select="./Column"/>
  474.     </xsl:template>
  475.  
  476.     <xsl:template match="Create/ColumnDefinitions/SQLColumn">
  477.         <xsl:apply-templates select="./Column"/>
  478.         <xsl:if test="count(../../Phase) = 0">
  479.             <xsl:apply-templates select="./Type"/>
  480.             <xsl:apply-templates select="./Usage"/>
  481.         </xsl:if>
  482.     </xsl:template>
  483.  
  484.     <xsl:template match="SQLColumn">
  485.         <xsl:variable name="table">
  486.             <xsl:if test="name(../../..) != 'Recursion' and (name(..)!='Count' or name(./Column/*[1]) != 'Asterisk')"><xsl:apply-templates select="./Table"/></xsl:if>
  487.         </xsl:variable>
  488.         <xsl:variable name="column">
  489.             <xsl:apply-templates select="./Column"/>
  490.         </xsl:variable>
  491.         <xsl:choose>
  492.             <xsl:when test="$table = ''">
  493.                 <xsl:value-of select="$column"/>
  494.             </xsl:when>
  495.             <xsl:otherwise>
  496.                 <xsl:value-of select="concat($table,'.', $column)"/>
  497.             </xsl:otherwise>
  498.         </xsl:choose>
  499.     </xsl:template>
  500.  
  501.     <xsl:template match="Create/Database|Drop/Database">
  502.         DATABASE <xsl:apply-templates select="./Name"/>
  503.     </xsl:template>
  504.  
  505.     <xsl:template match="Table">
  506.         <xsl:call-template name="build-quoted-schema-object"/>
  507.     </xsl:template>
  508.  
  509.     <xsl:template match="Recursion/Name">
  510.         <xsl:call-template name="quote-identifier"/>
  511.     </xsl:template>
  512.  
  513.     <xsl:template match="Create/Table|Drop/Table">
  514.         TABLE <xsl:call-template name="build-quoted-schema-object"/>
  515.     </xsl:template>
  516.  
  517.     <xsl:template match="View">
  518.         <xsl:call-template name="build-quoted-schema-object"/>
  519.     </xsl:template>
  520.  
  521.     <xsl:template match="Drop/View">
  522.         VIEW <xsl:call-template name="build-quoted-schema-object"/>
  523.     </xsl:template>
  524.  
  525.     <xsl:template match="Index">
  526.         <xsl:apply-templates select="./Name"/>
  527.     </xsl:template>
  528.  
  529.     <xsl:template match="Drop/Index">
  530.         INDEX <xsl:apply-templates select="./Name"/>
  531.     </xsl:template>
  532.  
  533.     <xsl:template match="Column">
  534.         <xsl:apply-templates select="./Asterisk"/>
  535.         <xsl:apply-templates select="./Name"/>
  536.     </xsl:template>
  537.  
  538.     <xsl:template match="Table/Name|View/Name|Index/Name|Column/Name|Database/Name|Schema">
  539.         <xsl:call-template name="quote-identifier"/>
  540.     </xsl:template>
  541.  
  542.     <xsl:template match="Usage">
  543.         <xsl:variable name="usage"><xsl:value-of select="."/></xsl:variable>
  544.         <xsl:choose>
  545.             <xsl:when test="$usage = 'Key'">    primary key   </xsl:when>
  546.         </xsl:choose>
  547.     </xsl:template>
  548.  
  549.     <xsl:template match="OpaqueExpression">
  550.         <xsl:if test="name(..) = 'As' and name(../..) = 'Sources'">
  551.             (
  552.         </xsl:if>
  553.         <xsl:value-of select="."/>
  554.         <xsl:if test="name(..) = 'As' and name(../..) = 'Sources'">
  555.             )
  556.         </xsl:if>
  557.     </xsl:template>
  558.  
  559.     <xsl:template match="OrderExpression">
  560.         <xsl:apply-templates select="./*[1]"/>
  561.         <xsl:apply-templates select="./Asc"/>
  562.         <xsl:apply-templates select="./Desc"/>
  563.     </xsl:template>
  564.  
  565.     <xsl:template match="Asc">
  566.         ASC
  567.     </xsl:template>
  568.  
  569.     <xsl:template match="Desc">
  570.         DESC
  571.     </xsl:template>
  572.  
  573.     <!-- Print values: ? for parametric queries and convert expressions
  574.          for non-parametric queries                                       -->
  575.     <xsl:template match="Parameter">
  576.         <xsl:choose>
  577.             <xsl:when test="$UseParams = 'yes' or $UseParams = 'nosubsel'">
  578.                 <xsl:choose>
  579.                     <xsl:when test="./@ParamName">
  580.                         @<xsl:value-of select="./@ParamName"/>
  581.                     </xsl:when>
  582.                     <xsl:otherwise>
  583.                         ?
  584.                     </xsl:otherwise>
  585.                 </xsl:choose>
  586.             </xsl:when>
  587.             <xsl:otherwise>
  588.                 <xsl:call-template name="print-non-parametric-parameter-ref">
  589.                     <xsl:with-param name="parameter-reference" select="."/>
  590.                 </xsl:call-template>
  591.             </xsl:otherwise>
  592.         </xsl:choose>
  593.     </xsl:template>
  594.  
  595.     <!-- DatePart                                                         -->
  596.     <xsl:template match="DatePart">
  597.         DATEPART( <xsl:apply-templates select="./*[1]"/> , <xsl:apply-templates select="./*[2]"/> )
  598.     </xsl:template>
  599.  
  600.     <!-- DatePartSpec                                                     -->
  601.     <xsl:template match="DatePartSpec">
  602.         <xsl:variable name="dps-val"><xsl:value-of select="normalize-space(./text())"/></xsl:variable>
  603.         <xsl:choose>
  604.             <xsl:when test="$dps-val = 'Year'">        year        </xsl:when>
  605.             <xsl:when test="$dps-val = 'Quarter'">     quarter     </xsl:when>
  606.             <xsl:when test="$dps-val = 'Month'">       month       </xsl:when>
  607.             <xsl:when test="$dps-val = 'DayOfYear'">   dayofyear   </xsl:when>
  608.             <xsl:when test="$dps-val = 'Day'">         day         </xsl:when>
  609.             <xsl:when test="$dps-val = 'Week'">        week        </xsl:when>
  610.             <xsl:when test="$dps-val = 'DayOfWeek'">   weekday     </xsl:when>
  611.             <xsl:when test="$dps-val = 'Hour'">        hour        </xsl:when>
  612.             <xsl:when test="$dps-val = 'Minute'">      minute      </xsl:when>
  613.             <xsl:when test="$dps-val = 'Second'">      second      </xsl:when>
  614.             <xsl:when test="$dps-val = 'Millisecond'"> millisecond </xsl:when>
  615.         </xsl:choose>
  616.     </xsl:template>
  617.  
  618.     <!-- Asterisk                                                         -->
  619.     <xsl:template match="Asterisk">*</xsl:template>
  620.  
  621.     <!-- Count/Min/Max/Sum                                                -->
  622.     <xsl:template match="Min|Max|Sum">
  623.         <xsl:variable name="function">
  624.             <xsl:choose>
  625.                 <xsl:when test="name()='Min'"> MIN </xsl:when>
  626.                 <xsl:when test="name()='Max'"> MAX </xsl:when>
  627.                 <xsl:when test="name()='Sum'"> SUM </xsl:when>
  628.             </xsl:choose>
  629.         </xsl:variable>
  630.         <xsl:value-of select="$function"/>( <xsl:apply-templates select="./*[1]"/> )
  631.     </xsl:template>
  632.  
  633.     <xsl:template match="Count">
  634.         COUNT_BIG ( <xsl:apply-templates select="./*[1]"/> <xsl:apply-templates select="./*[2]"/> )
  635.     </xsl:template>
  636.  
  637.     <!-- Binary expressions                                               -->
  638.     <!-- Equal/NotEqual/Greater/GreaterOrEqual/Less/LessOrEqual/In/And/Or/Plus/Minus/Divide/Multiply
  639.          expressions                                                      -->
  640.     <xsl:template match="Equal|NotEqual|Greater|GreaterOrEqual|Less|LessOrEqual|In|And|Or|Plus|Minus|Divide|Multiply">
  641.         <xsl:variable name="operator">
  642.             <xsl:choose>
  643.                 <xsl:when test="name()='Equal'">            =        </xsl:when>
  644.                 <xsl:when test="name()='NotEqual'">            <>    </xsl:when>
  645.                 <xsl:when test="name()='Greater'">            >        </xsl:when>
  646.                 <xsl:when test="name()='GreaterOrEqual'">    >=        </xsl:when>
  647.                 <xsl:when test="name()='Less'">                <    </xsl:when>
  648.                 <xsl:when test="name()='LessOrEqual'">        <=    </xsl:when>
  649.                 <xsl:when test="name()='In'">                IN        </xsl:when>
  650.                 <xsl:when test="name()='And'">                AND        </xsl:when>
  651.                 <xsl:when test="name()='Or'">                OR        </xsl:when>
  652.                 <xsl:when test="name()='Plus'">                +        </xsl:when>
  653.                 <xsl:when test="name()='Minus'">            -        </xsl:when>
  654.                 <xsl:when test="name()='Divide'">            /        </xsl:when>
  655.                 <xsl:when test="name()='Multiply'">            *        </xsl:when>
  656.             </xsl:choose>
  657.         </xsl:variable>
  658.         (
  659.             <xsl:call-template name="print-children-list">
  660.                 <xsl:with-param name="operator" select="$operator"/>
  661.             </xsl:call-template>
  662.         )
  663.     </xsl:template>
  664.  
  665.     <!-- Postfix unary expressions                                        -->
  666.     <!-- IsNull
  667.          expressions                                                      -->
  668.     <xsl:template match="IsNull">
  669.         <xsl:variable name="operator">
  670.             <xsl:choose>
  671.                 <xsl:when test="name()='IsNull'">            IS NULL        </xsl:when>
  672.             </xsl:choose>
  673.         </xsl:variable>
  674.         (
  675.             <xsl:apply-templates select="./*[1]"/>
  676.             <xsl:value-of select="$operator"/>
  677.         )
  678.     </xsl:template>
  679.  
  680.     <!-- Types                                                            -->
  681.     <xsl:template match="Type">
  682.         <xsl:variable name="type-val"><xsl:value-of select="normalize-space(./text())"/></xsl:variable>
  683.         <xsl:choose>
  684.             <xsl:when test="$type-val = 'DBTYPE_BSTR'">    nvarchar     </xsl:when>
  685.             <xsl:when test="$type-val = 'DBTYPE_WSTR'">    nvarchar     </xsl:when>
  686.             <xsl:when test="$type-val = 'DBTYPE_STR'">     varchar      </xsl:when>
  687.             <xsl:when test="$type-val = 'DBTYPE_BOOL'">    bit          </xsl:when>
  688.             <xsl:when test="$type-val = 'DBTYPE_I1'">      tinyint      </xsl:when>
  689.             <xsl:when test="$type-val = 'DBTYPE_I2'">      smallint     </xsl:when>
  690.             <xsl:when test="$type-val = 'DBTYPE_I4'">      int          </xsl:when>
  691.             <xsl:when test="$type-val = 'DBTYPE_I8'">      bigint       </xsl:when>
  692.             <xsl:when test="$type-val = 'DBTYPE_UI1'">     tinyint      </xsl:when>
  693.             <xsl:when test="$type-val = 'DBTYPE_UI2'">     smallint     </xsl:when>
  694.             <xsl:when test="$type-val = 'DBTYPE_UI4'">     int          </xsl:when>
  695.             <xsl:when test="$type-val = 'DBTYPE_UI8'">     bigint       </xsl:when>
  696.             <xsl:when test="$type-val = 'DBTYPE_R4'">      real         </xsl:when>
  697.             <xsl:when test="$type-val = 'DBTYPE_R8'">      float        </xsl:when>
  698.             <xsl:when test="$type-val = 'DBTYPE_DATE'">    datetime     </xsl:when>
  699.             <xsl:when test="$type-val = 'DBTYPE_DBTIMESTAMP'">    datetime     </xsl:when>
  700.             <xsl:when test="$type-val = 'DBTYPE_CY'">      money        </xsl:when>
  701.             <xsl:when test="$type-val = 'DBTYPE_VARIANT'"> sql_variant  </xsl:when>
  702.             <xsl:when test="$type-val = 'DBTYPE_GUID'"> uniqueidentifier  </xsl:when>
  703.             <xsl:when test="$type-val = 'DBTYPE_ByteArray'"> varbinary  </xsl:when>
  704.             <xsl:when test="$type-val = 'DBTYPE_DECIMAL'"> decimal      </xsl:when>
  705.         </xsl:choose>
  706.         <xsl:apply-templates select="./Size"/>
  707.         <xsl:apply-templates select="./Precision"/>
  708.         <xsl:apply-templates select="./Scale"/>        
  709.     </xsl:template>
  710.  
  711.     <!-- Size (optional)                                                  -->
  712.     <xsl:template match="Size">
  713.     ( <xsl:value-of select="./text()"/> )
  714.     </xsl:template>
  715.     
  716.     <!-- Precision (optional)                                                  -->
  717.     <xsl:template match="Precision">
  718.     ( <xsl:value-of select="./text()"/>
  719.     </xsl:template>
  720.  
  721.     <!-- Scale (optional)                                                  -->
  722.     <xsl:template match="Scale">
  723.     , <xsl:value-of select="./text()"/> )
  724.     </xsl:template>
  725.     <!-- Cast                                                             -->
  726.     <xsl:template match="Cast">
  727.         CAST(<xsl:apply-templates select="./*[1]"/> AS <xsl:apply-templates select="./*[2]"/>)
  728.     </xsl:template>
  729.     
  730.     <!-- By default don't do anything                                     -->
  731.     <xsl:template match="*">
  732.     </xsl:template>
  733.  
  734.     <!-- Print a schema object                                               -->
  735.     <xsl:template name="build-quoted-schema-object"> 
  736.         <xsl:param name="schema-object-node" select="."/>
  737.  
  738.         <xsl:variable name="schema">
  739.             <xsl:apply-templates select="$schema-object-node/Schema"/>
  740.         </xsl:variable>
  741.         <xsl:variable name="table">
  742.             <xsl:apply-templates select="$schema-object-node/Name"/>
  743.         </xsl:variable>
  744.         <xsl:choose>
  745.             <xsl:when test="$schema = ''">
  746.                 <xsl:value-of select="$table"/>
  747.             </xsl:when>
  748.             <xsl:otherwise>
  749.                 <xsl:value-of select="concat($schema,'.', $table)"/>
  750.             </xsl:otherwise>
  751.         </xsl:choose>
  752.     </xsl:template>
  753.  
  754.     <!-- Convert an identifier to the OLEDB quotation form                -->
  755.     <xsl:template name="quote-identifier"> 
  756.         <xsl:param name="identifier" select="."/>
  757.  
  758.         <xsl:value-of select="$IdentifierStartQuotingCharacter"/>
  759.         <xsl:call-template name="normalize-entity-aux">
  760.             <xsl:with-param name="entity" select="$identifier"/>
  761.             <xsl:with-param name="end-quoting-char" select="$IdentifierEndQuotingCharacter"/>
  762.         </xsl:call-template>
  763.         <xsl:value-of select="$IdentifierEndQuotingCharacter"/>
  764.     </xsl:template>
  765.  
  766.     <!-- Convert a string to the string quotation form                    -->
  767.     <xsl:template name="quote-string"> 
  768.         <xsl:param name="string" select="."/>
  769.  
  770.         <xsl:value-of select="$StringStartQuotingCharacter"/>
  771.         <xsl:call-template name="normalize-entity-aux">
  772.             <xsl:with-param name="entity" select="$string"/>
  773.             <xsl:with-param name="end-quoting-char" select="$StringEndQuotingCharacter"/>
  774.         </xsl:call-template>
  775.         <xsl:value-of select="$StringEndQuotingCharacter"/>
  776.     </xsl:template>
  777.  
  778.     <!-- Convert an entity to the quotation form (recursive, aux)  by
  779.          duplicating the end quoting character                            -->
  780.     <xsl:template name="normalize-entity-aux"> 
  781.         <xsl:param name="entity"/>
  782.         <xsl:param name="end-quoting-char"/>
  783.  
  784.         <xsl:choose>
  785.             <xsl:when test="contains($entity, $end-quoting-char)">
  786.                 <xsl:value-of select="substring-before($entity, $end-quoting-char)"/>
  787.                 <xsl:value-of select="$end-quoting-char"/>
  788.                 <xsl:value-of select="$end-quoting-char"/>
  789.                 <xsl:call-template name="normalize-entity-aux">
  790.                     <xsl:with-param name="entity" select="substring-after($entity, $end-quoting-char)"/>
  791.                     <xsl:with-param name="end-quoting-char" select="$end-quoting-char"/>
  792.                 </xsl:call-template>
  793.             </xsl:when>
  794.             <xsl:otherwise>
  795.                 <xsl:value-of select="$entity"/>
  796.             </xsl:otherwise>
  797.         </xsl:choose>
  798.     </xsl:template>
  799.  
  800.     <!-- Print the children list                                          -->
  801.     <xsl:template name="print-children-list">
  802.         <xsl:param name="value-node" select="."/>
  803.         <xsl:param name="operator" select="','"/>
  804.         <xsl:param name="prefix" select="''"/>
  805.  
  806.         <xsl:call-template name="print-list">
  807.             <xsl:with-param name="value-node" select="$value-node/*"/>
  808.             <xsl:with-param name="operator" select="$operator"/>
  809.             <xsl:with-param name="prefix" select="$prefix"/>
  810.         </xsl:call-template>
  811.     </xsl:template>
  812.  
  813.     <!-- Print a list                                                     -->
  814.     <xsl:template name="print-list">
  815.         <xsl:param name="operator" select="','"/>
  816.         <xsl:param name="value-node" select="."/>
  817.         <xsl:param name="prefix" select="''"/>
  818.  
  819.         <xsl:for-each select="$value-node">
  820.             <xsl:call-template name="print-element-optional-prefix">
  821.                 <xsl:with-param name="value-node" select="."/>
  822.                 <xsl:with-param name="prefix" select="$prefix"/>
  823.             </xsl:call-template>
  824.             <xsl:if test="position()!=last()">
  825.                 <xsl:value-of select="$operator"/>
  826.             </xsl:if>
  827.         </xsl:for-each>
  828.     </xsl:template>
  829.  
  830.     <!-- Print a list of pairs connected by =                             -->
  831.     <xsl:template name="print-children-pair-list">
  832.         <xsl:param name="value-node1" select="."/>
  833.         <xsl:param name="value-node2" select="."/>
  834.         <xsl:param name="prefix1" select="''"/>
  835.         <xsl:param name="prefix2" select="''"/>
  836.         <xsl:param name="operator" select="' AND '"/>
  837.         <xsl:param name="connector" select="' = '"/>
  838.  
  839.         <xsl:for-each select="$value-node1/*">
  840.             <xsl:call-template name="print-element-optional-prefix">
  841.                 <xsl:with-param name="value-node" select="."/>
  842.                 <xsl:with-param name="prefix" select="$prefix1"/>
  843.             </xsl:call-template>
  844.             <xsl:value-of select="$connector"/>
  845.             <xsl:call-template name="print-element-optional-prefix">
  846.                 <xsl:with-param name="value-node" select="$value-node2/*[position()]"/>
  847.                 <xsl:with-param name="prefix" select="$prefix2"/>
  848.             </xsl:call-template>
  849.             <xsl:if test="position()!=last()">
  850.                 <xsl:value-of select="$operator"/>
  851.             </xsl:if>
  852.         </xsl:for-each>
  853.     </xsl:template>
  854.  
  855.     <!-- Print an element giving it an optional prefix                    -->
  856.     <xsl:template name="print-element-optional-prefix">
  857.         <xsl:param name="value-node" select="."/>
  858.         <xsl:param name="prefix" select="''"/>
  859.  
  860.         <xsl:for-each select="$value-node">
  861.             <xsl:variable name="element">
  862.                 <xsl:apply-templates select="."/>
  863.             </xsl:variable>
  864.             <xsl:choose>
  865.                 <xsl:when test="$prefix = ''">
  866.                     <xsl:value-of select="$element"/>
  867.                 </xsl:when>
  868.                 <xsl:otherwise>
  869.                     <xsl:value-of select="concat($prefix, '.', $element)"/>
  870.                 </xsl:otherwise>
  871.             </xsl:choose>
  872.         </xsl:for-each>
  873.     </xsl:template>
  874.  
  875.     <!-- Get the value of a parameter ref for the query                   -->
  876.     <xsl:template name="print-non-parametric-parameter-ref">
  877.         <xsl:param name="parameter-reference"/>
  878.  
  879.         <xsl:variable name="reference"><xsl:value-of select="$parameter-reference/@ref"/></xsl:variable>
  880.         <xsl:call-template name="print-non-parametric-parameter">
  881.             <xsl:with-param name="parameter" select="/Statement/Parameters/Parameter[@id=$reference]"/>
  882.         </xsl:call-template>
  883.     </xsl:template>
  884.  
  885.     <!-- Get the value of a parameter ref for the query                   -->
  886.     <xsl:template name="print-non-parametric-parameter">
  887.         <xsl:param name="parameter"/>
  888.  
  889.         <xsl:variable name="db-type"><xsl:value-of select="$parameter/@DBTYPE"/></xsl:variable>
  890.         <xsl:variable name="value"><xsl:value-of select="$parameter/text()"/></xsl:variable>
  891.         <xsl:choose>
  892.             <xsl:when test="$db-type = 'DBTYPE_BSTR'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  893.             <xsl:when test="$db-type = 'DBTYPE_WSTR'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  894.             <xsl:when test="$db-type = 'DBTYPE_STR'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  895.             <xsl:when test="$db-type = 'DBTYPE_BOOL'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS bit)</xsl:when>
  896.             <xsl:when test="$db-type = 'DBTYPE_I1'"><xsl:value-of select="$value"/></xsl:when>
  897.             <xsl:when test="$db-type = 'DBTYPE_I2'"><xsl:value-of select="$value"/></xsl:when>
  898.             <xsl:when test="$db-type = 'DBTYPE_I4'"><xsl:value-of select="$value"/></xsl:when>
  899.             <xsl:when test="$db-type = 'DBTYPE_I8'"><xsl:value-of select="$value"/></xsl:when>
  900.             <xsl:when test="$db-type = 'DBTYPE_UI1'"><xsl:value-of select="$value"/></xsl:when>
  901.             <xsl:when test="$db-type = 'DBTYPE_UI2'"><xsl:value-of select="$value"/></xsl:when>
  902.             <xsl:when test="$db-type = 'DBTYPE_UI4'"><xsl:value-of select="$value"/></xsl:when>
  903.             <xsl:when test="$db-type = 'DBTYPE_UI8'"><xsl:value-of select="$value"/></xsl:when>
  904.             <xsl:when test="$db-type = 'DBTYPE_R4'"><xsl:value-of select="$value"/></xsl:when>
  905.             <xsl:when test="$db-type = 'DBTYPE_R8'"><xsl:value-of select="$value"/></xsl:when>
  906.             <xsl:when test="$db-type = 'DBTYPE_DATE'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS datetime)</xsl:when>
  907.             <xsl:when test="$db-type = 'DBTYPE_DBTIMESTAMP'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS datetime)</xsl:when>
  908.             <xsl:when test="$db-type = 'DBTYPE_CY'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS money)</xsl:when>
  909.             <xsl:when test="$db-type = 'DBTYPE_VARIANT'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  910.             <xsl:when test="$db-type = 'DBTYPE_GUID'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  911.             <xsl:when test="$db-type = 'DBTYPE_ByteArray'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  912.             <xsl:when test="$db-type = 'DBTYPE_DECIMAL'"><xsl:value-of select="$value"/></xsl:when>
  913.         </xsl:choose>
  914.     </xsl:template>
  915. </xsl:stylesheet>
  916.