muenchian分组,有人可以解释一下吗?

时间:2013-12-03 14:35:34

标签: html css xml xslt

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&amp;chd=t:', report/percentages/@violation, ',', report/percentages/@potential, ',', report/percentages/@recommendation, ',', report/percentages/@pRecommendation, ',', report/percentages/@manualcheck, '&amp;chs=450x100&amp;chl=Violation|Potential Violation|Recommendation|Potential Recommendation|Manual Check&amp;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"/>

1 个答案:

答案 0 :(得分:0)

使用以下过程将Muenchian分组添加到模板中:

  • 使用任意xsl:key属性和name属性创建match,该属性对应于您要分组的节点子集
  • use属性设置为要分组的节点以创建索引
  • 使用以下技术之一查找唯一节点:
    • 在当前节点和组中的第一个节点
    • 上使用generate-id
    • 将所选节点的generate-id与所选节点所属的组中第一个节点的generate-id进行比较
    • 比较由所选节点的联合形成的集合中的count节点与组中的第一个节点:如果它等于1,则它们是相同的节点

<强>参考