Skip to content

Commit

Permalink
#10 xsl fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Oct 20, 2017
1 parent 8f4162a commit 23cc88f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 16 deletions.
58 changes: 42 additions & 16 deletions src/main/resources/org/jpeek/jpeek.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SOFTWARE.
<meta name="description" content="jpeek metric"/>
<meta name="keywords" content="code quality metrics"/>
<meta name="author" content="jpeek.org"/>
<link rel="stylesheet" href="//cdn.rawgit.com/yegor256/tacit/gh-pages/tacit-css-1.1.1.min.css"/>
<link rel="stylesheet" href="http://cdn.rawgit.com/yegor256/tacit/gh-pages/tacit-css-1.1.1.min.css"/>
<title>
<xsl:text>jpeek</xsl:text>
</title>
Expand All @@ -46,7 +46,14 @@ SOFTWARE.
</html>
</xsl:template>
<xsl:template match="app">
<h1>Metric</h1>
<p>
<a href="http://www.jpeek.org">
<img src="http://www.jpeek.org/logo.svg" style="height:60px"/>
</a>
</p>
<h1>
<xsl:value-of select="@title"/>
</h1>
<table>
<colgroup>
<col/>
Expand All @@ -57,7 +64,7 @@ SOFTWARE.
<th>
<xsl:text>ID</xsl:text>
</th>
<th>
<th style="text-align:right">
<xsl:text>Value</xsl:text>
</th>
</tr>
Expand All @@ -69,31 +76,50 @@ SOFTWARE.
</xsl:template>
<xsl:template match="package">
<tr>
<th>
<strong>
<xsl:value-of select="@id"/>
</strong>
</th>
<th>
<td>
<code>
<strong>
<xsl:value-of select="@id"/>
</strong>
</code>
</td>
<td style="text-align:right">
<xsl:value-of select="@value"/>
</th>
</td>
</tr>
<xsl:apply-templates select="class"/>
</xsl:template>
<xsl:template match="class">
<tr>
<th>
<xsl:value-of select="@id"/>
</th>
<th>
<td>
<code>
<xsl:value-of select="@id"/>
</code>
</td>
<td>
<xsl:if test="@color">
<xsl:attribute name="style">
<xsl:text>text-align:right;</xsl:text>
<xsl:text>color:</xsl:text>
<xsl:value-of select="@color"/>
<xsl:choose>
<xsl:when test="@color='red'">
<xsl:text>red</xsl:text>
</xsl:when>
<xsl:when test="@color='green'">
<xsl:text>green</xsl:text>
</xsl:when>
<xsl:when test="@color='yellow'">
<xsl:text>orange</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>inherit</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>;</xsl:text>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="@value"/>
</th>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
9 changes: 9 additions & 0 deletions src/test/java/org/jpeek/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
*/
package org.jpeek;

import com.jcabi.matchers.XhtmlMatchers;
import com.jcabi.xml.XMLDocument;
import com.jcabi.xml.XSLDocument;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -49,6 +52,12 @@ public void createsXmlReports() throws IOException {
Files.exists(output.resolve("TotalFiles.xml")),
Matchers.equalTo(true)
);
MatcherAssert.assertThat(
XSLDocument.make(
this.getClass().getResourceAsStream("jpeek.xsl")
).applyTo(new XMLDocument(output.resolve("LCOM.xml").toFile())),
XhtmlMatchers.hasXPath("//xhtml:body")
);
}

}

0 comments on commit 23cc88f

Please sign in to comment.