XSL:
<xsl:template match="/">
<html>
<head>
<title>RPT Report</title>
<link rel="stylesheet" type="text/css" href="resource/rpt.css" media="screen"/>
<script src="resource/sorttable.js"/>
</head>
<body>
<div style="margin: 10px;">
<table class="rpt">
<thead>
<tr>
<th>Key</th>
<th>Type</th>
<th>Total</th>
<th>Overview</th>
</tr>
</thead>
<tbody>
<td><img src="resource/fatal.gif" alt="Violations in build"
title="Violations in build"/></td>
<td class="left" nowrap="nowrap">Violations</td>
<td><xsl:value-of select="sum(report/resultset/@violation)"/></td>
<td rowspan="5">
<img><xsl:attribute name="src">
<xsl:value-of
select="concat('http://chart.apis.google.com/chart?cht=p3&chd=t:', report/percentages/@violation, ',', report/percentages/@potential, ',', report/percentages/@recommendation, ',', report/percentages/@pRecommendation, ',', report/percentages/@manualcheck, '&chs=450x100&chl=Violation|Potential Violation|Recommendation|Potential Recommendation|Manual Check&chco=000000,ff0000,6277b5,46b0a5,ffff00')"
/>
</xsl:attribute></img>
</td>
<tr>
<td><img src="resource/error.gif" alt="Potential Violation in build"
title="Potential Violation in build"/></td>
<td class="left">Potential Violation</td>
<td><xsl:value-of select="sum(report/resultset/@potential)"/></td>
</tr>
<tr>
<td>
<img src="resource/published.gif" alt="Recommendations in build"
title="Recommendations in build"/>
</td>
<td class="left">Recommendation</td>
<td>
<xsl:value-of select="sum(report/resultset/@recommendation)"/>
</td>
</tr>
<tr>
<td>
<img src="resource/draft.gif" alt="Potential Recommendations in build"
title="Potential Recommendations in build"/>
</td>
<td class="left">Potential Recommendation</td>
<td>
<xsl:value-of select="sum(report/resultset/pRecommendation)"/>
</td>
</tr>
<tr>
<td>
<img src="resource/warning.gif" alt="Manual Checks in build"
title="Warnings in build"/>
</td>
<td class="left">Manual Check</td>
<td>
<xsl:value-of select="sum(report/resultset/@manualcheck)"/>
</td>
</tr>
</tbody>
</table>
<br/>
<br/>
<xsl:apply-templates select="report"/>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="report">
<table class="rpt sortable">
<thead>
<tr>
<th class="center">Filename</th>
<th class="center">Level</th>
<th class="center">GID</th>
<th class="center">Message</th>
<th class="center">XPath</th>
<th class="center">Line Number</th>
<th class="center">Help</th>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="issue">
<xsl:sort select="@filename" order="descending" data-type="text"/>
</xsl:apply-templates>
</tbody>
</table>
</xsl:template>
<xsl:template match="issue">
<tr class="alt_0">
<td class="center"><a href="{@infocenterURL}"><xsl:value-of select="@filename"
/></a></td>
<td class="center"><xsl:value-of select="@level"/></td>
<td class="center"><xsl:value-of select="@gid"/></td>
<td class="center"><xsl:value-of select="@message"/></td>
<td class="center"><xsl:value-of select="@xpath"/></td>
<td class="center"><xsl:value-of select="@linenum"/></td>
<td class="center"><a href="{@helplink}">More</a></td>
</tr>
</xsl:template>
我遇到的问题是,我似乎无法显示result set
模板和report
模板,更多的是它没有应用CSS。我确实有一个工作副本,只需要muenchian分组实施,但我向前迈了一步,后退了5步:P
编辑:好的,现在CSS正在运行。虽然它没有从xml中检索正确的值。
编辑修复了这些问题
XML:
<report created="2013-12-02 13:38:42.15" pluginname="sal">
<percentages manualcheck="0" pRecommendation="0" potential="69" recommendation="0" violation="30"/>
<resultset created="2013-12-02 13:38:42.15" link="writers_reports/" manualcheck="0" name="" pRecommendation="0" potential="229" recommendation="0" violation="100"/>
<issue filename="rpt_automation.html" gid="506" helplink="" infocenterURL="" level="Potential Violation" linenum="63" message="Ensure that, with the border or outline, the keyboard focus indicator is visible to users." xpath="/html/body/div[3]/img"/>
<issue filename="rpt_summary.html" gid="506" helplink="" infocenterURL="" level="Potential Violation" linenum="61" message="Ensure that, with the border or outline, the keyboard focus indicator is visible to users." xpath="/html/body/div[3]/img"/>
<issue filename="scan_results.html" gid="506" helplink="" infocenterURL="" level="Potential Violation" linenum="50" message="Ensure that, with the border or outline, the keyboard focus indicator is visible to users." xpath="/html/body/div[3]/img"/>
<issue filename="what_is_rpt.html" gid="506" helplink="" infocenterURL="" level="Potential Violation" linenum="49" message="Ensure that, with the border or outline, the keyboard focus indicator is visible to users." xpath="/html/body/div[3]/img"/>
答案 0 :(得分:0)
使用以下过程将Muenchian分组添加到模板中:
xsl:key
属性和name
属性创建match
,该属性对应于您要分组的节点子集use
属性设置为要分组的节点以创建索引generate-id
generate-id
与所选节点所属的组中第一个节点的generate-id
进行比较count
节点与组中的第一个节点:如果它等于1,则它们是相同的节点<强>参考强>