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_ClientAs80_xsl_32.C16C67A1_5ADC_4C44_B6AE_A40000020FCC < prev    next >
Extensible Markup Language  |  2009-03-29  |  17KB  |  397 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.  
  15.     <!-- Microsoft Analysis Server 2000 (Shiloh) pluggable cartridge      -->
  16.  
  17.     <!-- Area of STANDARD parametrizations: these are externally passed   -->
  18.     <xsl:param name="in_CanUseParams">no</xsl:param>
  19.     <xsl:param name="in_IdentStartQuotingCharacter">[</xsl:param>
  20.     <xsl:param name="in_IdentEndQuotingCharacter">]</xsl:param>
  21.     <xsl:param name="in_StringStartQuotingCharacter">'</xsl:param>
  22.     <xsl:param name="in_StringEndQuotingCharacter">'</xsl:param>
  23.     
  24.     <!-- Area of CORE parametrizations: These are externally checked      -->
  25.     <mssqlcrt:provider type="prefix" managed="yes" native="yes">OLAP server</mssqlcrt:provider>
  26.  
  27.     <mssqlcrt:capabilities>
  28.         <mssqlcrt:supports-column-alias/>
  29.     </mssqlcrt:capabilities>
  30.  
  31.     <mssqlcrt:schema-classes>
  32.         <mssqlcrt:schema-class>
  33.             <mssqlcrt:managed-provider>System.Data.OleDb</mssqlcrt:managed-provider>
  34.             <mssqlcrt:type>Microsoft.DataWarehouse.Design.OleDbSchema, Microsoft.DataWarehouse</mssqlcrt:type>
  35.             <mssqlcrt:query-designer>
  36.                 <mssqlcrt:type>Microsoft.DataWarehouse.Controls.OleDbQueryDesigner, Microsoft.DataWarehouse</mssqlcrt:type>
  37.             </mssqlcrt:query-designer>
  38.         </mssqlcrt:schema-class>
  39.         <mssqlcrt:schema-class>
  40.             <mssqlcrt:managed-provider>System.Data.Odbc</mssqlcrt:managed-provider>
  41.             <mssqlcrt:type>Microsoft.DataWarehouse.Design.OdbcSchema, Microsoft.DataWarehouse</mssqlcrt:type>
  42.         </mssqlcrt:schema-class>
  43.     </mssqlcrt:schema-classes>
  44.  
  45.     <!-- Area of internal parametrizations                                -->
  46.     <!-- overrideOfUseParams:
  47.              yes      = use always parametric queries
  48.              no       = never use parametric queries
  49.              nosubsel = use as yes, but not on subselects
  50.              auto     = use the value of in_CanUseParams to determine     -->
  51.     <xsl:variable name="overrideOfUseParams">auto</xsl:variable>
  52.     <!-- shouldProduceDebug:
  53.              yes      = produce debug information
  54.              no       = do not produce debug information                  -->
  55.     <xsl:variable name="shouldProduceDebug">yes</xsl:variable>
  56.  
  57.     <!-- Area of global variables initializations                         -->
  58.     <xsl:variable name="UseParams">
  59.         <xsl:choose>
  60.             <xsl:when test="normalize-space($overrideOfUseParams) = 'yes' or (normalize-space($overrideOfUseParams) = 'auto' and normalize-space($in_CanUseParams)='yes')">yes</xsl:when>
  61.             <xsl:when test="normalize-space($overrideOfUseParams) = 'nosubsel'">nosubsel</xsl:when>
  62.             <xsl:otherwise>no</xsl:otherwise>
  63.         </xsl:choose>
  64.     </xsl:variable>
  65.     <xsl:variable name="ProduceDebug" select="$shouldProduceDebug"/>
  66.     <xsl:variable name="IdentifierStartQuotingCharacter" select="normalize-space($in_IdentStartQuotingCharacter)"/>
  67.     <xsl:variable name="IdentifierEndQuotingCharacter" select="normalize-space($in_IdentEndQuotingCharacter)"/>
  68.     <xsl:variable name="StringStartQuotingCharacter" select="normalize-space($in_StringStartQuotingCharacter)"/>
  69.     <xsl:variable name="StringEndQuotingCharacter" select="normalize-space($in_StringEndQuotingCharacter)"/>
  70.  
  71.     <!-- Generated statement packaging                                    -->
  72.     <xsl:template match="/">
  73.         <xsl:element name="Statement">
  74.  
  75.             <!-- Generate query                                           -->
  76.             <xsl:element name="Text">
  77.                 <xsl:apply-templates select="./Statement/*[1]"/>
  78.             </xsl:element>
  79.  
  80.             <!-- Generate parameters                                      -->
  81.             <xsl:if test="count(./Statement/Parameters/Parameter)!=0 and ((normalize-space($UseParams)='yes') or (normalize-space($UseParams)='nosubsel'))">
  82.                 <xsl:element name="Parameters">
  83.                     <xsl:choose>
  84.                         <xsl:when test="/Statement/*[1]//Parameter/@ParamName">
  85.                             <xsl:for-each select="./Statement/Parameters/Parameter">
  86.                                 <xsl:element name="Parameter">
  87.                                     <xsl:attribute name="ref">
  88.                                         <xsl:value-of select="./@id"/>
  89.                                     </xsl:attribute>
  90.                                 </xsl:element>
  91.                             </xsl:for-each>
  92.                         </xsl:when>
  93.                         <xsl:otherwise>
  94.                             <xsl:for-each select="./Statement/*[1]//Parameter">
  95.                                 <xsl:element name="Parameter">
  96.                                     <xsl:attribute name="ref">
  97.                                         <xsl:value-of select="./@ref"/>
  98.                                     </xsl:attribute>
  99.                                 </xsl:element>
  100.                             </xsl:for-each>
  101.                         </xsl:otherwise>
  102.                     </xsl:choose>
  103.                 </xsl:element>
  104.             </xsl:if>
  105.  
  106.             <!-- Generate debug info                                      -->
  107.             <xsl:if test="$ProduceDebug='yes'">
  108.                 <xsl:element name="mssqldbg:DebugInfo">
  109.                     <xsl:element name="mssqldbg:GenerateParametricInfo">
  110.                         <xsl:attribute name="mssqldbg:Value">
  111.                             <xsl:value-of select="$UseParams"/>
  112.                         </xsl:attribute>
  113.                         <xsl:element name="mssqldbg:External">
  114.                             <xsl:value-of select="$in_CanUseParams"/>
  115.                         </xsl:element>
  116.                         <xsl:element name="mssqldbg:Internal">
  117.                             <xsl:value-of select="$overrideOfUseParams"/>
  118.                         </xsl:element>
  119.                     </xsl:element>
  120.                 </xsl:element>
  121.             </xsl:if>
  122.  
  123.         </xsl:element>
  124.     </xsl:template>
  125.  
  126.     <!-- Select statement                                                 -->
  127.     <xsl:template match="Select">
  128.         SELECT <xsl:apply-templates select="./Distinct"/>
  129.             <xsl:apply-templates select="./ColumnExpressions"/>
  130.             <xsl:apply-templates select="./Sources"/>
  131.             <xsl:apply-templates select="./Where"/>
  132.             <xsl:apply-templates select="./GroupBy"/>
  133.             <xsl:apply-templates select="./OrderBy"/>
  134.         
  135.             <xsl:if test="name(..) = 'Statement'">
  136.                 <xsl:text> </xsl:text><xsl:value-of select="$post-select-query-hint"/>
  137.             </xsl:if>
  138.     </xsl:template>
  139.  
  140.     <xsl:template match="Distinct">
  141.         DISTINCT
  142.     </xsl:template>
  143.  
  144.     <xsl:template match="As">
  145.         <xsl:apply-templates select="./*[1]"/> AS <xsl:apply-templates select="./*[2]"/>
  146.     </xsl:template>
  147.  
  148.     <xsl:template match="Sources">
  149.         FROM <xsl:call-template name="print-children-list"/>
  150.     </xsl:template>
  151.  
  152.     <xsl:template match="GroupBy">
  153.         GROUP BY <xsl:call-template name="print-children-list"/>
  154.     </xsl:template>
  155.  
  156.     <xsl:template match="OrderBy">
  157.         ORDER BY <xsl:call-template name="print-children-list"/>
  158.     </xsl:template>
  159.  
  160.     <xsl:template match="Where">
  161.         WHERE <xsl:apply-templates select="./*"/>
  162.     </xsl:template>
  163.  
  164.     <xsl:template match="ColumnExpressions">
  165.         <xsl:call-template name="print-children-list"/>
  166.     </xsl:template>
  167.  
  168.     <xsl:template match="SQLColumn">
  169.         <xsl:variable name="table">
  170.             <xsl:if test="name(..)!='Count' or name(./Column/*[1]) != 'Asterisk'"><xsl:apply-templates select="./Table"/></xsl:if>
  171.         </xsl:variable>
  172.         <xsl:variable name="column">
  173.             <xsl:apply-templates select="./Column"/>
  174.         </xsl:variable>
  175.         <xsl:choose>
  176.             <xsl:when test="$table = ''">
  177.                 <xsl:value-of select="$column"/>
  178.             </xsl:when>
  179.             <xsl:otherwise>
  180.                 <xsl:value-of select="concat($table,'.', $column)"/>
  181.             </xsl:otherwise>
  182.         </xsl:choose>
  183.     </xsl:template>
  184.  
  185.     <xsl:template match="Table">
  186.         <xsl:call-template name="build-quoted-schema-object"/>
  187.     </xsl:template>
  188.  
  189.     <xsl:template match="Column">
  190.         <xsl:apply-templates select="./Asterisk"/>
  191.         <xsl:apply-templates select="./Name"/>
  192.     </xsl:template>
  193.  
  194.     <xsl:template match="Table/Name|View/Name|Index/Name|Column/Name|Database/Name|Schema">
  195.         <xsl:call-template name="quote-identifier"/>
  196.     </xsl:template>
  197.  
  198.     <xsl:template match="OpaqueExpression">
  199.         <xsl:if test="name(..) = 'As' and name(../..) = 'Sources'">
  200.             (
  201.         </xsl:if>
  202.         <xsl:value-of select="."/>
  203.         <xsl:if test="name(..) = 'As' and name(../..) = 'Sources'">
  204.             )
  205.         </xsl:if>
  206.     </xsl:template>
  207.  
  208.     <xsl:template match="OrderExpression">
  209.         <xsl:apply-templates select="./*[1]"/>
  210.         <xsl:apply-templates select="./Asc"/>
  211.         <xsl:apply-templates select="./Desc"/>
  212.     </xsl:template>
  213.  
  214.     <xsl:template match="Asc">
  215.         ASC
  216.     </xsl:template>
  217.  
  218.     <xsl:template match="Desc">
  219.         DESC
  220.     </xsl:template>
  221.  
  222.     <!-- Asterisk                                                         -->
  223.     <xsl:template match="Asterisk">*</xsl:template>
  224.  
  225.     <!-- Count/Min/Max/Sum                                                -->
  226.     <xsl:template match="Count|Min|Max|Sum">
  227.         <xsl:variable name="function">
  228.             <xsl:choose>
  229.                 <xsl:when test="name()='Count'"> COUNT </xsl:when>
  230.                 <xsl:when test="name()='Min'"> MIN </xsl:when>
  231.                 <xsl:when test="name()='Max'"> MAX </xsl:when>
  232.                 <xsl:when test="name()='Sum'"> SUM </xsl:when>
  233.             </xsl:choose>
  234.         </xsl:variable>
  235.         <xsl:value-of select="$function"/>( <xsl:apply-templates select="./*[1]"/> )
  236.     </xsl:template>
  237.  
  238.     <!-- Binary expressions                                               -->
  239.     <!-- Equal/NotEqual/Greater/GreaterOrEqual/Less/LessOrEqual/In/And/Or/Plus/Minus/Divide/Multiply
  240.          expressions                                                      -->
  241.     <xsl:template match="Equal|NotEqual|Greater|GreaterOrEqual|Less|LessOrEqual|In|And|Or|Plus|Minus|Divide|Multiply">
  242.         <xsl:variable name="operator">
  243.             <xsl:choose>
  244.                 <xsl:when test="name()='Equal'">            =        </xsl:when>
  245.                 <xsl:when test="name()='NotEqual'">            <>    </xsl:when>
  246.                 <xsl:when test="name()='Greater'">            >        </xsl:when>
  247.                 <xsl:when test="name()='GreaterOrEqual'">    >=        </xsl:when>
  248.                 <xsl:when test="name()='Less'">                <    </xsl:when>
  249.                 <xsl:when test="name()='LessOrEqual'">        <=    </xsl:when>
  250.                 <xsl:when test="name()='In'">                IN        </xsl:when>
  251.                 <xsl:when test="name()='And'">                AND        </xsl:when>
  252.                 <xsl:when test="name()='Or'">                OR        </xsl:when>
  253.                 <xsl:when test="name()='Plus'">                +        </xsl:when>
  254.                 <xsl:when test="name()='Minus'">            -        </xsl:when>
  255.                 <xsl:when test="name()='Divide'">            /        </xsl:when>
  256.                 <xsl:when test="name()='Multiply'">            *        </xsl:when>
  257.             </xsl:choose>
  258.         </xsl:variable>
  259.         (
  260.             <xsl:call-template name="print-children-list">
  261.                 <xsl:with-param name="operator" select="$operator"/>
  262.             </xsl:call-template>
  263.         )
  264.     </xsl:template>
  265.     
  266.     <!-- By default don't do anything                                     -->
  267.     <xsl:template match="*">
  268.     </xsl:template>
  269.  
  270.     <!-- Print a schema object                                               -->
  271.     <xsl:template name="build-quoted-schema-object"> 
  272.         <xsl:param name="schema-object-node" select="."/>
  273.  
  274.         <xsl:variable name="schema">
  275.             <xsl:apply-templates select="$schema-object-node/Schema"/>
  276.         </xsl:variable>
  277.         <xsl:variable name="table">
  278.             <xsl:apply-templates select="$schema-object-node/Name"/>
  279.         </xsl:variable>
  280.         <xsl:choose>
  281.             <xsl:when test="$schema = ''">
  282.                 <xsl:value-of select="$table"/>
  283.             </xsl:when>
  284.             <xsl:otherwise>
  285.                 <xsl:value-of select="concat($schema,'.', $table)"/>
  286.             </xsl:otherwise>
  287.         </xsl:choose>
  288.     </xsl:template>
  289.  
  290.     <!-- Convert an identifier to the OLEDB quotation form                -->
  291.     <xsl:template name="quote-identifier"> 
  292.         <xsl:param name="identifier" select="."/>
  293.  
  294.         <xsl:value-of select="$IdentifierStartQuotingCharacter"/>
  295.         <xsl:call-template name="normalize-entity-aux">
  296.             <xsl:with-param name="entity" select="$identifier"/>
  297.             <xsl:with-param name="end-quoting-char" select="$IdentifierEndQuotingCharacter"/>
  298.         </xsl:call-template>
  299.         <xsl:value-of select="$IdentifierEndQuotingCharacter"/>
  300.     </xsl:template>
  301.  
  302.     <!-- Convert a string to the string quotation form                    -->
  303.     <xsl:template name="quote-string"> 
  304.         <xsl:param name="string" select="."/>
  305.  
  306.         <xsl:value-of select="$StringStartQuotingCharacter"/>
  307.         <xsl:call-template name="normalize-entity-aux">
  308.             <xsl:with-param name="entity" select="$string"/>
  309.             <xsl:with-param name="end-quoting-char" select="$StringEndQuotingCharacter"/>
  310.         </xsl:call-template>
  311.         <xsl:value-of select="$StringEndQuotingCharacter"/>
  312.     </xsl:template>
  313.  
  314.     <!-- Convert an entity to the quotation form (recursive, aux)  by
  315.          duplicating the end quoting character                            -->
  316.     <xsl:template name="normalize-entity-aux"> 
  317.         <xsl:param name="entity"/>
  318.         <xsl:param name="end-quoting-char"/>
  319.  
  320.         <xsl:choose>
  321.             <xsl:when test="contains($entity, $end-quoting-char)">
  322.                 <xsl:value-of select="substring-before($entity, $end-quoting-char)"/>
  323.                 <xsl:value-of select="$end-quoting-char"/>
  324.                 <xsl:value-of select="$end-quoting-char"/>
  325.                 <xsl:call-template name="normalize-entity-aux">
  326.                     <xsl:with-param name="entity" select="substring-after($entity, $end-quoting-char)"/>
  327.                     <xsl:with-param name="end-quoting-char" select="$end-quoting-char"/>
  328.                 </xsl:call-template>
  329.             </xsl:when>
  330.             <xsl:otherwise>
  331.                 <xsl:value-of select="$entity"/>
  332.             </xsl:otherwise>
  333.         </xsl:choose>
  334.     </xsl:template>
  335.  
  336.     <!-- Print the children list                                          -->
  337.     <xsl:template name="print-children-list">
  338.         <xsl:param name="operator" select="','"/>
  339.         
  340.         <xsl:call-template name="print-list">
  341.             <xsl:with-param name="value-node" select="./*"/>
  342.             <xsl:with-param name="operator" select="$operator"/>
  343.         </xsl:call-template>
  344.     </xsl:template>
  345.  
  346.     <!-- Print a list                                                     -->
  347.     <xsl:template name="print-list">
  348.         <xsl:param name="operator" select="','"/>
  349.         <xsl:param name="value-node" select="."/>
  350.  
  351.         <xsl:for-each select="$value-node">
  352.             <xsl:apply-templates select="."/>
  353.             <xsl:if test="position()!=last()">
  354.                 <xsl:value-of select="$operator"/>
  355.             </xsl:if>
  356.         </xsl:for-each>
  357.     </xsl:template>
  358.  
  359.     <!-- Get the value of a parameter ref for the query                   -->
  360.     <xsl:template name="print-non-parametric-parameter-ref">
  361.         <xsl:param name="parameter-reference"/>
  362.  
  363.         <xsl:variable name="reference"><xsl:value-of select="$parameter-reference/@ref"/></xsl:variable>
  364.         <xsl:call-template name="print-non-parametric-parameter">
  365.             <xsl:with-param name="parameter" select="/Statement/Parameters/Parameter[@id=$reference]"/>
  366.         </xsl:call-template>
  367.     </xsl:template>
  368.  
  369.     <!-- Get the value of a parameter ref for the query                   -->
  370.     <xsl:template name="print-non-parametric-parameter">
  371.         <xsl:param name="parameter"/>
  372.  
  373.         <xsl:variable name="db-type"><xsl:value-of select="$parameter/@DBTYPE"/></xsl:variable>
  374.         <xsl:variable name="value"><xsl:value-of select="$parameter/text()"/></xsl:variable>
  375.         <xsl:choose>
  376.             <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>
  377.             <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>
  378.             <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>
  379.             <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>
  380.             <xsl:when test="$db-type = 'DBTYPE_I1'"><xsl:value-of select="$value"/></xsl:when>
  381.             <xsl:when test="$db-type = 'DBTYPE_I2'"><xsl:value-of select="$value"/></xsl:when>
  382.             <xsl:when test="$db-type = 'DBTYPE_I4'"><xsl:value-of select="$value"/></xsl:when>
  383.             <xsl:when test="$db-type = 'DBTYPE_I8'"><xsl:value-of select="$value"/></xsl:when>
  384.             <xsl:when test="$db-type = 'DBTYPE_UI1'"><xsl:value-of select="$value"/></xsl:when>
  385.             <xsl:when test="$db-type = 'DBTYPE_UI2'"><xsl:value-of select="$value"/></xsl:when>
  386.             <xsl:when test="$db-type = 'DBTYPE_UI4'"><xsl:value-of select="$value"/></xsl:when>
  387.             <xsl:when test="$db-type = 'DBTYPE_UI8'"><xsl:value-of select="$value"/></xsl:when>
  388.             <xsl:when test="$db-type = 'DBTYPE_R4'"><xsl:value-of select="$value"/></xsl:when>
  389.             <xsl:when test="$db-type = 'DBTYPE_R8'"><xsl:value-of select="$value"/></xsl:when>
  390.             <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>
  391.             <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>
  392.             <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>
  393.             <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>
  394.         </xsl:choose>
  395.     </xsl:template>
  396. </xsl:stylesheet>
  397.