github.com/matislovas/ratago@v0.0.0-20240408115641-cc0857415a7a/xslt/testdata/general/bug-5-.xsl (about)

     1  <?xml version = "1.0" encoding = "UTF-8"?>
     2  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
     3  <xsl:variable name="ACTIONgrid" select="//GROUP[@type='REC' and not(@name=preceding::GROUP[@type='REC']/@name)]/@name"/>
     4  <xsl:template match='/'>
     5  		<html>
     6  			<head>
     7  				<title>Churn by Product</title>
     8  				<style type="text/css">	.PROD {background-color:cyan}
     9  	.PROD * {background-color:cyan}
    10  	.ACT {background-color:green;font-weight:bold}
    11  	.ACT * {background-color:green;font-weight:bold}
    12  	.NR {background-color:yellow;color:blue}
    13  	.NR * {background-color:yellow;color:blue}
    14  	.RC {background-color:yellow;color:red}
    15  	.RC * {background-color:yellow;color:red}
    16  
    17  				</style>
    18  			</head>
    19  			<body>
    20  				<h1><center>Churn by Product</center></h1>
    21  				<table width="100%">
    22  					<tr>
    23  						<td width="50%" align="left" valign="top">
    24  							Run Date: <xsl:value-of select="XMLDATA/RUNDATE"/><br/>
    25  							Parameters:
    26  						</td>
    27  						<td align="right" valign="top">
    28  							<table><tr><th>Legend</th></tr><tr class="PROD"><td>Product</td></tr>
    29  <tr class="ACT"><td>Action</td></tr>
    30  <tr class="NR"><td>Non-Recurring</td></tr>
    31  <tr class="RC"><td>Recurring</td></tr>
    32  
    33  							</table>
    34  						</td>
    35  					</tr>
    36  				</table>
    37  				<table align="center"><xsl:apply-templates select="/XMLDATA/GROUP"/></table>
    38  			</body>
    39  		</html>
    40  	</xsl:template><xsl:template match="GROUP[@type='PRODUCT']">
    41  		<tr>
    42  <xsl:attribute name="class">
    43  PROD
    44  </xsl:attribute>
    45  
    46  			<td><xsl:value-of select='.//ROW[1]/PRODUCT'/></td>
    47  			<td>Proj. Rev: <xsl:value-of select='sum(.//ROW/PREV)'/></td>
    48  			<td>Actual Rev: <xsl:value-of select='sum(.//ROW/AREV)'/></td>
    49  		</tr>
    50  		<xsl:apply-templates select='GROUP'/>
    51  		<tr>
    52  <xsl:attribute name="class">
    53  PROD
    54  </xsl:attribute>
    55  
    56  		</tr>
    57  </xsl:template>
    58  
    59  <xsl:template match="GROUP[@type='ACTION']">
    60  	<xsl:variable name='grp' select='.'/>
    61  		<tr>
    62  <xsl:attribute name="class">
    63  ACT
    64  </xsl:attribute>
    65  
    66  			<td><xsl:value-of select='.//ROW[1]/ACTION'/></td>
    67  			<td>Proj. Rev: <xsl:value-of select='sum(.//ROW/PREV)'/></td>
    68  			<td>Act. Rev: <xsl:value-of select='sum(.//ROW/AREV)'/></td>
    69  		</tr>
    70  		<tr>
    71  				<xsl:for-each select='$ACTIONgrid'>
    72  				<xsl:sort select='.'/>
    73  				<td valign='top'>
    74  					<xsl:apply-templates select='$grp/GROUP[@name=current()]'/>
    75  				</td>
    76  				</xsl:for-each>
    77  		</tr>
    78  		<tr>
    79  <xsl:attribute name="class">
    80  ACT
    81  </xsl:attribute>
    82  
    83  		</tr>
    84  </xsl:template>
    85  
    86  <xsl:template match="GROUP[@type='REC']">
    87  	<table>
    88  		<tr>
    89  <xsl:attribute name="class">
    90  
    91  						<xsl:choose>
    92  							<xsl:when test="@name='Recurring'">RC</xsl:when>
    93  							<xsl:otherwise>NR</xsl:otherwise>
    94  						</xsl:choose>
    95  					
    96  </xsl:attribute>
    97  
    98  			<td><xsl:value-of select='.//ROW[1]/REC'/></td>
    99  			<td>Number: <xsl:value-of select='sum(.//ROW/NUM)'/></td>
   100  			<td>Proj. Rev: <xsl:value-of select='sum(.//ROW/PREV)'/></td>
   101  			<td>Act. Rev: <xsl:value-of select='sum(.//ROW/AREV)'/></td>
   102  		</tr>
   103  		<tr>
   104  			<td>Segment</td>
   105  			<td>Number</td>
   106  			<td>Proj. Rev</td>
   107  			<td>Act. Rev</td>
   108  		</tr>
   109  		<xsl:apply-templates select='ROW'/>
   110  		<tr>
   111  <xsl:attribute name="class">
   112  
   113  						<xsl:choose>
   114  							<xsl:when test="@name='Recurring'">RC</xsl:when>
   115  							<xsl:otherwise>NR</xsl:otherwise>
   116  						</xsl:choose>
   117  					
   118  </xsl:attribute>
   119  
   120  		</tr>
   121  	</table>
   122  </xsl:template>
   123  
   124  
   125  <xsl:template match='ROW'>
   126  	<tr>
   127  
   128  		<xsl:apply-templates select='SEGMENT'/>
   129  		<xsl:apply-templates select='NUM'/>
   130  		<xsl:apply-templates select='PREV'/>
   131  		<xsl:apply-templates select='AREV'/>
   132  	</tr>
   133  </xsl:template>
   134  
   135  <xsl:template match='SEGMENT'>
   136  	<td>
   137  		<xsl:value-of select='.'/>
   138  	</td>
   139  </xsl:template>
   140  
   141  <xsl:template match='NUM'>
   142  	<td>
   143  		<xsl:value-of select='.'/>
   144  	</td>
   145  </xsl:template>
   146  
   147  <xsl:template match='PREV'>
   148  	<td>
   149  		<xsl:value-of select='.'/>
   150  	</td>
   151  </xsl:template>
   152  
   153  <xsl:template match='AREV'>
   154  	<td>
   155  		<xsl:value-of select='.'/>
   156  	</td>
   157  </xsl:template>
   158  </xsl:stylesheet>