-1

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>

The issue am having is that I can't seem to make it display both the result set template and the report template, further more its not applying the CSS. I did have a working copy that just needed muenchian grouping implementing but I took 1 step forward and 5 steps back attempting this :P

EDIT: Okay so the CSS is now working. Although its not retrieving the correct values from the xml.

EDIT: fixed those issues

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"/>

misterbear
  • 803
  • 2
  • 13
  • 33
  • What do you mean by "Fixed those issues"? That your post no longer requires an answer? If not, what is the issue that persists? – Mathias Müller Dec 03 '13 at 14:55
  • The css now displays, am trying to implement hover at the moment in my css to make the entire row change colour giving a highlight effect and underline the first cell. but my main question is, if i wanted to create tables with the grouping of filename and level how would i quite do that? – user2983601 Dec 03 '13 at 15:10
  • It's rather hard to help without any indication of how the input XML is structured. But on a more general note: if you're asking how to do multiple grouping, you already have plenty of answers on this on SO - hundreds, I'd say. – Mathias Müller Dec 03 '13 at 15:15
  • Am looking at this specific one, http://stackoverflow.com/questions/948218/xslt-3-level-grouping-on-attributes/955527#955527. But I don't quite understand what's going on. – user2983601 Dec 03 '13 at 15:15
  • In your templates I cannot see that you attempted to do Muenchian grouping. We expect that you at least try this yourself. Start by understanding one-level grouping with a key - otherwise there is no point in trying to group by multiple elements. Last remark: If you use XSLT 2.0 there is absolutely no need for Muenchian grouping. – Mathias Müller Dec 03 '13 at 15:35
  • I would use xsl 2.0 but browsers don't support it yet. am attempting to do just by name am attempting to group the data ive posted above. – user2983601 Dec 03 '13 at 15:38

1 Answers1

1

Use the following process to add Muenchian grouping to your template:

  • Create an xsl:key with an arbitrary name attribute and a match attribute which corresponds to the subset of nodes you want to group
  • Set the use attribute to the node that you want to group by to create an index
  • Use one of the following techniques to find unique nodes:
    • Use generate-id on both the current node and the first node in the group
    • Compare the generate-id of a selected node with the generate-id of the first node in the group to which your selected node belongs
    • Compare the count of the nodes in the set formed by the union of a selected node and the first node in the group: if it equals 1, they're the same node

References

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265