MSAS: Extensions for XSLT cube management

Technical Value

In our recent post “MSAS: XSLT for cube management ” we presented a template for the cube management infrastructure based on XSL transformations.

In the first feedback people were asking about modifications that allow producing several <Parallel> blocks in single <Batch> or combining <Parallel> blocks with single commands staying alone. For example you could want to have your fact processing in <Parallel> followed by <ClearCache> in one <Batch>:

  1. <Batch>
  2.    <Parallel>
  3.      <Process></Process>
  4.      <Process></Process>
  5.    </Parallel>
  6.    <ClearCache></ClearCache>
  7. </Batch>

Please note that <ClearCache> must stay directly under <Batch> and cannot be under <Parallel>.

You need <ClearCache> after you process a many-to-many measure group, because of the old AS bug.

Such a modification is not a problem at all! Let’s add a column [Order] into the control table and define the following transformation rules:

  1. Commands having the same [Order] value should be grouped in a separate <Parallel> block
  2. A single command with unique [Order] value should stay without <Parallel>
  3. The [Order] should define the real order in <Batch> 


Now we have a choice of how exactly to implement this feature:


  1. Pass [Order] as an additional element (or attribute) for <ASObject> in XML and do the grouping in XSLT
  2. Do the grouping already in XML (by SQL FOR XML) and translate groups to <Parallel> in XSLT

Let’s say we choose the second option because the first one requires using some tricks with KEY elements and functions in XSLT and we want to keep XSLT as simple as possible.

Now our SQL FOR XML will look like following:

  2. [Order] as '@Order',
  3. CAST((
  4. SELECT distinct
  5.    [ObjectType] '@ObjectType'
  6.   ,[NeedCreate] '@NeedCreate'
  7.   ,[DatabaseID]
  8.   ,[DimensionID]
  9.   ,[CubeID]
  10.   ,[MeasureGroupID]
  11.   ,[PartitionID]
  12.   ,[Parameter_1]
  13.   ,[ActionType]
  14. FROM [dbo].[OLAP_ToDo] t2
  15. WHERE t2.JobType=t1.JobType
  16.        AND (t2.[Order]=t1.[Order] OR (t2.[Order] is null AND t1.[Order] is null))
  17. FOR XML PATH('ASObject')
  18. ) AS XML)
  19. FROM [dbo].[OLAP_ToDo] t1
  20. WHERE JobType='Regular'
  21. GROUP BY [Order],[JobType]
  22. ORDER BY [Order]
  23. FOR XML PATH('Group'), ROOT('ASObjects')

…and will deliver something like this:

  1. <ASObjects>
  2.   <Group Order="1">
  3.     <ASObject ObjectType=...>
  4.       ...
  5.     </ASObject>
  6.     <ASObject ObjectType=...>
  7.       ...
  8.     </ASObject>
  9.   </Group>
  10.   <Group Order="2">
  11.     <ASObject ObjectType=...>
  12.       ...
  13.     </ASObject>
  14.   </Group>
  15. </ASObjects>

The last thing to do is to adjust how we interpret it in XSLTs. Here is for example how the beginning of ProcessFacts.xslt should look like:

  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
  2.   <xsl:output omit-xml-declaration="yes"/>
  4.   <xsl:template match="ASObjects">
  5.     <Batch xmlns="http://schemas.microsoft.com/analysisservices/2003/engine" >
  6.       <xsl:apply-templates/>
  7.     </Batch>
  8.   </xsl:template>
  10.   <xsl:template match="Group">
  11.     <xsl:if test="count(ASObject) &gt; 1">
  12.       <Parallel xmlns="http://schemas.microsoft.com/analysisservices/2003/engine" >
  13.         <xsl:apply-templates/>
  14.       </Parallel>
  15.     </xsl:if>
  16.     <xsl:if test="count(ASObject) = 1">
  17.       <xsl:apply-templates/>
  18.     </xsl:if>
  19.   </xsl:template>
  20.   ...
  21. </xsl:stylesheet>

Hope it helps!

P.S. Here is what you need in your ProcessFacts.xslt to produce <ClearCache> (an example for the level of database):


  1. <xsl:template match="ASObject[@ObjectType='Database' and ActionType='ClearCache']">
  2.   <ClearCache xmlns="http://schemas.microsoft.com/analysisservices/2003/engine" >
  3.     <Oabject>
  4.       <DatabaseID>
  5.         <xsl:value-of select="DatabaseID"/>
  6.       </DatabaseID>
  7.     </Oabject>
  8.   </ClearCache>
  9. </xsl:template>


Neuen Kommentar schreiben

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.


  • Keine HTML-Tags erlaubt.
  • HTML - Zeilenumbrüche und Absätze werden automatisch erzeugt.
  • Web page addresses and email addresses turn into links automatically.
Teilen auf

Newsletter Anmeldung

Abonnieren Sie unseren Newsletter!
Lassen Sie sich regelmäßig über alle Neuigkeiten rundum ORAYLIS und die BI- & Big-Data-Branche informieren.

Jetzt anmelden