<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<HTML>
<HEAD>
<STYLE TYPE="text/css">
  TD.group { background-color:teal;color:white }
  TD.step { background-color:beige }
</STYLE>

</HEAD>
<BODY>
<TABLE border='0' cellpadding='2' cellspacing ='0' style='font: 9px arial;border-width:0px;border-spacing:0px;border-style:none' width="100%" >
<!-- Header row for Task Sequence -->
<TR >
		<TD style='background-color:black;color:white;'><B>Group</B></TD>
		<TD style='background-color:black;color:white;'><B>Description</B></TD>
		<TD style='background-color:black;color:white;'></TD>
		<TD style='background-color:black;color:white;'><B>Conditions</B></TD>
		<TD style='background-color:black;color:white;'></TD>
		<xsl:for-each select="descendant::group">
            <TD style='background-color:black;color:white;'></TD>
        </xsl:for-each>
</TR> 

<!-- Parse Each Group -->
<xsl:for-each select="SmsTaskSequencePackage/SequenceData/sequence//group | sequence//group">
	<TR  >
        <!-- Indent for parent groups, i.e. add cells for the number of group ancestors -->
        <xsl:for-each select="ancestor::group">
            <TD></TD>
        </xsl:for-each>
        <!-- Add the group name and description -->
        <TD Class='group'><xsl:value-of select="@name"/></TD>
		<TD Class='group'><xsl:value-of select="@description"/></TD>
		<TD Class='group'>
		<!-- Output the conditions for the group -->
		<xsl:if test="@continueOnError='true'">
                continue on error
                </xsl:if>
                <!-- Conditions with preceding operators -->
                <xsl:if test="./condition//operator">
                    <xsl:for-each select="./condition//operator">
                        ( <xsl:value-of select="@type"/> <BR />
                        <xsl:value-of select=".//expression//variable[@name='Query']"/>
                        <xsl:value-of select=".//expression//variable[@name='Variable']"/>
                        <xsl:value-of select=".//expression//variable[@name='Operator']"/>
                        <xsl:value-of select=".//expression//variable[@name='Value']"/>
                        )
                    </xsl:for-each>
                </xsl:if>
                <!-- Conditions with no preceding operators -->
                <xsl:if test="not(./condition//operator)">
                    <xsl:for-each select="./condition//expression">
                      <xsl:value-of select=".//variable[@name='Query']"/>
                      <xsl:value-of select=".//variable[@name='Variable']"/><BR />
                      <xsl:value-of select=".//variable[@name='Operator']"/><BR />
                      <xsl:value-of select=".//variable[@name='Value']"/><BR />
                    </xsl:for-each>
                </xsl:if> 
		</TD>
		<!-- Trailing cells for child groups, i.e. add cells for the number of group decendants -->
		<TD Class='group'></TD>
		<TD Class='group'></TD>
		<TD Class='group'></TD>
		<xsl:for-each select="descendant::group">
            <TD Class='group'></TD>
        </xsl:for-each>
	</TR>
    <!-- Parse Each Task(Step) Display Header -->
    <TR >
        <!-- Indent for parent groups, i.e. add cells for the number of group ancestors -->    
        <xsl:for-each select="ancestor::group">
            <TD></TD>
        </xsl:for-each>
        <!-- Display header only if a child step exists -->
        <xsl:if test="child::step">
            <TD><B>Conditions</B></TD>
            <TD><B>Task</B></TD>
            <TD><B>Description</B></TD>
            <TD><B>Package</B></TD>
            <TD><B>Action</B></TD>
            <TD><B>Variables</B></TD>
        </xsl:if> 
    </TR>
	<!-- Parse Each Task(Step) that is not disabled -->
	<xsl:for-each select="step[not(@disable='true')]">
        <TR >
        <!-- Indent for parent groups of parent, i.e. add cells for the number of group ancestors of the parent group -->    
        <xsl:for-each select="parent::group/ancestor::group">
            <TD ></TD>
        </xsl:for-each>
        <!-- Conditions for steps -->
        <TD Class='step'>
            <xsl:if test="@continueOnError='true'">
                continue on error
            </xsl:if>
            <!-- Conditions with  preceding operators -->
            <xsl:if test="./condition//operator">
                <xsl:for-each select="./condition//operator">
                    ( <xsl:value-of select="@type"/> <BR />
                      <xsl:value-of select=".//expression//variable[@name='Query']"/>
                      <xsl:value-of select=".//expression//variable[@name='Variable']"/>
                      <xsl:value-of select=".//expression//variable[@name='Operator']"/>
                      <xsl:value-of select=".//expression//variable[@name='Value']"/>
                      )
                      
                </xsl:for-each>
            </xsl:if>
            <!-- Conditions with no preceding operators -->
            <xsl:if test="not(./condition//operator)">
                <xsl:for-each select="./condition//expression">
                      <xsl:value-of select=".//variable[@name='Query']"/>
                      <xsl:value-of select=".//variable[@name='Variable']"/><BR />
                      <xsl:value-of select=".//variable[@name='Operator']"/><BR />
                      <xsl:value-of select=".//variable[@name='Value']"/><BR />
                </xsl:for-each>    
            </xsl:if>
        </TD>
        <!-- Output Name and Description of Step -->
        <TD Class='step'><xsl:value-of select="@name"/></TD>
        <TD Class='step'><xsl:value-of select="@description"/></TD>
        <!-- Output the PackageID, DriverPackageID or CustomSettingPackageID or OSPackageIDs for the step -->
        <TD Class='step'>
            <xsl:for-each select=".//variable[@name='PackageID' or @name='OSDApplyDriverDriverPackageID' or @name='ConfigFilePackage' or @name='ImagePackageID']">
                <xsl:value-of select="."/><BR />
            </xsl:for-each>    
        </TD>
        <!-- Output the step action -->
        <TD Class='step'><xsl:value-of select="action"/></TD>
        <TD Class='step'>
            <!-- Output non-commandline variables (commandline should be in previous action field) -->
            <xsl:for-each select="defaultVarList/variable[not(@name='CommandLine')]">
                <xsl:value-of select="./@name"/>:<xsl:value-of select="." /><BR/>
            </xsl:for-each>    
        </TD>
        </TR>
        
    </xsl:for-each> <!-- Step -->
        
</xsl:for-each> <!-- Group -->

</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
