HP Matrix Operating Environment Chargeback

Technical white paper | HP Matrix Operating Environment Chargeback
14
Figure 16. Minimal Excel report containing formatted text
Creating a report to show only service name, date, and service fixed cost
The following example shows a report displaying only a few attributes such as service name, metric date, and the service
fixed cost. The XSLT allows only the desired information to show in the reports.
As demonstrated in the section “Accessing the source data,” the service list is represented by the XML
/GetServiceUsageDetail/ServiceUsageDetail” element. The XSL below iterates over the service list
elements using the <xsl:for-each> element. The <xsl:value-of> element is used to select the desired nodes
and display its value for each service in the source XML.
Figure 17. XSL presenting only service name, date, and service fixed cost
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="html"/>
<xsl:template match="/">
<html><body>
<h2>Service Usage Detail Sample </h2>
<table border="1px" cellpadding="6px" cellspacing="0" style="font-family:
arial;font-size:16">
<tr bgcolor="blue" style="color:white;font-weight:bold">
<td>Service Name</td>
<td>Date</td>
<td>Fixed Cost</td>
</tr>
<xsl:for-each select="GetServiceUsageDetail/ServiceUsageDetail">
<tr>
<!-- Service data -->
<td><xsl:value-of select="serviceInformation/name"/></td>
<td><xsl:value-of select="date"/></td>
<td align="right"><xsl:value-of
select="resourceUsageDetail/fixedCost"/></td>
</tr>
</xsl:for-each>
</table>
</body></html>
</xsl:template>
Following is an example of how Excel displays the source XML data when the preceding XSL is applied. For more details
about how to prepare the source XML file to use the XSL and how to open the file in Excel, see Applying the formatter to the
source data.
Figure 18. Excel report containing only service name, date and service fixed cost
Adding attributes to an existing report
The following example shows how to add a new attribute to the existing XSL file displayed in Figure 17. As defined in Table
2, the <xsl:value-of> element is responsible for extracting the value of a specified node.
The XSL displayed in Figure 17 shows the service name, metric date, and service fixed cost. It is enhanced to also display
service organization ID, billing code, and owner attribute.