Analysis Context
Introduction
Section titled “Introduction”The Analysis Context represents the current server and database schema information that SQL Enlight loads before starting the analysis.
The analysis context is an XML document that holds information for the current SQL Server, the current database.
The current database is determined initially from the SQL connection and later by the database switches ( USE [DatabaseName] statements) inside the script.
XML Schema
Section titled “XML Schema”Analysis Context XML Schema is included in SQL Enlight installation: \Schemas\AnalysisContext.xsd
Query the Analysis Context
Section titled “Query the Analysis Context”Example XPath expression for retrieving the XML node of the function ufnGetAccountingStartDate from database AdventureWorks:
<xsl:variable name="function" select="$context/Server/Databases/Database[@Name='AdventureWorks']/Functions/Function[@Name='ufnGetAccountingStartDate']"/>Or
<xsl:variable name="function" select="$server/Databases/Database[@Name='AdventureWorks']/Functions/Function[@Name='ufnGetAccountingStartDate']"/>The same XPath expression, but assuming that the ‘AdventureWorks’ database is the current database:
<xsl:variable name="function" select="$database/Functions/Function[@Name='ufnGetAccountingStartDate']"/>Generating Analysis Context XML
Section titled “Generating Analysis Context XML”Sometimes it can be handy to be able to test your analysis rules using different than the default test analysis context.
You can create your own analysis context XML for testing your analysis rules either by editing the AdventureWorksone or by using the Enlightcommand line tool with command analysiscontext.