Merge pull request #65 from radicallyopensecurity/html-report

Html report
This commit is contained in:
Patricia Piolon
2019-06-04 18:15:43 +02:00
committed by GitHub
24 changed files with 3227 additions and 1141 deletions

View File

@@ -188,17 +188,13 @@
<xs:complexType>
<xs:attribute ref="pieAttr" use="required"/>
<xs:attribute ref="pieElem" use="required"/>
<xs:attribute ref="pieHeight" use="required"/>
<xs:attribute ref="status" use="optional"/>
<xs:attribute ref="threshold" use="optional" default="1"/>
</xs:complexType>
</xs:element>
<xs:attribute name="pieAttr" type="xs:string"/>
<xs:attribute name="pieElem" type="xs:string"/>
<xs:attribute name="pieHeight" type="xs:integer"/>
<xs:attribute name="status" type="xs:string"/>
<xs:attribute name="threshold" type="xs:integer"/>
<xs:attribute name="inexecsummary">
<xs:simpleType>

View File

@@ -67,86 +67,6 @@
</xsl:for-each>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="unsortedFindingSummaryTable">
<xsl:for-each-group select="//finding" group-by="@threatLevel">
<xsl:for-each select="current-group()">
<findingEntry>
<xsl:attribute name="Ref">
<xsl:value-of select="@Ref"/>
</xsl:attribute>
<xsl:attribute name="status">
<xsl:value-of select="@status"/>
</xsl:attribute>
<xsl:attribute name="findingId">
<xsl:value-of select="@id"/>
</xsl:attribute>
<findingNumber>
<xsl:apply-templates select="." mode="number"/>
</findingNumber>
<findingType>
<xsl:value-of select="@type"/>
</findingType>
<findingDescription>
<xsl:choose>
<xsl:when test="description_summary">
<xsl:value-of select="description_summary"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="description" mode="summarytable"/>
</xsl:otherwise>
</xsl:choose>
</findingDescription>
<findingThreatLevel>
<xsl:value-of select="current-grouping-key()"/>
</findingThreatLevel>
</findingEntry>
</xsl:for-each>
</xsl:for-each-group>
</xsl:variable>
<xsl:variable name="findingSummaryTable">
<xsl:for-each select="$unsortedFindingSummaryTable/findingEntry">
<xsl:sort data-type="number" order="descending"
select="
(number(findingThreatLevel = 'Extreme') * 10)
+ (number(findingThreatLevel = 'High') * 9)
+ (number(findingThreatLevel = 'Elevated') * 8)
+ (number(findingThreatLevel = 'Moderate') * 7)
+ (number(findingThreatLevel = 'Low') * 6)
+ (number(findingThreatLevel = 'Unknown') * 3)
+ (number(findingThreatLevel = 'N/A') * 1)"/>
<xsl:variable name="findingThreatLevelClean"
select="translate(findingThreatLevel, '/', '_')"/>
<findingEntry>
<xsl:attribute name="Ref">
<xsl:value-of select="@Ref"/>
</xsl:attribute>
<xsl:attribute name="status">
<xsl:value-of select="@status"/>
</xsl:attribute>
<xsl:attribute name="findingId">
<xsl:value-of select="@findingId"/>
</xsl:attribute>
<!-- add an id for the first entry of each type so that we can link to it -->
<xsl:if
test="not(preceding-sibling::findingEntry/findingThreatLevel = findingThreatLevel)">
<xsl:attribute name="id">summaryTableThreatLevel<xsl:value-of
select="$findingThreatLevelClean"/></xsl:attribute>
</xsl:if>
<findingNumber>
<xsl:value-of select="findingNumber"/>
</findingNumber>
<findingType>
<xsl:value-of select="findingType"/>
</findingType>
<findingDescription>
<xsl:value-of select="findingDescription"/>
</findingDescription>
<findingThreatLevel>
<xsl:value-of select="findingThreatLevel"/>
</findingThreatLevel>
</findingEntry>
</xsl:for-each>
</xsl:variable>
<fo:block>
<fo:table xsl:use-attribute-sets="fwtable table borders">
<xsl:call-template name="checkIfLast"/>
@@ -213,6 +133,7 @@
</xsl:if>
<fo:table-cell xsl:use-attribute-sets="td">
<fo:block>
<!-- attach id to first finding of each threatLevel so pie charts can link to it -->
<xsl:if test="@id">
<xsl:attribute name="id">
<xsl:value-of select="@id"/>

653
xml/xslt/css.xslt Normal file
View File

@@ -0,0 +1,653 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template name="css">
/*@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
font-display: swap;
src: local('Open Sans Regular'), local('OpenSans-Regular');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
*/
/*! normalize.css v3.0.2 | MIT License | git.io/normalize */
/**
* 1. Set default font family to sans-serif.
* 2. Prevent iOS text size adjust after orientation change, without disabling
* user zoom.
*/
html {
font-family: sans-serif; /* 1 */
-ms-text-size-adjust: 100%; /* 2 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/**
* Remove default margin.
*/
body {
margin: 0;
}
/* HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined for any HTML5 element in IE 8/9.
* Correct `block` display not defined for `details` or `summary` in IE 10/11
* and Firefox.
* Correct `block` display not defined for `main` in IE 11.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
main,
menu,
nav,
section,
summary {
display: block;
}
/**
* 1. Correct `inline-block` display not defined in IE 8/9.
* 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
*/
audio,
canvas,
progress,
video {
display: inline-block; /* 1 */
vertical-align: baseline; /* 2 */
}
/**
* Prevent modern browsers from displaying `audio` without controls.
* Remove excess height in iOS 5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/**
* Address `[hidden]` styling not present in IE 8/9/10.
* Hide the `template` element in IE 8/9/11, Safari, and Firefox &lt; 22.
*/
[hidden],
template {
display: none;
}
/* Links
========================================================================== */
/**
* Remove the gray background color from active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* Improve readability when focused and also mouse hovered in all browsers.
*/
a:active,
a:hover {
outline: 0;
}
/* Text-level semantics
========================================================================== */
/**
* Address styling not present in IE 8/9/10/11, Safari, and Chrome.
*/
abbr[title] {
border-bottom: 1px dotted;
}
/**
* Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
*/
b,
strong,
.topLevelToCEntry {
font-weight: bold;
}
/**
* Address styling not present in Safari and Chrome.
*/
dfn {
font-style: italic;
}
/**
* Address variable `h1` font-size and margin within `section` and `article`
* contexts in Firefox 4+, Safari, and Chrome.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/**
* Address styling not present in IE 8/9.
*/
mark {
background: #ff0;
color: #000;
}
/**
* Address inconsistent and variable font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` affecting `line-height` in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
/* Embedded content
========================================================================== */
/**
* Remove border when inside `a` element in IE 8/9/10.
*/
img {
border: 0;
}
/**
* Correct overflow not hidden in IE 9/10/11.
*/
svg:not(:root) {
overflow: hidden;
}
/* Grouping content
========================================================================== */
/**
* Address margin not present in IE 8/9 and Safari.
*/
figure {
margin: 1em 40px;
}
/**
* Address differences between Firefox and other browsers.
*/
hr {
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 0;
}
/**
* Contain overflow in all browsers.
*/
pre {
overflow: auto;
}
/**
* Address odd `em`-unit font size rendering in all browsers.
*/
code,
kbd,
pre,
samp {
font-family: monospace, monospace;
font-size: 1em;
}
/* Tables
========================================================================== */
/**
* Remove most spacing between table cells.
*/
table {
border-collapse: collapse;
border-spacing: 0;
}
td,
th {
padding: 0;
}
/*
* Skeleton V2.0.4
* Copyright 2014, Dave Gamache
* www.getskeleton.com
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* 12/29/2014
*/
/* Table of contents
- Grid
- Base Styles
- Typography
- Links
- Buttons
- Forms
- Lists
- Code
- Tables
- Spacing
- Utilities
- Clearing
- Media Queries
*/
/* Grid
*/
.container {
position: relative;
width: 100%;
max-width: 960px;
margin: 0 auto;
padding: 0 20px;
box-sizing: border-box; }
.column,
.columns {
width: 100%;
float: left;
box-sizing: border-box; }
body > div.section {
border-bottom: 1px solid <xsl:value-of select="$c_support_light"/>;
padding: 4rem 0;
margin-top: 0;}
/* For devices larger than 400px */
@media (min-width: 400px) {
.container {
width: 85%;
padding: 0; }
}
/* For devices larger than 550px */
@media (min-width: 550px) {
.container {
width: 80%; }
.column,
.columns {
margin-left: 4%; }
.column:first-child,
.columns:first-child {
margin-left: 0; }
.one.column,
.one.columns { width: 4.66666666667%; }
.two.columns { width: 13.3333333333%; }
.three.columns { width: 22%; }
.four.columns { width: 30.6666666667%; }
.five.columns { width: 39.3333333333%; }
.six.columns { width: 48%; }
.seven.columns { width: 56.6666666667%; }
.eight.columns { width: 65.3333333333%; }
.nine.columns { width: 74.0%; }
.ten.columns { width: 82.6666666667%; }
.eleven.columns { width: 91.3333333333%; }
.twelve.columns { width: 100%; margin-left: 0; }
.one-third.column { width: 30.6666666667%; }
.two-thirds.column { width: 65.3333333333%; }
.one-half.column { width: 48%; }
/* Offsets */
.offset-by-one.column,
.offset-by-one.columns { margin-left: 8.66666666667%; }
.offset-by-two.column,
.offset-by-two.columns { margin-left: 17.3333333333%; }
.offset-by-three.column,
.offset-by-three.columns { margin-left: 26%; }
.offset-by-four.column,
.offset-by-four.columns { margin-left: 34.6666666667%; }
.offset-by-five.column,
.offset-by-five.columns { margin-left: 43.3333333333%; }
.offset-by-six.column,
.offset-by-six.columns { margin-left: 52%; }
.offset-by-seven.column,
.offset-by-seven.columns { margin-left: 60.6666666667%; }
.offset-by-eight.column,
.offset-by-eight.columns { margin-left: 69.3333333333%; }
.offset-by-nine.column,
.offset-by-nine.columns { margin-left: 78.0%; }
.offset-by-ten.column,
.offset-by-ten.columns { margin-left: 86.6666666667%; }
.offset-by-eleven.column,
.offset-by-eleven.columns { margin-left: 95.3333333333%; }
.offset-by-one-third.column,
.offset-by-one-third.columns { margin-left: 34.6666666667%; }
.offset-by-two-thirds.column,
.offset-by-two-thirds.columns { margin-left: 69.3333333333%; }
.offset-by-one-half.column,
.offset-by-one-half.columns { margin-left: 52%; }
}
/* Base Styles
*/
/* NOTE
html is set to 62.5% so that all the REM measurements throughout Skeleton
are based on 10px sizing. So basically 1.5rem = 15px :) */
html {
font-size: 62.5%; }
body {
font-size: 1.5em; /* currently ems cause chrome bug misinterpreting rems on body element */
line-height: 1.6;
font-weight: 400;
font-family: "Open Sans", "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif;
color: <xsl:value-of select="$c_support_dark"/>; }
/* Typography
*/
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: 2rem;
font-weight: 300; }
h1 { font-size: 4.0rem; line-height: 1.2; letter-spacing: -.1rem;}
h2 { font-size: 3.6rem; line-height: 1.25; letter-spacing: -.1rem; }
h3 { font-size: 3.0rem; line-height: 1.3; letter-spacing: -.1rem; }
h4 { font-size: 2.4rem; line-height: 1.35; letter-spacing: -.08rem; }
h5 { font-size: 1.8rem; line-height: 1.5; letter-spacing: -.05rem; }
h6 { font-size: 1.5rem; line-height: 1.6; letter-spacing: 0; }
/* Larger than phablet */
@media (min-width: 550px) {
h1 { font-size: 5.0rem; }
h2 { font-size: 4.2rem; }
h3 { font-size: 3.6rem; }
h4 { font-size: 3.0rem; }
h5 { font-size: 2.4rem; }
h6 { font-size: 1.5rem; }
}
p {
margin-top: 0; }
/* Links
*/
a {
color: <xsl:value-of select="$c_main"/>; }
a:hover {
color: <xsl:value-of select="$c_support_medium"/>; }
/* Lists
*/
ul {
list-style: circle inside; }
ol {
list-style: decimal inside; }
ol, ul {
padding-left: 0;
margin-top: 0; }
ul ul,
ul ol,
ol ol,
ol ul {
margin: 1.5rem 0 1.5rem 3rem;
font-size: 90%; }
li {
margin-bottom: 1rem; }
/* Code
*/
code {
padding: .2rem .5rem;
margin: 0 .2rem;
font-size: 90%;
white-space: nowrap;
background: <xsl:value-of select="$c_support_light"/>;
border: 1px solid <xsl:value-of select="$c_support_subtlydarkerlight"/>;
border-radius: 4px; }
pre {
background: <xsl:value-of select="$c_support_light"/>;
border: 1px solid <xsl:value-of select="$c_support_subtlydarkerlight"/>;
}
pre > code {
display: block;
padding: 1rem 1.5rem;
white-space: pre; }
/* Tables
*/
th,
td {
padding: 12px 15px;
text-align: left;
vertical-align: top;
border-bottom: 1px solid <xsl:value-of select="$c_support_medium"/>; }
th:first-child,
td:first-child {
padding-left: 0; }
th:last-child,
td:last-child {
padding-right: 0; }
th {background-color: }
/* Spacing
*/
button,
.button {
margin-bottom: 1rem; }
input,
textarea,
select,
fieldset {
margin-bottom: 1.5rem; }
pre,
blockquote,
dl,
figure,
table,
p,
ul,
ol,
form {
margin-bottom: 2.5rem; }
/* Utilities
*/
.u-full-width {
width: 100%;
box-sizing: border-box; }
.u-max-full-width {
max-width: 100%;
box-sizing: border-box; }
.u-pull-right {
float: right; }
.u-pull-left {
float: left; }
/* Misc
*/
hr {
margin-top: 3rem;
margin-bottom: 3.5rem;
border-width: 0;
border-top: 1px solid <xsl:value-of select="$c_main"/>; }
/* Clearing
*/
/* Self Clearing Goodness */
.container:after,
.row:after,
.u-cf {
content: "";
display: table;
clear: both; }
/* Media Queries
*/
/*
Note: The best way to structure the use of media queries is to create the queries
near the relevant code. For example, if you wanted to change the styles for buttons
on small devices, paste the mobile query code up in the buttons section and style it
there.
*/
/* Larger than mobile */
@media (min-width: 400px) {}
/* Larger than phablet (also point when grid becomes active) */
@media (min-width: 550px) {}
/* Larger than tablet */
@media (min-width: 750px) {}
/* Larger than desktop */
@media (min-width: 1000px) {}
/* Larger than Desktop HD */
@media (min-width: 1200px) {}
/* ROS specific */
.findingMetaBox {
background-color: <xsl:value-of select="$c_support_light"/>;
border-left: 1px solid <xsl:value-of select="$c_support_subtlydarkerlight"/>;
border-bottom: 1px solid <xsl:value-of select="$c_support_subtlydarkerlight"/>;
border-right: 1px solid <xsl:value-of select="$c_support_subtlydarkerlight"/>;
/* border-top is dynamically set according to finding severity */
padding: 3px 3px 3px 3px;
margin-bottom: 2rem;
}
.findingMetaBoxLabel {
font-weight: bold;
}
.status-new {
color: <xsl:value-of select="$color_new"/>;
}
.status-not_retested {
color: <xsl:value-of select="$color_notretested"/>;
}
.status-resolved {
color: <xsl:value-of select="$color_resolved"/>;
}
.errortext {
background-color: black;
color: <xsl:value-of select="$color_moderate"/>;
}
.censoredblock, .censoredtext {
background-color: black;
color: white;
font-weight: bold;
}
.finding-content {
margin-bottom: 2.5rem; }
.pieLegendText {
margin-left: 1rem;
}
h1, h2, h3, h4 {
margin-top: 5rem;
}
img {
width: 80%;
height: auto;
}
.logo {
width: 60%;
}
.title-client {
font-weight: bold;
}
.contents {
margin-bottom: 5rem;
}
.endOfDoc {
width: 25%;
margin-bottom: 10rem;
}
</xsl:template>
</xsl:stylesheet>

377
xml/xslt/fo_inline.xslt Normal file
View File

@@ -0,0 +1,377 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="xs"
version="2.0">
<xsl:import href="inline.xslt"/>
<xsl:template match="a">
<xsl:param name="execsummary" tunnel="yes"/>
<xsl:variable name="destination">
<xsl:choose>
<xsl:when test="starts-with(@href, '#')">
<xsl:value-of select="substring(@href, 2)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@href"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="checkLinkValidity"/>
<xsl:choose>
<xsl:when test="starts-with(@href, '#') and not(//*[@id = $destination])">
<fo:inline xsl:use-attribute-sets="errortext">WARNING: LINK TARGET NOT FOUND IN
DOCUMENT</fo:inline>
</xsl:when>
<xsl:when
test="(starts-with(@href, '#') and //*[@id = $destination][ancestor-or-self::*[@visibility = 'hidden']])">
<fo:inline xsl:use-attribute-sets="errortext">WARNING: LINK TARGET IS
HIDDEN</fo:inline>
</xsl:when>
<xsl:when
test="starts-with(@href, '#') and $execsummary = true() and //*[@id = $destination][ancestor-or-self::*[not(@inexecsummary = 'yes')]]">
<!-- linking to something that is not in the exec summary -->
<xsl:value-of select="local-name(*[@id = $destination])"/>
<xsl:text> </xsl:text>
<xsl:call-template name="linkText">
<xsl:with-param name="destination" select="$destination"/>
<xsl:with-param name="execsummary_linking_to_content_not_in_report" select="true()"></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<fo:basic-link xsl:use-attribute-sets="link">
<xsl:choose>
<xsl:when test="starts-with(@href, '#')">
<xsl:attribute name="internal-destination">
<xsl:value-of select="$destination"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="external-destination">
<xsl:value-of select="$destination"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="linkText">
<xsl:with-param name="destination" select="$destination"/>
</xsl:call-template>
</fo:basic-link>
<xsl:if test="starts-with(@href, '#')">
<xsl:if test="not(@includepage = 'no')">
<xsl:text> (page </xsl:text>
<fo:page-number-citation ref-id="{substring(@href, 2)}"/>
<xsl:text>)</xsl:text>
</xsl:if>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="linkText">
<xsl:param name="execsummary_linking_to_content_not_in_report" select="false()"/>
<xsl:param name="destination"/>
<xsl:choose>
<xsl:when test="starts-with(@href, '#') and not(text())">
<xsl:for-each select="key('rosid', $destination)">
<xsl:choose>
<xsl:when test="$execsummary_linking_to_content_not_in_report = false()">
<xsl:if test="not(local-name() = 'appendix' or local-name() = 'finding')">
<!-- appendix already has 'appendix' as part of its numbering, findings should not be prefixed with the word 'finding' -->
<xsl:value-of select="local-name()"/>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="." mode="number"/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="not(local-name() = 'appendix')">
<!-- appendix already has 'appendix' as part of its numbering, findings should not be prefixed with the word 'finding' -->
<xsl:value-of select="local-name()"/>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="." mode="number"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="* | text()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="a" mode="summarytable">
<xsl:variable name="destination">
<xsl:choose>
<xsl:when test="starts-with(@href, '#')">
<xsl:value-of select="substring(@href, 2)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@href"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<fo:basic-link xsl:use-attribute-sets="link">
<xsl:choose>
<xsl:when test="starts-with(@href, '#')">
<xsl:attribute name="internal-destination">
<xsl:value-of select="$destination"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="external-destination">
<xsl:value-of select="$destination"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="starts-with(@href, '#') and not(text())">
<xsl:for-each select="key('rosid', $destination)">
<xsl:if test="not(local-name() = 'appendix' or local-name() = 'finding')">
<!-- appendix already has 'appendix' as part of its numbering, findings should not be prefixed with the word 'finding' -->
<xsl:value-of select="local-name()"/>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="." mode="number"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="* | text()"/>
</xsl:otherwise>
</xsl:choose>
</fo:basic-link>
</xsl:template>
<xsl:template match="b">
<fo:inline xsl:use-attribute-sets="bold">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
<xsl:template match="i">
<fo:inline xsl:use-attribute-sets="italic">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
<xsl:template match="u">
<fo:inline xsl:use-attribute-sets="underline">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
<xsl:template match="code">
<xsl:choose>
<xsl:when test="ancestor::title">
<fo:inline xsl:use-attribute-sets="code-title">
<xsl:apply-templates/>
</fo:inline>
</xsl:when>
<xsl:when test="ancestor::pre">
<!-- <code> in <pre> is just <pre> -->
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<fo:inline xsl:use-attribute-sets="code">
<xsl:apply-templates/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="sup">
<fo:inline xsl:use-attribute-sets="sup">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
<xsl:template match="sub">
<fo:inline xsl:use-attribute-sets="sub">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
<xsl:template match="fnref">
<xsl:variable name="fnCount" select="count(preceding::fnref) + 1"/>
<fo:footnote>
<fo:inline xsl:use-attribute-sets="sup">
<xsl:value-of select="$fnCount"/>
<xsl:text>&#160;</xsl:text>
</fo:inline>
<fo:footnote-body xsl:use-attribute-sets="TinyFont">
<fo:block>
<fo:inline xsl:use-attribute-sets="sup">
<xsl:value-of select="$fnCount"/>
</fo:inline>
<xsl:apply-templates/>
</fo:block>
</fo:footnote-body>
</fo:footnote>
</xsl:template>
<xsl:template match="bibref">
<xsl:variable name="bibid" select="./@ref"/>
<xsl:variable name="bibCount" select="count(preceding::biblioentry[@id = $bibid]) + 1"/>
<xsl:choose>
<xsl:when test="starts-with(@href, '#') and not(//*[@id = $bibid])">
<fo:inline xsl:use-attribute-sets="errortext">WARNING: BIBLIOGRAPHY ENTRY NOT FOUND
IN DOCUMENT</fo:inline>
</xsl:when>
<xsl:when
test="starts-with(@href, '#') and //*[@id = $bibid][ancestor-or-self::*[@visibility = 'hidden']]">
<fo:inline xsl:use-attribute-sets="errortext">WARNING: BIBLIOGRAPHY ENTRY IS
HIDDEN</fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:basic-link>
<xsl:attribute name="internal-destination">
<xsl:value-of select="$bibid"/>
</xsl:attribute>
<xsl:text>[</xsl:text>
<xsl:for-each select="key('biblioid', $bibid)">
<xsl:apply-templates select="." mode="number"/>
</xsl:for-each>
<xsl:text>]</xsl:text>
</fo:basic-link>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="author">
<xsl:value-of select="firstname"/>
<xsl:text> </xsl:text>
<xsl:value-of select="surname"/>
<xsl:if test="org">
<xsl:if test="firstname | surname">
<xsl:text> (</xsl:text>
</xsl:if>
<xsl:value-of select="org"/>
<xsl:if test="firstname | surname">
<xsl:text>)</xsl:text>
</xsl:if>
</xsl:if>
<xsl:choose>
<xsl:when test="following-sibling::author">, </xsl:when>
<xsl:otherwise>
<xsl:text>. </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="biblioentry/title">
<xsl:choose>
<xsl:when test="../@role = 'book'">
<fo:inline xsl:use-attribute-sets="title.book">
<xsl:apply-templates/>
</fo:inline>
</xsl:when>
<xsl:when test="../@role = 'article'">
<fo:inline xsl:use-attribute-sets="title.article">
<xsl:apply-templates/>
</fo:inline>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="following-sibling::info">
<!-- we're getting something more, place a comma -->
<xsl:text>, </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>. </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="journal">
<fo:inline xsl:use-attribute-sets="journal">
<xsl:apply-templates/>
</fo:inline>
<xsl:choose>
<xsl:when test="following-sibling::info or following-sibling::pubdate">
<!-- we're getting something more, place a comma -->
<xsl:text>, </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>. </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="website">
<fo:inline xsl:use-attribute-sets="website">
<xsl:apply-templates/>
</fo:inline>
<xsl:choose>
<xsl:when test="following-sibling::info or following-sibling::pubdate">
<!-- we're getting something more, place a comma -->
<xsl:text>, </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>. </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="info">
<fo:inline xsl:use-attribute-sets="info">
<xsl:apply-templates/>
</fo:inline>
<xsl:choose>
<xsl:when test="../@role = 'article' and following-sibling::pubdate">
<!-- we're getting something more, place a comma -->
<xsl:text>, </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>. </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="publisher">
<fo:inline xsl:use-attribute-sets="publisher">
<xsl:apply-templates/>
</fo:inline>
<xsl:choose>
<xsl:when test="following-sibling::pubdate">
<!-- we're getting something more, place a comma -->
<xsl:text>, </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>. </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="publisher/name">
<xsl:apply-templates/>
<xsl:if test="following-sibling::location">
<!-- we're getting something more, place a comma -->
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="publisher/location">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="pubdate">
<fo:inline xsl:use-attribute-sets="pubdate">
<xsl:apply-templates/>
</fo:inline>
<xsl:text>. </xsl:text>
</xsl:template>
<xsl:template match="link">
<xsl:apply-templates select="a"/>
<xsl:text>. </xsl:text>
<xsl:if test="accessed">
<xsl:apply-templates select="accessed"/>
</xsl:if>
</xsl:template>
<xsl:template match="accessed">
<xsl:text>Accessed: </xsl:text>
<xsl:apply-templates/>
<xsl:text>.</xsl:text>
</xsl:template>
</xsl:stylesheet>

152
xml/xslt/fo_piecharts.xslt Normal file
View File

@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg" xmlns:my="http://www.radical.sexy"
exclude-result-prefixes="xs my"
version="2.0">
<xsl:import href="piecharts.xslt"/>
<xsl:template name="output_piechart_with_legend">
<xsl:param name="pieTable"/>
<xsl:param name="pieHeight"/>
<xsl:param name="pieTotal"/>
<xsl:param name="no_entries"/>
<xsl:param name="pieHeightHalf"/>
<xsl:param name="x"/>
<xsl:param name="pieAttr"/>
<xsl:for-each select="$pieTable">
<fo:block xsl:use-attribute-sets="p">
<fo:table margin-top="15px" xsl:use-attribute-sets="fwtable">
<!-- need some margin to make space for percentages that can't fit in the pie... -->
<fo:table-column column-width="{$pieHeight + 85}px"/>
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-body>
<fo:table-row keep-together.within-column="always">
<fo:table-cell xsl:use-attribute-sets="td indent_reset">
<fo:block>
<fo:instream-foreign-object
xmlns:svg="http://www.w3.org/2000/svg">
<!--set the display-->
<xsl:call-template name="pie_svg">
<xsl:with-param name="pieHeight" select="$pieHeight"/>
<xsl:with-param name="pieTotal" select="$pieTotal"/>
<xsl:with-param name="no_entries" select="$no_entries"/>
<xsl:with-param name="pieHeightHalf" select="$pieHeightHalf"/>
</xsl:call-template>
</fo:instream-foreign-object>
</fo:block>
</fo:table-cell>
<!-- PIE CHART LEGEND -->
<fo:table-cell>
<fo:block>
<fo:table xsl:use-attribute-sets="pieLegendTable fwtable">
<fo:table-column column-width="22px"/>
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-body>
<xsl:for-each select="$pieTable/pieEntry">
<xsl:variable name="pieEntryLabelClean"
select="translate(pieEntryLabel, '/', '_')"/>
<xsl:variable name="pieEntryLabel">
<xsl:sequence
select="
string-join(for $x in tokenize(pieEntryLabel, '_')
return
my:titleCase($x), ' ')"
/>
</xsl:variable>
<fo:table-row>
<fo:table-cell
xsl:use-attribute-sets="pieLegendTableCell">
<fo:block>
<fo:instream-foreign-object>
<svg:svg height="13" width="13">
<svg:rect stroke="#706f6f" stroke-width="1"
stroke-linejoin="round" height="11" width="11">
<xsl:attribute name="fill">
<xsl:call-template name="selectColor">
<xsl:with-param name="position"
select="position()"/>
<xsl:with-param name="label"
select="pieEntryLabel"/>
</xsl:call-template>
</xsl:attribute>
</svg:rect>
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
</fo:table-cell>
<fo:table-cell
xsl:use-attribute-sets="pieLegendTableCell">
<fo:block>
<xsl:value-of select="$pieEntryLabel"/>
<xsl:text> (</xsl:text>
<!-- for threatLevel legend, link to finding summary table -->
<xsl:choose>
<xsl:when test="$pieAttr = 'threatLevel'">
<fo:basic-link xsl:use-attribute-sets="link">
<xsl:attribute name="internal-destination"
>summaryTableThreatLevel<xsl:value-of
select="$pieEntryLabelClean"/></xsl:attribute>
<xsl:value-of select="pieEntryCount"/>
</fo:basic-link>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="pieEntryCount"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>)</xsl:text>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:for-each>
</xsl:template>
<xsl:template name="pie_percentage_large_slice_style">
<xsl:param name="text_angle"/>
<xsl:param name="middle_x"/>
<xsl:param name="text_line_x"/>
<xsl:param name="percentage"/>
<xsl:param name="part_half"/>
<xsl:param name="middle_y"/>
<xsl:param name="text_line_y"/>
<svg:text xsl:use-attribute-sets="PieFont">
<xsl:call-template name="pie_percentage_large_slice_content">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="middle_x" select="$middle_x"/>
<xsl:with-param name="text_line_x" select="$text_line_x"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
<xsl:with-param name="middle_y" select="$middle_y"/>
<xsl:with-param name="text_line_y" select="$text_line_y"/>
</xsl:call-template>
</svg:text>
</xsl:template>
<xsl:template name="pie_percentage_small_slice_style">
<xsl:param name="text_x_relative_to_line"/>
<xsl:param name="middle_y"/>
<xsl:param name="text_line_y"/>
<xsl:param name="percentage"/>
<svg:text text-anchor="end" xsl:use-attribute-sets="PieFont">
<xsl:call-template name="pie_percentage_small_slice_content">
<xsl:with-param name="text_x_relative_to_line" select="$text_x_relative_to_line"/>
<xsl:with-param name="middle_y" select="$middle_y"/>
<xsl:with-param name="text_line_y" select="$text_line_y"/>
<xsl:with-param name="percentage" select="$percentage"/>
</xsl:call-template>
</svg:text>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="xs"
version="2.0">
<xsl:import href="placeholders.xslt"/>
<xsl:template name="displayErrorText">
<xsl:param name="string" select="'XXXXXXXXXX'"/>
<fo:inline xsl:use-attribute-sets="errortext"><xsl:value-of select="$string"/></fo:inline>
</xsl:template>
<xsl:template name="generate_activities">
<fo:list-block xsl:use-attribute-sets="list">
<xsl:for-each select="/contract/meta/work/activities/activity">
<fo:list-item>
<!-- insert a bullet -->
<fo:list-item-label end-indent="label-end()">
<fo:block>
<fo:inline>&#8226;</fo:inline>
</fo:block>
</fo:list-item-label>
<!-- list text -->
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</xsl:for-each>
</fo:list-block>
</xsl:template>
</xsl:stylesheet>

20
xml/xslt/fo_secrets.xslt Normal file
View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="xs"
version="2.0">
<xsl:import href="secrets.xslt"/>
<xsl:template name="censoredBlock">
<fo:block xsl:use-attribute-sets="censoredblock">
<xsl:call-template name="checkIfLast"/>
<xsl:text>[ CENSORED ]</xsl:text>
</fo:block>
</xsl:template>
<xsl:template name="censoredInline">
<fo:inline xsl:use-attribute-sets="censoredtext">[ CENSORED ]</fo:inline>
</xsl:template>
</xsl:stylesheet>

View File

@@ -2,6 +2,16 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:my="http://www.radical.sexy"
exclude-result-prefixes="xs my" version="2.0">
<!-- color scheme, just change these to change colors throughout the suite -->
<xsl:variable name="c_main">#e2632a</xsl:variable>
<xsl:variable name="c_support_light">#ededed</xsl:variable>
<xsl:variable name="c_support_subtlydarkerlight">#e4e4e4</xsl:variable><!-- used for subtle light border around support_light background -->
<xsl:variable name="c_support_medium">#999999</xsl:variable><!-- used for subtle light border around support_light background -->
<xsl:variable name="c_support_dark">#444444</xsl:variable>
<xsl:variable name="c_main_contrast">white</xsl:variable>
<xsl:variable name="border-color">#444444</xsl:variable>
<!-- auto numbering format (used in various docs) -->
<xsl:param name="AUTO_NUMBERING_FORMAT" select="'1.1.1'"/>
@@ -65,6 +75,121 @@
<xsl:variable name="generic_piecolor_20">mediumturquoise</xsl:variable>
<xsl:variable name="generic_piecolor_21">navy</xsl:variable>
<xsl:variable name="generic_piecolor_other">black</xsl:variable>
<xsl:template name="selectColor">
<xsl:param name="label"/>
<xsl:param name="position"/>
<xsl:choose>
<!-- specific cases -->
<!-- threat level -->
<xsl:when test="$label = 'Extreme'">
<xsl:value-of select="$color_extreme"/>
</xsl:when>
<xsl:when test="$label = 'High'">
<xsl:value-of select="$color_high"/>
</xsl:when>
<xsl:when test="$label = 'Elevated'">
<xsl:value-of select="$color_elevated"/>
</xsl:when>
<xsl:when test="$label = 'Moderate'">
<xsl:value-of select="$color_moderate"/>
</xsl:when>
<xsl:when test="$label = 'Low'">
<xsl:value-of select="$color_low"/>
</xsl:when>
<xsl:when test="$label = 'N/A'">
<xsl:value-of select="$color_na"/>
</xsl:when>
<xsl:when test="$label = 'Unknown'">
<xsl:value-of select="$color_unknown"/>
</xsl:when>
<!-- status -->
<xsl:when test="$label = 'new'">
<xsl:value-of select="$color_new"/>
</xsl:when>
<xsl:when test="$label = 'unresolved'">
<xsl:value-of select="$color_unresolved"/>
</xsl:when>
<xsl:when test="$label = 'not_retested'">
<xsl:value-of select="$color_notretested"/>
</xsl:when>
<xsl:when test="$label = 'resolved'">
<xsl:value-of select="$color_resolved"/>
</xsl:when>
<xsl:otherwise>
<!-- generic pie chart -->
<xsl:choose>
<!-- Going with shades of green, yellow and blue/purple in all cases here so as not to imply severity levels -->
<xsl:when test="$position = 1">
<xsl:value-of select="$generic_piecolor_1"/>
</xsl:when>
<xsl:when test="$position = 2">
<xsl:value-of select="$generic_piecolor_2"/>
</xsl:when>
<xsl:when test="$position = 3">
<xsl:value-of select="$generic_piecolor_3"/>
</xsl:when>
<xsl:when test="$position = 4">
<xsl:value-of select="$generic_piecolor_4"/>
</xsl:when>
<xsl:when test="$position = 5">
<xsl:value-of select="$generic_piecolor_5"/>
</xsl:when>
<xsl:when test="$position = 6">
<xsl:value-of select="$generic_piecolor_6"/>
</xsl:when>
<xsl:when test="$position = 7">
<xsl:value-of select="$generic_piecolor_7"/>
</xsl:when>
<xsl:when test="$position = 8">
<xsl:value-of select="$generic_piecolor_8"/>
</xsl:when>
<xsl:when test="$position = 9">
<xsl:value-of select="$generic_piecolor_9"/>
</xsl:when>
<xsl:when test="$position = 10">
<xsl:value-of select="$generic_piecolor_10"/>
</xsl:when>
<xsl:when test="$position = 11">
<xsl:value-of select="$generic_piecolor_11"/>
</xsl:when>
<xsl:when test="$position = 12">
<xsl:value-of select="$generic_piecolor_12"/>
</xsl:when>
<xsl:when test="$position = 13">
<xsl:value-of select="$generic_piecolor_13"/>
</xsl:when>
<xsl:when test="$position = 14">
<xsl:value-of select="$generic_piecolor_14"/>
</xsl:when>
<xsl:when test="$position = 15">
<xsl:value-of select="$generic_piecolor_15"/>
</xsl:when>
<xsl:when test="$position = 16">
<xsl:value-of select="$generic_piecolor_16"/>
</xsl:when>
<xsl:when test="$position = 17">
<xsl:value-of select="$generic_piecolor_17"/>
</xsl:when>
<xsl:when test="$position = 18">
<xsl:value-of select="$generic_piecolor_18"/>
</xsl:when>
<xsl:when test="$position = 19">
<xsl:value-of select="$generic_piecolor_19"/>
</xsl:when>
<xsl:when test="$position = 20">
<xsl:value-of select="$generic_piecolor_20"/>
</xsl:when>
<xsl:when test="$position = 21">
<xsl:value-of select="$generic_piecolor_21"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$generic_piecolor_other"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- document version number (mostly for report) -->
<xsl:variable name="latestVersionNumber">
@@ -114,6 +239,88 @@
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Finding stuff -->
<xsl:variable name="unsortedFindingSummaryTable">
<xsl:for-each-group select="//finding" group-by="@threatLevel">
<xsl:for-each select="current-group()">
<findingEntry>
<xsl:attribute name="Ref">
<xsl:value-of select="@Ref"/>
</xsl:attribute>
<xsl:attribute name="status">
<xsl:value-of select="@status"/>
</xsl:attribute>
<xsl:attribute name="findingId">
<xsl:value-of select="@id"/>
</xsl:attribute>
<findingNumber>
<xsl:apply-templates select="." mode="number"/>
</findingNumber>
<findingType>
<xsl:value-of select="@type"/>
</findingType>
<findingDescription>
<xsl:choose>
<xsl:when test="description_summary">
<xsl:value-of select="description_summary"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="description" mode="summarytable"/>
</xsl:otherwise>
</xsl:choose>
</findingDescription>
<findingThreatLevel>
<xsl:value-of select="current-grouping-key()"/>
</findingThreatLevel>
</findingEntry>
</xsl:for-each>
</xsl:for-each-group>
</xsl:variable>
<xsl:variable name="findingSummaryTable">
<xsl:for-each select="$unsortedFindingSummaryTable/findingEntry">
<xsl:sort data-type="number" order="descending"
select="
(number(findingThreatLevel = 'Extreme') * 10)
+ (number(findingThreatLevel = 'High') * 9)
+ (number(findingThreatLevel = 'Elevated') * 8)
+ (number(findingThreatLevel = 'Moderate') * 7)
+ (number(findingThreatLevel = 'Low') * 6)
+ (number(findingThreatLevel = 'Unknown') * 3)
+ (number(findingThreatLevel = 'N/A') * 1)"/>
<xsl:variable name="findingThreatLevelClean"
select="translate(findingThreatLevel, '/', '_')"/>
<findingEntry>
<xsl:attribute name="Ref">
<xsl:value-of select="@Ref"/>
</xsl:attribute>
<xsl:attribute name="status">
<xsl:value-of select="@status"/>
</xsl:attribute>
<xsl:attribute name="findingId">
<xsl:value-of select="@findingId"/>
</xsl:attribute>
<!-- add an id for the first entry of each type so that we can link to it -->
<xsl:if
test="not(preceding-sibling::findingEntry/findingThreatLevel = findingThreatLevel)">
<xsl:attribute name="id">summaryTableThreatLevel<xsl:value-of
select="$findingThreatLevelClean"/></xsl:attribute>
</xsl:if>
<findingNumber>
<xsl:value-of select="findingNumber"/>
</findingNumber>
<findingType>
<xsl:value-of select="findingType"/>
</findingType>
<findingDescription>
<xsl:value-of select="findingDescription"/>
</findingDescription>
<findingThreatLevel>
<xsl:value-of select="findingThreatLevel"/>
</findingThreatLevel>
</findingEntry>
</xsl:for-each>
</xsl:variable>
<!-- Money stuff -->
<xsl:variable name="eur" select="'eur'"/>
@@ -195,4 +402,124 @@
</xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:function name="my:calculatePeriod">
<xsl:param name="enddate"/>
<xsl:param name="startdate"/>
<xsl:variable name="startYear" as="xs:integer" select="year-from-date($startdate)"/>
<xsl:variable name="startMonth" as="xs:integer" select="month-from-date($startdate)"/>
<xsl:variable name="startDay" as="xs:integer" select="day-from-date($startdate)"/>
<xsl:variable name="endYear" as="xs:integer" select="year-from-date($enddate)"/>
<xsl:variable name="endMonth" as="xs:integer" select="month-from-date($enddate)"/>
<xsl:variable name="endDay" as="xs:integer" select="day-from-date($enddate)"/>
<xsl:variable name="startMonthNumberOfDays">
<xsl:choose>
<xsl:when test="xs:string($startMonth) = '1'">31</xsl:when>
<xsl:when test="xs:string($startMonth) = '2'">
<!-- I hate february -->
<xsl:choose>
<xsl:when test="$startYear mod 4 != 0">28</xsl:when>
<xsl:when test="$startYear mod 100 != 0">29</xsl:when>
<xsl:when test="$startYear mod 400 != 0">28</xsl:when>
<xsl:otherwise>29</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="xs:string($startMonth) = '3'">31</xsl:when>
<xsl:when test="xs:string($startMonth) = '4'">30</xsl:when>
<xsl:when test="xs:string($startMonth) = '5'">31</xsl:when>
<xsl:when test="xs:string($startMonth) = '6'">30</xsl:when>
<xsl:when test="xs:string($startMonth) = '7'">31</xsl:when>
<xsl:when test="xs:string($startMonth) = '8'">31</xsl:when>
<xsl:when test="xs:string($startMonth) = '9'">30</xsl:when>
<xsl:when test="xs:string($startMonth) = '10'">31</xsl:when>
<xsl:when test="xs:string($startMonth) = '11'">30</xsl:when>
<xsl:when test="xs:string($startMonth) = '12'">31</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="numYears">
<xsl:choose>
<xsl:when test="$endMonth > $startMonth">
<xsl:sequence select="$endYear - $startYear"/>
</xsl:when>
<xsl:when test="$endMonth &lt; $startMonth">
<xsl:sequence select="$endYear - $startYear - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$endDay >= $startDay">
<xsl:sequence select="$endYear - $startYear"/>
</xsl:when>
<xsl:otherwise>
<!-- $endDay &lt; $startDay -->
<xsl:sequence select="$endYear - $startYear - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="numMonths">
<xsl:choose>
<xsl:when test="$endDay &lt; $startDay">
<xsl:sequence select="$endMonth - $startMonth - 1"/>
</xsl:when>
<xsl:otherwise>
<!-- $endDay >= $startDay -->
<xsl:sequence select="$endMonth - $startMonth"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="numDays">
<!--<xsl:choose>
<xsl:when test="$numMonths &lt; 1 and $numYears &lt; 1">
<!-\- only displaying days if contract is for less than a month -\->
<xsl:sequence select="($enddate - $startdate) div xs:dayTimeDuration('P1D')"/>
</xsl:when>
<xsl:otherwise>
<!-\- if contract is longer than a month, don't count days -\->
<xsl:sequence select="0"/>
</xsl:otherwise>
</xsl:choose>-->
<xsl:choose>
<xsl:when test="$endDay - $startDay &lt; 0">
<xsl:value-of select="$startMonthNumberOfDays - $startDay + $endDay"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$endDay - $startDay"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$numYears > 0">
<xsl:sequence select="$numYears"/>
<xsl:text>year</xsl:text>
<xsl:if test="$numYears > 1">
<xsl:text>s</xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when
test="($numMonths > 0 and $numDays = 0) or ($numMonths = 0 and $numDays > 0)">
<xsl:text> and</xsl:text>
</xsl:when>
<xsl:when test="$numMonths > 0 and $numDays > 0">
<xsl:text>,</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:if>
<xsl:if test="$numMonths > 0">
<xsl:sequence select="$numMonths"/>
<xsl:text>month</xsl:text>
<xsl:if test="$numMonths > 1">
<xsl:text>s</xsl:text>
</xsl:if>
<xsl:if test="$numDays > 0">
<xsl:text> and</xsl:text>
</xsl:if>
</xsl:if>
<xsl:if test="$numDays > 0">
<xsl:sequence select="$numDays"/>
<xsl:text>day</xsl:text>
<xsl:if test="$numDays > 1">
<xsl:text>s</xsl:text>
</xsl:if>
</xsl:if>
</xsl:function>
</xsl:stylesheet>

View File

@@ -0,0 +1,970 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:my="http://www.radical.sexy" xmlns:svg="http://www.w3.org/2000/svg"
exclude-result-prefixes="xs my" version="2.0">
<xsl:import href="html_inline.xslt"/>
<xsl:import href="html_piecharts.xslt"/>
<xsl:import href="html_placeholders.xslt"/>
<xsl:import href="html_secrets.xslt"/>
<xsl:import href="localisation.xslt"/>
<xsl:import href="css.xslt"/>
<xsl:include href="functions_params_vars.xslt"/>
<!-- numbered titles or not? -->
<xsl:param name="NUMBERING" select="true()"/>
<xsl:output method="xml" indent="no"/>
<!-- ROOT -->
<xsl:template match="/">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="description" content="{//meta/title}"/>
<meta name="author" content="{//meta/company/full_name}"/>
<style>
<xsl:call-template name="css"/>
</style>
<title>
<xsl:sequence
select="
string-join(for $x in tokenize(normalize-space(//meta/title), ' ')
return
my:titleCase($x), ' ')"
/>
</title>
</head>
<body>
<xsl:apply-templates select="/*/meta" mode="frontmatter"/>
<xsl:apply-templates select="/*/generate_index"/>
<div class="container contents">
<xsl:for-each select="/*/section | /*/appendix">
<xsl:apply-templates select="."/>
</xsl:for-each>
</div>
<hr class="endOfDoc"/>
</body>
</html>
</xsl:template>
<xsl:template match="meta" mode="frontmatter">
<div class="section">
<div class="container">
<div class="row">
<div class="offset-by-two columns">
<img src="../graphics/logo.png" class="logo"/>
</div>
</div>
<div class="row">
<div class="u-full-width">
<h1>
<xsl:sequence
select="
string-join(for $x in tokenize(normalize-space(title), ' ')
return
my:titleCase($x), ' ')"
/>
</h1>
<div class="title-client">
<xsl:value-of select="//client/full_name"/>
</div>
<xsl:if test="normalize-space(//meta/subtitle) or //meta/subtitle/*">
<div class="title-sub">
<xsl:apply-templates select="subtitle"/>
</div>
</xsl:if>
</div>
</div>
</div>
</div>
<div class="section">
<xsl:call-template name="DocProperties"/>
</div>
<div class="section">
<xsl:call-template name="Contact"/>
</div>
<div class="section">
<xsl:call-template name="VersionControl"/>
</div>
</xsl:template>
<xsl:template name="VersionNumber">
<!-- COMMON WITH FO -->
<xsl:param name="number" select="@number"/>
<xsl:choose>
<!-- if value is auto, do some autonumbering magic -->
<xsl:when test="string(@number) = 'auto'"> 0.<xsl:number count="version"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
<!-- this is really unrobust :D - todo: follow fixed numbering if provided -->
</xsl:when>
<xsl:otherwise>
<!-- just plop down the value -->
<!-- todo: guard numbering format in schema -->
<xsl:value-of select="@number"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="DocProperties">
<xsl:variable name="authors"
select="version_history/version/v_author[not(. = ../preceding::version/v_author)]"/>
<div class="container">
<h4>Document Properties</h4>
<xsl:if test="not(/generic_document)">
<div class="row">
<div class="two columns">
<strong>Client</strong>
</div>
<div class="ten columns">
<xsl:value-of select="//client/full_name"/>
</div>
</div>
</xsl:if>
<div class="row">
<div class="two columns">
<strong>Title</strong>
</div>
<div class="ten columns">
<xsl:sequence
select="
concat(upper-case(substring(title, 1, 1)),
substring(title, 2),
' '[not(last())]
)
"
/>
</div>
</div>
<xsl:if test="not(/generic_document)">
<div class="row">
<div class="two columns">
<strong>Target<xsl:if test="targets/target[2]">s</xsl:if></strong>
</div>
<div class="ten columns">
<xsl:choose>
<xsl:when test="targets/target[2]">
<!-- more than one target -->
<ul>
<xsl:for-each select="targets/target">
<li>
<xsl:value-of select="."/>
</li>
</xsl:for-each>
</ul>
<!-- end list -->
</xsl:when>
<xsl:otherwise>
<!-- just the one -->
<xsl:value-of select="targets/target"/>
</xsl:otherwise>
</xsl:choose>
</div>
</div>
</xsl:if>
<div class="row">
<div class="two columns">
<strong>Version</strong>
</div>
<div class="ten columns">
<xsl:value-of select="$latestVersionNumber"/>
</div>
</div>
<xsl:if test="not(/generic_document)">
<div class="row">
<div class="two columns">
<strong>Pentester<xsl:if test="collaborators/pentesters/pentester[2]"
>s</xsl:if></strong>
</div>
<div class="ten columns">
<xsl:for-each select="collaborators/pentesters/pentester">
<xsl:value-of select="name"/>
<xsl:if test="following-sibling::pentester">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
</div>
</div>
</xsl:if>
<div class="row">
<div class="two columns">
<strong>Author<xsl:if test="$authors[2]">s</xsl:if></strong>
</div>
<div class="ten columns">
<xsl:for-each select="$authors">
<xsl:if test="preceding::v_author">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:value-of select="."/>
</xsl:for-each>
</div>
</div>
<div class="row">
<div class="two columns">
<strong>Reviewed by</strong>
</div>
<div class="ten columns">
<xsl:for-each select="collaborators/reviewers/reviewer">
<div>
<xsl:value-of select="."/>
</div>
</xsl:for-each>
</div>
</div>
<div class="row">
<div class="two columns">
<strong>Approved by</strong>
</div>
<div class="ten columns">
<xsl:value-of select="collaborators/approver/name"/>
</div>
</div>
</div>
</xsl:template>
<xsl:template name="VersionControl">
<xsl:variable name="versions" select="version_history/version"/>
<div class="container">
<h4>Version control</h4>
<table class="borders u-full-width">
<thead>
<tr>
<th>Version </th>
<th>Date </th>
<th>Author </th>
<th>Description </th>
</tr>
</thead>
<tbody>
<xsl:for-each select="$versions">
<!-- todo: guard date format in schema -->
<xsl:sort select="xs:dateTime(@date)" order="ascending"/>
<tr>
<xsl:if test="position() mod 2 != 0">
<xsl:attribute name="class">light-grey</xsl:attribute>
</xsl:if>
<td>
<xsl:call-template name="VersionNumber">
<xsl:with-param name="number" select="@number"/>
</xsl:call-template>
</td>
<td>
<xsl:value-of
select="format-dateTime(@date, '[MNn] [D1o], [Y]', 'en', (), ())"
/>
</td>
<td>
<xsl:for-each select="v_author">
<xsl:value-of select="."/>
<xsl:if test="following-sibling::v_author">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
</td>
<td>
<xsl:value-of select="v_description"/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</div>
</xsl:template>
<xsl:template name="Contact">
<div class="container">
<h4>Contact</h4>
<p>For more information about this document and its contents please contact
<xsl:value-of select="company/full_name"/>
<xsl:if test="not(company/full_name[ends-with(., '.')])"
><xsl:text>.</xsl:text></xsl:if></p>
<div class="row">
<div class="two columns">
<strong>Name</strong>
</div>
<div class="ten columns">
<xsl:value-of select="company/poc1"/>
</div>
</div>
<div class="row">
<div class="two columns">
<strong>Address</strong>
</div>
<div class="ten columns">
<div>
<xsl:apply-templates select="company/address"/>
</div>
<div>
<xsl:value-of select="company/postal_code"/>&#160;<xsl:value-of
select="company/city"/>
</div>
<div>
<xsl:value-of select="company/country"/>
</div>
</div>
</div>
<div class="row">
<div class="two columns">
<strong>Phone</strong>
</div>
<div class="ten columns">
<xsl:value-of select="company/phone"/>
</div>
</div>
<div class="row">
<div class="two columns">
<strong>Email</strong>
</div>
<div class="ten columns">
<xsl:value-of select="company/email"/>
</div>
</div>
<div class="coc">
<xsl:value-of select="company/full_name"/> is registered at the trade register of
the Dutch chamber of commerce under number <xsl:value-of select="company/coc"/>.
</div>
</div>
</xsl:template>
<xsl:template match="generate_index">
<div class="section">
<div class="container">
<h2>Table of Contents</h2>
<xsl:apply-templates select="/" mode="toc"/>
</div>
</div>
</xsl:template>
<xsl:template match="meta | *[ancestor-or-self::*/@visibility = 'hidden']" mode="toc"/>
<!-- meta, hidden things and children of hidden things not indexed -->
<xsl:template
match="section[not(@visibility = 'hidden')] | finding | appendix[not(@visibility = 'hidden')] | non-finding"
mode="toc">
<xsl:call-template name="ToC"/>
</xsl:template>
<xsl:template name="ToC">
<div class="row">
<div class="one column">
<a>
<xsl:if test="parent::pentest_report or parent::generic_document">
<!-- We're in a top-level section, so add some extra styling -->
<xsl:call-template name="topLevelToCEntry"/>
</xsl:if>
<xsl:call-template name="getHref"/>
<xsl:call-template name="tocContent_Numbering"/>
</a>
</div>
<div class="eleven columns">
<a>
<xsl:if test="parent::pentest_report or parent::generic_document">
<!-- We're in a top-level section, so add some extra styling -->
<xsl:call-template name="topLevelToCEntry"/>
</xsl:if>
<xsl:call-template name="getHref"/>
<xsl:call-template name="tocContent_Title"/>
</a>
</div>
</div>
<xsl:apply-templates
select="section[not(@visibility = 'hidden')][not(../@visibility = 'hidden')] | finding[not(../@visibility = 'hidden')] | non-finding[not(../@visibility = 'hidden')]"
mode="toc"/>
</xsl:template>
<xsl:template name="getHref">
<xsl:attribute name="href">
<xsl:value-of select="concat('#', @id)"/>
</xsl:attribute>
</xsl:template>
<xsl:template name="topLevelToCEntry">
<xsl:attribute name="class">topLevelToCEntry</xsl:attribute>
</xsl:template>
<xsl:template name="tocContent_Title">
<xsl:apply-templates select="title" mode="toc"/>
</xsl:template>
<xsl:template match="title" mode="toc">
<xsl:call-template name="prependId"/>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="finding" mode="number">
<!-- Output finding display number (context is finding) -->
<xsl:variable name="sectionNumber">
<xsl:if test="/pentest_report/@findingNumberingBase = 'Section'">
<xsl:value-of
select="count(ancestor::section[last()]/preceding-sibling::section) + 1"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="findingNumber" select="count(preceding::finding) + 1"/>
<xsl:variable name="numFormat">
<xsl:choose>
<xsl:when test="/pentest_report/@findingNumberingBase = 'Section'">00</xsl:when>
<xsl:otherwise>000</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of
select="concat(ancestor::*[@findingCode][1]/@findingCode, '-', $sectionNumber, string(format-number($findingNumber, $numFormat)))"
/>
</xsl:template>
<xsl:template match="non-finding" mode="number">
<!-- Output finding display number (context is finding) -->
<xsl:variable name="nonFindingNumber" select="count(preceding::non-finding) + 1"/>
<xsl:variable name="numFormat" select="'000'"/>
<xsl:value-of select="concat('NF-', string(format-number($nonFindingNumber, $numFormat)))"/>
</xsl:template>
<xsl:template
match="section[not(@visibility = 'hidden')] | appendix[not(@visibility = 'hidden')]"
mode="number">
<xsl:choose>
<xsl:when test="self::appendix"> Appendix&#160;<xsl:number
count="appendix[not(@visibility = 'hidden')]" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>
</xsl:when>
<xsl:when test="ancestor::appendix"> App&#160;<xsl:number count="appendix"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>.<xsl:number
count="section[ancestor::appendix][not(@visibility = 'hidden')]"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</xsl:when>
<xsl:otherwise>
<xsl:number count="section[not(@visibility = 'hidden')] | finding | non-finding"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="prependId">
<!-- COMMON WITH FO -->
<xsl:choose>
<xsl:when test="parent::finding or parent::non-finding">
<!-- prepend finding id (XXX-NNN) -->
<xsl:apply-templates select=".." mode="number"/>
<xsl:text> &#8212; </xsl:text>
</xsl:when>
<xsl:when test="parent::non-finding">
<!-- prepend non-finding id (NF-NNN) -->
<xsl:apply-templates select=".." mode="number"/>
<xsl:text> &#8212; </xsl:text>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="tocContent_Numbering">
<xsl:choose>
<xsl:when test="self::appendix[not(@visibility = 'hidden')]">
<span> Appendix&#160;<xsl:number count="appendix[not(@visibility = 'hidden')]"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/></span>
</xsl:when>
<xsl:when test="ancestor::appendix[not(@visibility = 'hidden')]">
<span> App&#160;<xsl:number count="appendix[not(@visibility = 'hidden')]"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>.<xsl:number
count="section[not(@visibility = 'hidden')][ancestor::appendix[not(@visibility = 'hidden')]]"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</span>
</xsl:when>
<xsl:otherwise>
<span>
<xsl:number count="section[not(@visibility = 'hidden')] | finding | non-finding"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="section | appendix | finding | non-finding | annex">
<xsl:if test="not(@visibility = 'hidden')">
<div class="section">
<xsl:apply-templates select="@* | node()"/>
</div>
</xsl:if>
</xsl:template>
<xsl:template match="title[not(parent::biblioentry)]">
<xsl:variable name="LEVEL">
<xsl:value-of select="count(ancestor::*)"/>
</xsl:variable>
<xsl:element name="{concat('h', $LEVEL)}">
<xsl:call-template name="titleLogic"/>
</xsl:element>
<xsl:if test="parent::finding">
<!-- display meta box after title -->
<xsl:apply-templates select=".." mode="meta"/>
</xsl:if>
</xsl:template>
<xsl:template name="titleLogic">
<xsl:param name="AUTO_NUMBERING_FORMAT" tunnel="yes"/>
<!-- Give somewhat larger separation to Appendix because of the long string; if everything gets 3cm it looks horrible -->
<xsl:choose>
<xsl:when test="$NUMBERING">
<span class="title">
<xsl:choose>
<xsl:when test="self::title[parent::appendix]">
<span class="titlenumber"> Appendix&#160;<xsl:number
count="appendix[not(@visibility = 'hidden')]" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>
</span>
</xsl:when>
<xsl:when test="ancestor::appendix and not(self::title[parent::appendix])">
<span class="titlenumber"> App&#160;<xsl:number
count="appendix[not(@visibility = 'hidden')]" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>.<xsl:number
count="section[ancestor::appendix][not(@visibility = 'hidden')]"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</span>
</xsl:when>
<xsl:otherwise>
<span class="titlenumber">
<xsl:number
count="section[not(@visibility = 'hidden')] | finding | non-finding"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</span>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&#160;</xsl:text>
<xsl:call-template name="titleContent"/>
</span>
</xsl:when>
<xsl:otherwise>
<span class="title">
<xsl:call-template name="titleContent"/>
</span>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="titleContent">
<xsl:param name="client" tunnel="yes"/>
<xsl:variable name="titleText_raw">
<xsl:apply-templates/>
</xsl:variable>
<xsl:variable name="titleText">
<xsl:sequence
select="
string-join(for $x in tokenize(normalize-space($titleText_raw), ' ')
return
my:titleCase($x), ' ')"
/>
</xsl:variable>
<xsl:if test="parent::finding">
<xsl:call-template name="prependId"/>
</xsl:if>
<xsl:apply-templates/>
</xsl:template>
<!-- hide any attributes that are not explicitly handled -->
<xsl:template match="@*"/>
<xsl:template match="@id | @src | @alt">
<!-- copy these! -->
<xsl:copy/>
</xsl:template>
<xsl:template match="company/address">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="finding" mode="meta">
<xsl:variable name="status" select="@status"/>
<xsl:variable name="prettyStatus">
<xsl:sequence
select="
string-join(for $x in tokenize($status, '_')
return
my:titleCase($x), ' ')"
/>
</xsl:variable>
<div class="findingMetaBox">
<xsl:attribute name="style">
<xsl:text>border-top: 4px solid </xsl:text>
<xsl:call-template name="selectColor">
<xsl:with-param name="label" select="@threatLevel"/>
</xsl:call-template>
<xsl:text>;</xsl:text>
</xsl:attribute>
<div class="row">
<div class="six columns">
<span class="findingMetaBoxLabel">Vulnerability ID: </span>
<xsl:apply-templates select="." mode="number"/>
</div>
<xsl:if test="@status">
<div class="six columns">
<span class="findingMetaBoxLabel">Retest status: </span>
<xsl:choose>
<xsl:when test="@status = 'new' or @status = 'unresolved'">
<span class="status-new">
<xsl:value-of select="$prettyStatus"/>
</span>
</xsl:when>
<xsl:when test="@status = 'not_retested'">
<span class="status-not_retested">
<xsl:value-of select="$prettyStatus"/>
</span>
</xsl:when>
<xsl:when test="@status = 'resolved'">
<span class="status-resolved">
<xsl:value-of select="$prettyStatus"/>
</span>
</xsl:when>
</xsl:choose>
</div>
</xsl:if>
</div>
<div class="row">
<div>
<span class="findingMetaBoxLabel">Vulnerability type: </span>
<xsl:value-of select="@type"/>
</div>
</div>
<div class="row">
<div>
<span class="findingMetaBoxLabel">Threat level: </span>
<xsl:value-of select="@threatLevel"/>
</div>
</div>
</div>
</xsl:template>
<!-- ignore summary-table-only elements in the findings -->
<xsl:template match="description_summary | recommendation_summary"/>
<xsl:template match="description">
<h5 class="title-findingsection">Description:</h5>
<div class="finding-content">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="description" mode="summarytable">
<xsl:if test="img | table">
<xsl:message>WARNING: description containing img or table may not look very good in the
finding summary table. Consider using a description_summary element
instead.</xsl:message>
</xsl:if>
<xsl:apply-templates mode="summarytable"/>
</xsl:template>
<xsl:template match="technicaldescription">
<h5 class="title-findingsection">Technical description:</h5>
<div class="finding-content">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="impact">
<h5 class="title-findingsection">Impact:</h5>
<div class="finding-content">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="recommendation">
<h5 class="title-findingsection">Recommendation:</h5>
<div class="finding-content">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="recommendation" mode="summarytable">
<xsl:if test="img | table">
<xsl:message>WARNING: recommendation containing img or table may not look very good in
the finding summary table. Consider using a recommendation_summary element
instead.</xsl:message>
</xsl:if>
<xsl:apply-templates mode="summarytable"/>
</xsl:template>
<xsl:template match="recommendation_summary" mode="summarytable">
<xsl:apply-templates mode="summarytable"/>
</xsl:template>
<xsl:template match="description_summary" mode="summarytable">
<xsl:apply-templates mode="summarytable"/>
</xsl:template>
<xsl:template match="generate_targets">
<xsl:call-template name="generate_targets_html"/>
</xsl:template>
<xsl:template name="generate_targets_html">
<xsl:param name="Ref" select="@Ref"/>
<ul class="list">
<xsl:for-each
select="/*/meta/targets/target[@Ref = $Ref] | /*/meta/targets/target[not(@Ref)]">
<li class="li">
<xsl:apply-templates/>
</li>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="generate_teammembers">
<xsl:call-template name="generate_teammembers_fo"/>
</xsl:template>
<xsl:template name="generate_teammembers_fo">
<ul class="list" provisional-distance-between-starts="0.75cm"
provisional-label-separation="2.5mm" space-after="12pt" start-indent="1cm">
<xsl:for-each select="//activityinfo//team/member">
<li>
<span class="bold"><xsl:apply-templates select="name"/>: </span>
<xsl:apply-templates select="expertise"/>
</li>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="generate_findings">
<xsl:variable name="Ref" select="@Ref"/>
<xsl:variable name="statusSequence" as="item()*">
<xsl:for-each select="@status">
<xsl:for-each select="tokenize(., ' ')">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:for-each>
</xsl:variable>
<table class="fwtable table borders u-full-width">
<colgroup>
<col style="width:10%"/>
<col style="width:15%"/>
<col style="width:65%"/>
<col style="width:10%"/>
</colgroup>
<thead>
<tr>
<th>
<div>ID</div>
</th>
<th>
<div>Type</div>
</th>
<th>
<div>Description</div>
</th>
<th>
<div>Threat level</div>
</th>
</tr>
</thead>
<tbody>
<xsl:choose>
<xsl:when test="@status and @Ref">
<!-- Only generate a table for findings in the section with this status AND this Ref -->
<xsl:for-each
select="$findingSummaryTable/findingEntry[@status = $statusSequence][ancestor::*[@id = $Ref]]">
<xsl:call-template name="findingsSummaryContent"/>
</xsl:for-each>
</xsl:when>
<xsl:when test="@status and not(@Ref)">
<!-- Only generate a table for findings in the section with this status -->
<xsl:for-each
select="$findingSummaryTable/findingEntry[@status = $statusSequence]">
<xsl:call-template name="findingsSummaryContent"/>
</xsl:for-each>
</xsl:when>
<xsl:when test="@Ref and not(@status)">
<!-- Only generate a table for findings in the section with this Ref -->
<xsl:for-each
select="$findingSummaryTable/findingEntry[ancestor::*[@id = $Ref]]">
<xsl:call-template name="findingsSummaryContent"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="$findingSummaryTable/findingEntry">
<xsl:call-template name="findingsSummaryContent"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</tbody>
</table>
</xsl:template>
<xsl:template name="findingsSummaryContent">
<tr class="TableFont">
<!--<xsl:if test="position() mod 2 != 0">
<xsl:attribute name="background-color">#ededed</xsl:attribute>
</xsl:if>-->
<td>
<div>
<!-- attach id to first finding of each threatLevel so pie charts can link to it -->
<xsl:if test="@id">
<xsl:attribute name="id">
<xsl:value-of select="@id"/>
</xsl:attribute>
</xsl:if>
<a class="link">
<xsl:attribute name="href">
<xsl:text>#</xsl:text>
<xsl:value-of select="@findingId"/>
</xsl:attribute>
<xsl:value-of select="findingNumber"/>
</a>
</div>
</td>
<td>
<div>
<xsl:value-of select="findingType"/>
</div>
</td>
<td>
<div>
<xsl:value-of select="findingDescription"/>
</div>
</td>
<td>
<div>
<xsl:value-of select="findingThreatLevel"/>
</div>
</td>
</tr>
</xsl:template>
<xsl:template match="generate_recommendations">
<xsl:variable name="Ref" select="@Ref"/>
<xsl:variable name="statusSequence" as="item()*">
<xsl:for-each select="@status">
<xsl:for-each select="tokenize(., ' ')">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:for-each>
</xsl:variable>
<table class="fwtable table borders u-full-width">
<colgroup>
<col style="width:10%"/>
<col style="width:15%"/>
<col style="width:75%"/>
</colgroup>
<thead>
<tr>
<th>
<div>ID</div>
</th>
<th>
<div>Type</div>
</th>
<th>
<div>Recommendation</div>
</th>
</tr>
</thead>
<tbody>
<xsl:choose>
<xsl:when test="@status and @Ref">
<!-- Only generate a table for findings in the section with this status AND this Ref -->
<xsl:for-each
select="/pentest_report/descendant::finding[@status = $statusSequence][ancestor::*[@id = $Ref]]">
<xsl:call-template name="recommendationsSummaryContent"/>
</xsl:for-each>
</xsl:when>
<xsl:when test="@status and not(@Ref)">
<!-- Only generate a table for findings in the section with this status -->
<xsl:for-each
select="/pentest_report/descendant::finding[@status = $statusSequence]">
<xsl:call-template name="recommendationsSummaryContent"/>
</xsl:for-each>
</xsl:when>
<xsl:when test="@Ref and not(@status)">
<!-- Only generate a table for findings in the section with this Ref -->
<xsl:for-each
select="/pentest_report/descendant::finding[ancestor::*[@id = $Ref]]">
<xsl:call-template name="recommendationsSummaryContent"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="/pentest_report/descendant::finding">
<xsl:call-template name="recommendationsSummaryContent"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</tbody>
</table>
</xsl:template>
<xsl:template name="recommendationsSummaryContent">
<tr class="TableFont">
<!--<xsl:if test="position() mod 2 != 0">
<xsl:attribute name="background-color">#ededed</xsl:attribute>
</xsl:if>-->
<td>
<div>
<a class="link">
<xsl:attribute name="href">
<xsl:text>#</xsl:text>
<xsl:value-of select="@id"/>
</xsl:attribute>
<xsl:apply-templates select="." mode="number"/>
</a>
</div>
</td>
<td>
<div>
<xsl:value-of select="@type"/>
</div>
</td>
<td>
<div>
<xsl:choose>
<xsl:when test="recommendation_summary">
<xsl:apply-templates select="recommendation_summary" mode="summarytable"
/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="recommendation" mode="summarytable"/>
</xsl:otherwise>
</xsl:choose>
</div>
</td>
</tr>
</xsl:template>
<xsl:template match="generate_testteam">
<xsl:for-each select="/pentest_report/meta/collaborators/pentesters/pentester">
<xsl:if test="not(./name = /pentest_report/meta/collaborators/approver/name)">
<div class="row">
<div class="two columns">
<xsl:apply-templates select="name"/>
</div>
<div class="ten columns">
<xsl:apply-templates select="bio"/>
</div>
</div>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="/pentest_report/meta/collaborators/approver">
<div class="row">
<div class="two columns">
<xsl:apply-templates select="name"/>
</div>
<div class="ten columns">
<xsl:apply-templates select="bio"/>
</div>
</div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

View File

@@ -19,7 +19,7 @@
<xsl:import href="generic.xslt"/>
<xsl:import href="numbering.xslt"/>
<xsl:import href="localisation.xslt"/>
<xsl:import href="placeholders.xslt"/>
<xsl:import href="fo_placeholders.xslt"/>
<xsl:import href="waiver.xslt"/>
<xsl:include href="functions_params_vars.xslt"/>
<xsl:include href="styles_off.xslt"/>

View File

@@ -8,7 +8,7 @@
<xsl:import href="block.xslt"/>
<xsl:import href="inline.xslt"/>
<xsl:import href="auto.xslt"/>
<xsl:import href="placeholders.xslt"/>
<xsl:import href="fo_placeholders.xslt"/>
<xsl:import href="structure.xslt"/>
<xsl:import href="lists.xslt"/>
<xsl:import href="generic.xslt"/>

View File

@@ -11,16 +11,16 @@
<xsl:import href="block.xslt"/>
<xsl:import href="findings.xslt"/>
<xsl:import href="auto.xslt"/>
<xsl:import href="piecharts.xslt"/>
<xsl:import href="fo_piecharts.xslt"/>
<xsl:import href="table.xslt"/>
<xsl:import href="lists.xslt"/>
<xsl:import href="inline.xslt"/>
<xsl:import href="fo_inline.xslt"/>
<xsl:import href="graphics.xslt"/>
<xsl:import href="generic.xslt"/>
<xsl:import href="numbering.xslt"/>
<xsl:import href="localisation.xslt"/>
<xsl:import href="placeholders.xslt"/>
<xsl:import href="secrets.xslt"/>
<xsl:import href="fo_placeholders.xslt"/>
<xsl:import href="fo_secrets.xslt"/>
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>

148
xml/xslt/html_inline.xslt Normal file
View File

@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:import href="inline.xslt"/>
<xsl:template match="br | p | ul | ol | li | pre | div | img">
<xsl:copy copy-namespaces="no">
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="a">
<xsl:variable name="destination">
<xsl:choose>
<xsl:when test="starts-with(@href, '#')">
<xsl:value-of select="substring(@href, 2)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@href"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="checkLinkValidity"/>
<xsl:choose>
<xsl:when test="starts-with(@href, '#') and not(//*[@id = $destination])">
<xsl:call-template name="displayErrorText">
<xsl:with-param name="string" select="'WARNING: LINK TARGET NOT FOUND IN DOCUMENT'"></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when
test="(starts-with(@href, '#') and //*[@id = $destination][ancestor-or-self::*[@visibility = 'hidden']])">
<xsl:call-template name="displayErrorText">
<xsl:with-param name="string" select="'WARNING: LINK TARGET NOT FOUND IN DOCUMENT'"></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<a class="link" href="{@href}">
<xsl:call-template name="linkText">
<xsl:with-param name="destination" select="$destination"/>
</xsl:call-template>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="linkText">
<xsl:param name="destination"/>
<xsl:choose>
<xsl:when test="starts-with(@href, '#') and not(text())">
<xsl:for-each select="key('rosid', $destination)">
<xsl:if test="not(local-name() = 'appendix' or local-name() = 'finding')">
<!-- appendix already has 'appendix' as part of its numbering, findings should not be prefixed with the word 'finding' -->
<xsl:value-of select="local-name()"/>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="." mode="number"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="* | text()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="a" mode="summarytable">
<xsl:variable name="destination">
<xsl:choose>
<xsl:when test="starts-with(@href, '#')">
<xsl:value-of select="substring(@href, 2)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@href"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a class="link" href="{@href}">
<xsl:choose>
<xsl:when test="starts-with(@href, '#') and not(text())">
<xsl:for-each select="key('rosid', $destination)">
<xsl:if test="not(local-name() = 'appendix' or local-name() = 'finding')">
<!-- appendix already has 'appendix' as part of its numbering, findings should not be prefixed with the word 'finding' -->
<xsl:value-of select="local-name()"/>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="." mode="number"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="* | text()"/>
</xsl:otherwise>
</xsl:choose>
</a>
</xsl:template>
<xsl:template match="b">
<strong>
<xsl:apply-templates/>
</strong>
</xsl:template>
<xsl:template match="i">
<em>
<xsl:apply-templates/>
</em>
</xsl:template>
<xsl:template match="u">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="code">
<xsl:choose>
<xsl:when test="ancestor::title">
<code>
<xsl:apply-templates/>
</code>
</xsl:when>
<xsl:when test="ancestor::pre">
<!-- <code> in <pre> is just <pre> -->
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<code>
<xsl:apply-templates/>
</code>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="sup">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="sub">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:svg="http://www.w3.org/2000/svg" xmlns:my="http://www.radical.sexy"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<xsl:import href="piecharts.xslt"/>
<xsl:variable name="pieTextStyle">
<xsl:text>font-family: 'Open Sans'; font-size: 11pt; color:
black;</xsl:text>
</xsl:variable>
<xsl:template name="output_piechart_with_legend">
<xsl:param name="pieTable"/>
<xsl:param name="pieHeight"/>
<xsl:param name="pieTotal"/>
<xsl:param name="no_entries"/>
<xsl:param name="pieHeightHalf"/>
<xsl:param name="x"/>
<xsl:param name="pieAttr"/>
<xsl:for-each select="$pieTable">
<div class="row">
<div class="five columns">
<xsl:call-template name="pie_svg">
<xsl:with-param name="pieHeight" select="$pieHeight"/>
<xsl:with-param name="pieTotal" select="$pieTotal"/>
<xsl:with-param name="no_entries" select="$no_entries"/>
<xsl:with-param name="pieHeightHalf" select="$pieHeightHalf"/>
</xsl:call-template>
</div>
<!-- PIE CHART LEGEND -->
<div class="seven columns">
<xsl:for-each select="$pieTable/pieEntry">
<xsl:variable name="pieEntryLabelClean"
select="translate(pieEntryLabel, '/', '_')"/>
<xsl:variable name="pieEntryLabel">
<xsl:sequence
select="
string-join(for $x in tokenize(pieEntryLabel, '_')
return
my:titleCase($x), ' ')"
/>
</xsl:variable>
<div>
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16">
<rect xmlns="http://www.w3.org/2000/svg" stroke="#706f6f"
stroke-width="1" stroke-linejoin="round" height="16" width="16">
<xsl:attribute name="fill">
<xsl:call-template name="selectColor">
<xsl:with-param name="position" select="position()"/>
<xsl:with-param name="label" select="pieEntryLabel"/>
</xsl:call-template>
</xsl:attribute>
</rect>
</svg>
<span class="pieLegendText">
<xsl:value-of select="$pieEntryLabel"/>
<xsl:text> (</xsl:text>
<!-- for threatLevel legend, link to finding summary table -->
<xsl:choose>
<xsl:when test="$pieAttr = 'threatLevel'">
<a>
<xsl:attribute name="href"
>#summaryTableThreatLevel<xsl:value-of
select="$pieEntryLabelClean"/></xsl:attribute>
<xsl:value-of select="pieEntryCount"/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="pieEntryCount"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>)</xsl:text>
</span>
</div>
</xsl:for-each>
</div>
</div>
</xsl:for-each>
</xsl:template>
<xsl:template name="pie_percentage_large_slice_style">
<xsl:param name="text_angle"/>
<xsl:param name="middle_x"/>
<xsl:param name="text_line_x"/>
<xsl:param name="percentage"/>
<xsl:param name="part_half"/>
<xsl:param name="middle_y"/>
<xsl:param name="text_line_y"/>
<text xmlns="http://www.w3.org/2000/svg">
<xsl:attribute name="style"><xsl:value-of select="normalize-space($pieTextStyle)"/></xsl:attribute>
<xsl:call-template name="pie_percentage_large_slice_content">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="middle_x" select="$middle_x"/>
<xsl:with-param name="text_line_x" select="$text_line_x"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
<xsl:with-param name="middle_y" select="$middle_y"/>
<xsl:with-param name="text_line_y" select="$text_line_y"/>
</xsl:call-template>
</text>
</xsl:template>
<xsl:template name="pie_percentage_small_slice_style">
<xsl:param name="text_x_relative_to_line"/>
<xsl:param name="middle_y"/>
<xsl:param name="text_line_y"/>
<xsl:param name="percentage"/>
<text xmlns="http://www.w3.org/2000/svg" text-anchor="end">
<xsl:attribute name="style"><xsl:value-of select="normalize-space($pieTextStyle)"/></xsl:attribute>
<xsl:call-template name="pie_percentage_small_slice_content">
<xsl:with-param name="text_x_relative_to_line" select="$text_x_relative_to_line"/>
<xsl:with-param name="middle_y" select="$middle_y"/>
<xsl:with-param name="text_line_y" select="$text_line_y"/>
<xsl:with-param name="percentage" select="$percentage"/>
</xsl:call-template>
</text>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:import href="placeholders.xslt"/>
<xsl:template name="displayErrorText">
<xsl:param name="string" select="'XXXXXXXXXX'"/>
<span class="errortext"><xsl:value-of select="$string"/></span>
</xsl:template>
<xsl:template name="generate_activities"/>
</xsl:stylesheet>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:import href="secrets.xslt"/>
<xsl:template name="censoredInline">
<span class="censoredtext">[ CENSORED ]</span>
</xsl:template>
<xsl:template name="censoredBlock">
<div class="censoredblock">
<xsl:text>[ CENSORED ]</xsl:text>
</div>
</xsl:template>
</xsl:stylesheet>

View File

@@ -1,373 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
xmlns:fo="http://www.w3.org/1999/XSL/Format" version="2.0">
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<xsl:template match="a">
<xsl:param name="execsummary" tunnel="yes"/>
<xsl:variable name="destination">
<xsl:choose>
<xsl:when test="starts-with(@href, '#')">
<xsl:value-of select="substring(@href, 2)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@href"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="starts-with(@href, '#') and not(//*[@id = $destination])">
<fo:inline xsl:use-attribute-sets="errortext">WARNING: LINK TARGET NOT FOUND IN
DOCUMENT</fo:inline>
</xsl:when>
<xsl:when
test="(starts-with(@href, '#') and //*[@id = $destination][ancestor-or-self::*[@visibility = 'hidden']])">
<fo:inline xsl:use-attribute-sets="errortext">WARNING: LINK TARGET IS
HIDDEN</fo:inline>
</xsl:when>
<xsl:when
test="starts-with(@href, '#') and $execsummary = true() and //*[@id = $destination][ancestor-or-self::*[not(@inexecsummary = 'yes')]]">
<!-- linking to something that is not in the exec summary -->
<xsl:value-of select="local-name(*[@id = $destination])"/>
<xsl:text> </xsl:text>
<xsl:call-template name="linkText">
<xsl:with-param name="destination" select="$destination"/>
<xsl:with-param name="execsummary_linking_to_content_not_in_report" select="true()"></xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<fo:basic-link xsl:use-attribute-sets="link">
<xsl:choose>
<xsl:when test="starts-with(@href, '#')">
<xsl:attribute name="internal-destination">
<xsl:value-of select="$destination"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="external-destination">
<xsl:value-of select="$destination"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="linkText">
<xsl:with-param name="destination" select="$destination"/>
</xsl:call-template>
</fo:basic-link>
<xsl:if test="starts-with(@href, '#')">
<xsl:if test="not(@includepage = 'no')">
<xsl:text> (page </xsl:text>
<fo:page-number-citation ref-id="{substring(@href, 2)}"/>
<xsl:text>)</xsl:text>
</xsl:if>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="linkText">
<xsl:param name="execsummary_linking_to_content_not_in_report" select="false()"/>
<xsl:param name="destination"/>
<xsl:choose>
<xsl:when test="starts-with(@href, '#') and not(text())">
<xsl:for-each select="key('rosid', $destination)">
<xsl:choose>
<xsl:when test="$execsummary_linking_to_content_not_in_report = false()">
<xsl:if test="not(local-name() = 'appendix' or local-name() = 'finding')">
<!-- appendix already has 'appendix' as part of its numbering, findings should not be prefixed with the word 'finding' -->
<xsl:value-of select="local-name()"/>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="." mode="number"/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="not(local-name() = 'appendix')">
<!-- appendix already has 'appendix' as part of its numbering, findings should not be prefixed with the word 'finding' -->
<xsl:value-of select="local-name()"/>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="." mode="number"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="* | text()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="a" mode="summarytable">
<xsl:variable name="destination">
<xsl:choose>
<xsl:when test="starts-with(@href, '#')">
<xsl:value-of select="substring(@href, 2)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@href"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<fo:basic-link xsl:use-attribute-sets="link">
<xsl:choose>
<xsl:when test="starts-with(@href, '#')">
<xsl:attribute name="internal-destination">
<xsl:value-of select="$destination"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="external-destination">
<xsl:value-of select="$destination"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="starts-with(@href, '#') and not(text())">
<xsl:for-each select="key('rosid', $destination)">
<xsl:if test="not(local-name() = 'appendix' or local-name() = 'finding')">
<!-- appendix already has 'appendix' as part of its numbering, findings should not be prefixed with the word 'finding' -->
<xsl:value-of select="local-name()"/>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select="." mode="number"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="* | text()"/>
</xsl:otherwise>
</xsl:choose>
</fo:basic-link>
</xsl:template>
<xsl:template match="b">
<fo:inline xsl:use-attribute-sets="bold">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
<xsl:template match="i">
<fo:inline xsl:use-attribute-sets="italic">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
<xsl:template match="u">
<fo:inline xsl:use-attribute-sets="underline">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
<xsl:template match="code">
<xsl:choose>
<xsl:when test="ancestor::title">
<fo:inline xsl:use-attribute-sets="code-title">
<xsl:apply-templates/>
</fo:inline>
</xsl:when>
<xsl:when test="ancestor::pre">
<!-- <code> in <pre> is just <pre> -->
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<fo:inline xsl:use-attribute-sets="code">
<xsl:apply-templates/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="sup">
<fo:inline xsl:use-attribute-sets="sup">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
<xsl:template match="sub">
<fo:inline xsl:use-attribute-sets="sub">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
<xsl:template match="fnref">
<xsl:variable name="fnCount" select="count(preceding::fnref) + 1"/>
<fo:footnote>
<fo:inline xsl:use-attribute-sets="sup">
<xsl:value-of select="$fnCount"/>
<xsl:text>&#160;</xsl:text>
</fo:inline>
<fo:footnote-body xsl:use-attribute-sets="TinyFont">
<fo:block>
<fo:inline xsl:use-attribute-sets="sup">
<xsl:value-of select="$fnCount"/>
</fo:inline>
<xsl:apply-templates/>
</fo:block>
</fo:footnote-body>
</fo:footnote>
</xsl:template>
<xsl:template match="bibref">
<xsl:variable name="bibid" select="./@ref"/>
<xsl:variable name="bibCount" select="count(preceding::biblioentry[@id = $bibid]) + 1"/>
<xsl:choose>
<xsl:when test="starts-with(@href, '#') and not(//*[@id = $bibid])">
<fo:inline xsl:use-attribute-sets="errortext">WARNING: BIBLIOGRAPHY ENTRY NOT FOUND
IN DOCUMENT</fo:inline>
</xsl:when>
<xsl:when
test="starts-with(@href, '#') and //*[@id = $bibid][ancestor-or-self::*[@visibility = 'hidden']]">
<fo:inline xsl:use-attribute-sets="errortext">WARNING: BIBLIOGRAPHY ENTRY IS
HIDDEN</fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:basic-link>
<xsl:attribute name="internal-destination">
<xsl:value-of select="$bibid"/>
</xsl:attribute>
<xsl:text>[</xsl:text>
<xsl:for-each select="key('biblioid', $bibid)">
<xsl:apply-templates select="." mode="number"/>
</xsl:for-each>
<xsl:text>]</xsl:text>
</fo:basic-link>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="author">
<xsl:value-of select="firstname"/>
<xsl:text> </xsl:text>
<xsl:value-of select="surname"/>
<xsl:if test="org">
<xsl:if test="firstname | surname">
<xsl:text> (</xsl:text>
</xsl:if>
<xsl:value-of select="org"/>
<xsl:if test="firstname | surname">
<xsl:text>)</xsl:text>
</xsl:if>
<xsl:template name="checkLinkValidity">
<xsl:if test="not(starts-with(@href, '#')) and not(contains(@href, '://'))">
<xsl:call-template name="displayErrorText">
<xsl:with-param name="string">[ Invalid link: use #[id] for internal links or a
well-formed url for external ones ]</xsl:with-param>
</xsl:call-template>
</xsl:if>
<xsl:choose>
<xsl:when test="following-sibling::author">, </xsl:when>
<xsl:otherwise>
<xsl:text>. </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="biblioentry/title">
<xsl:choose>
<xsl:when test="../@role = 'book'">
<fo:inline xsl:use-attribute-sets="title.book">
<xsl:apply-templates/>
</fo:inline>
</xsl:when>
<xsl:when test="../@role = 'article'">
<fo:inline xsl:use-attribute-sets="title.article">
<xsl:apply-templates/>
</fo:inline>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="following-sibling::info">
<!-- we're getting something more, place a comma -->
<xsl:text>, </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>. </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="journal">
<fo:inline xsl:use-attribute-sets="journal">
<xsl:apply-templates/>
</fo:inline>
<xsl:choose>
<xsl:when test="following-sibling::info or following-sibling::pubdate">
<!-- we're getting something more, place a comma -->
<xsl:text>, </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>. </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="website">
<fo:inline xsl:use-attribute-sets="website">
<xsl:apply-templates/>
</fo:inline>
<xsl:choose>
<xsl:when test="following-sibling::info or following-sibling::pubdate">
<!-- we're getting something more, place a comma -->
<xsl:text>, </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>. </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="info">
<fo:inline xsl:use-attribute-sets="info">
<xsl:apply-templates/>
</fo:inline>
<xsl:choose>
<xsl:when test="../@role = 'article' and following-sibling::pubdate">
<!-- we're getting something more, place a comma -->
<xsl:text>, </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>. </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="publisher">
<fo:inline xsl:use-attribute-sets="publisher">
<xsl:apply-templates/>
</fo:inline>
<xsl:choose>
<xsl:when test="following-sibling::pubdate">
<!-- we're getting something more, place a comma -->
<xsl:text>, </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>. </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="publisher/name">
<xsl:apply-templates/>
<xsl:if test="following-sibling::location">
<!-- we're getting something more, place a comma -->
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="publisher/location">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="pubdate">
<fo:inline xsl:use-attribute-sets="pubdate">
<xsl:apply-templates/>
</fo:inline>
<xsl:text>. </xsl:text>
</xsl:template>
<xsl:template match="link">
<xsl:apply-templates select="a"/>
<xsl:text>. </xsl:text>
<xsl:if test="accessed">
<xsl:apply-templates select="accessed"/>
</xsl:if>
</xsl:template>
<xsl:template match="accessed">
<xsl:text>Accessed: </xsl:text>
<xsl:apply-templates/>
<xsl:text>.</xsl:text>
</xsl:template>
</xsl:stylesheet>

View File

@@ -6,9 +6,6 @@
<xsl:variable name="strdoc"
select="document('../source/snippets/localisationstrings.xml')/localised_strings"/>
<xsl:template name="getString">
<xsl:param name="stringID" select="'none'"/>

View File

@@ -109,11 +109,11 @@
<xsl:comment> generated from Findings section </xsl:comment>
<section id="threatlevelpie">
<title>Findings by Threat Level</title>
<generate_piechart pieAttr="threatLevel" pieElem="finding" pieHeight="200" threshold="1"/>
<generate_piechart pieAttr="threatLevel" pieElem="finding"/>
</section>
<section id="typepie">
<title>Findings by Type</title>
<generate_piechart pieAttr="type" pieElem="finding" pieHeight="200" threshold="2"/>
<generate_piechart pieAttr="type" pieElem="finding"/>
</section>
</section>
<section id="recommendationSummary">

View File

@@ -3,6 +3,10 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:svg="http://www.w3.org/2000/svg" xmlns:math="http://www.w3.org/2005/xpath-functions/math"
xmlns:my="http://www.radical.sexy" exclude-result-prefixes="xs math" version="2.0">
<!-- Note: any svg here should be output as <svg xmlns:svg="http://www.w3.org/2000/svg"> rather than <svg:svg> to make the result readable both by xsl-fo parsers and html5 parsers (fop and browsers, specifically ;) -->
<xsl:template match="generate_piechart">
<xsl:choose>
<xsl:when test="//finding">
@@ -10,19 +14,14 @@
<xsl:call-template name="do_generate_piechart">
<xsl:with-param name="pieAttr" select="@pieAttr"/>
<xsl:with-param name="pieElem" select="@pieElem"/>
<xsl:with-param name="pieHeight" select="@pieHeight"/>
<xsl:with-param name="status" select="@status"/>
<xsl:with-param name="threshold">
<xsl:choose>
<xsl:when test="@threshold"><xsl:value-of select="@threshold"/></xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<fo:block xsl:use-attribute-sets="errortext">Pie chart can only be generated when
there are findings in the report. Get to work! ;)</fo:block>
<xsl:call-template name="displayErrorText">
<xsl:with-param name="string">Pie chart can only be generated when
there are findings in the report. Get to work! ;)</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
@@ -32,9 +31,9 @@
<!-- generate_piechart @type="type" or "threatLevel" -->
<xsl:param name="pieAttr" select="@pieAttr"/>
<xsl:param name="pieElem" select="@pieElem"/>
<xsl:param name="pieHeight" as="xs:integer" select="@pieHeight"/>
<xsl:param name="pieHeight" as="xs:integer" select="200"/>
<xsl:param name="status" select="@status"/>
<xsl:param name="threshold" select="@threshold"/>
<xsl:param name="threshold" select="2"/>
<xsl:variable name="statusSequence" as="item()*">
<xsl:for-each select="$status">
<xsl:for-each select="tokenize(., ' ')">
@@ -152,7 +151,7 @@
</xsl:variable>
<xsl:variable name="pieTable_thresholdApplied">
<xsl:choose>
<xsl:when test="$threshold &gt; 1">
<xsl:when test="not($pieAttr = 'threatLevel') and $sumBelowThreshold > 4">
<xsl:for-each
select="$sortedPieTable/pieEntry[child::pieEntryCount &gt;= $threshold]">
<pieEntry>
@@ -172,7 +171,7 @@
</xsl:variable>
<xsl:variable name="pieTable">
<xsl:copy-of select="$pieTable_thresholdApplied" copy-namespaces="no"/>
<xsl:if test="$threshold &gt; 1">
<xsl:if test="not($pieAttr = 'threatLevel') and $sumBelowThreshold > 4">
<pieEntry>
<pieEntryLabel>
<xsl:text>Other</xsl:text>
@@ -184,127 +183,50 @@
</xsl:if>
</xsl:variable>
<xsl:variable name="no_entries" select="count($pieTable/pieEntry)"/>
<xsl:for-each select="$pieTable">
<fo:block xsl:use-attribute-sets="p">
<fo:table margin-top="15px" xsl:use-attribute-sets="fwtable">
<!-- need some margin to make space for percentages that can't fit in the pie... -->
<fo:table-column column-width="{$pieHeight + 85}px"/>
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-body>
<fo:table-row keep-together.within-column="always">
<fo:table-cell xsl:use-attribute-sets="td indent_reset">
<fo:block>
<fo:instream-foreign-object
xmlns:svg="http://www.w3.org/2000/svg">
<!--set the display-->
<svg:svg>
<!-- width and height of the viewport -->
<xsl:attribute name="width">
<xsl:value-of select="$pieHeight + 30"/>
</xsl:attribute>
<xsl:attribute name="height">
<xsl:value-of select="$pieHeight + 30"/>
</xsl:attribute>
<!-- viewBox to scale -->
<xsl:attribute name="viewBox">
<!-- start viewbox 15px to the left and make it 15px larger to catch svg's cutoff text -->
<xsl:value-of
select="concat('-15 0 ', $pieHeight + 15 + 30, ' ', $pieHeight + 30)"
/>
</xsl:attribute>
<!--call the template starting at the last slice-->
<xsl:call-template name="pie_chart_slice">
<xsl:with-param name="pieTotal" select="$pieTotal"/>
<xsl:with-param name="no_entries"
select="$no_entries"/>
<xsl:with-param name="position" select="$no_entries"/>
<xsl:with-param name="middle_x"
select="$pieHeightHalf"/>
<xsl:with-param name="middle_y"
select="$pieHeightHalf"/>
<xsl:with-param name="move_x" select="0"/>
<xsl:with-param name="radius"
select="$pieHeightHalf div 100 * 85"/>
</xsl:call-template>
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
</fo:table-cell>
<!-- PIE CHART LEGEND -->
<fo:table-cell>
<fo:block>
<fo:table xsl:use-attribute-sets="pieLegendTable fwtable">
<fo:table-column column-width="22px"/>
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-body>
<xsl:for-each select="$pieTable/pieEntry">
<xsl:variable name="pieEntryLabelClean"
select="translate(pieEntryLabel, '/', '_')"/>
<xsl:variable name="pieEntryLabel">
<xsl:sequence
select="
string-join(for $x in tokenize(pieEntryLabel, '_')
return
my:titleCase($x), ' ')"
/>
</xsl:variable>
<fo:table-row>
<fo:table-cell
xsl:use-attribute-sets="pieLegendTableCell">
<fo:block>
<fo:instream-foreign-object>
<svg:svg height="13" width="13">
<svg:rect stroke="#706f6f" stroke-width="1"
stroke-linejoin="round" height="11" width="11">
<xsl:attribute name="fill">
<xsl:call-template name="selectColor">
<xsl:with-param name="position"
select="position()"/>
<xsl:with-param name="label"
select="pieEntryLabel"/>
</xsl:call-template>
</xsl:attribute>
</svg:rect>
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
</fo:table-cell>
<fo:table-cell
xsl:use-attribute-sets="pieLegendTableCell">
<fo:block>
<xsl:value-of select="$pieEntryLabel"/>
<xsl:text> (</xsl:text>
<!-- for threatLevel legend, link to finding summary table -->
<xsl:choose>
<xsl:when test="$pieAttr = 'threatLevel'">
<fo:basic-link xsl:use-attribute-sets="link">
<xsl:attribute name="internal-destination"
>summaryTableThreatLevel<xsl:value-of
select="$pieEntryLabelClean"/></xsl:attribute>
<xsl:value-of select="pieEntryCount"/>
</fo:basic-link>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="pieEntryCount"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>)</xsl:text>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:for-each>
<xsl:call-template name="output_piechart_with_legend">
<xsl:with-param name="pieTable" select="$pieTable"/>
<xsl:with-param name="pieHeight" select="$pieHeight"/>
<xsl:with-param name="pieTotal" select="$pieTotal"/>
<xsl:with-param name="no_entries" select="$no_entries"/>
<xsl:with-param name="pieHeightHalf" select="$pieHeightHalf"/>
<xsl:with-param name="pieAttr" select="$pieAttr"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="pie_svg">
<xsl:param name="pieHeight"/>
<xsl:param name="pieTotal"/>
<xsl:param name="no_entries"/>
<xsl:param name="pieHeightHalf"/>
<svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" viewBox="-40 -20 300 300">
<!-- The bit below tried to configure the piechart size but basically nobody ever changes it and it just makes it all way too difficult -->
<!-- width and height of the viewport -->
<!--<xsl:attribute name="width">
<xsl:value-of select="$pieHeight + $spacing_for_percentage_labels * 2"/>
</xsl:attribute>
<xsl:attribute name="height">
<xsl:value-of select="$pieHeight + $spacing_for_percentage_labels * 2"/>
</xsl:attribute>
<!-\- viewBox to scale -\->
<xsl:attribute name="viewBox">
<!-\- start viewbox 15px to the left and make it 15px larger to catch svg's cutoff text -\->
<xsl:value-of select="concat(-$spacing_for_percentage_labels, ' 0 ', $pieHeight + $spacing_for_percentage_labels * 2, ' ', $pieHeight + ($spacing_for_percentage_labels * 3))"
/>
</xsl:attribute>-->
<!--call the template starting at the last slice-->
<xsl:call-template name="pie_chart_slice">
<xsl:with-param name="pieTotal" select="$pieTotal"/>
<xsl:with-param name="no_entries" select="$no_entries"/>
<xsl:with-param name="position" select="$no_entries"/>
<xsl:with-param name="middle_x" select="$pieHeightHalf"/>
<xsl:with-param name="middle_y" select="$pieHeightHalf"/>
<xsl:with-param name="move_x" select="0"/>
<xsl:with-param name="radius" select="$pieHeightHalf div 100 * 85"/>
</xsl:call-template>
</svg>
</xsl:template>
<xsl:template name="pie_chart_slice">
<xsl:param name="pieTotal"/>
@@ -337,7 +259,7 @@
<xsl:variable name="d"
select="concat($middle, ' ', $first_line, ' ', 'a ', $radius, ',', $radius, ' ', $arc_move, ' ', $x, ',', $radius - $y, ' ', 'z')"/>
<!--put it all together-->
<svg:path stroke="white" stroke-width="1" stroke-linejoin="round">
<path xmlns="http://www.w3.org/2000/svg" stroke="white" stroke-width="1" stroke-linejoin="round">
<xsl:attribute name="fill">
<xsl:call-template name="selectColor">
<xsl:with-param name="position" select="$position"/>
@@ -348,7 +270,7 @@
<xsl:attribute name="d">
<xsl:value-of select="$d"/>
</xsl:attribute>
</svg:path>
</path>
<!--now the percentage-->
<xsl:variable name="percentage" as="xs:double"
select="(//pieEntry[position() = $position]/pieEntryCount div sum(//pieEntry/pieEntryCount)) * 100"/>
@@ -367,231 +289,15 @@
<xsl:choose>
<xsl:when test="$percentage >= 3.5">
<!--on the edge-->
<svg:text xsl:use-attribute-sets="PieFont">
<xsl:attribute name="x">
<xsl:choose>
<!-- try for some better placement of percentages than the standard -->
<xsl:when test="$text_angle &lt;= 22.5">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 45 and $text_angle &gt; 22.5">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 67.5 and $text_angle &gt; 45">
<xsl:value-of select="$middle_x + $text_line_x - 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 85 and $text_angle &gt; 67.5">
<xsl:value-of select="$middle_x + $text_line_x - 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 95 and $text_angle &gt; 85">
<xsl:value-of select="$middle_x + $text_line_x - 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 112.5 and $text_angle &gt; 95">
<xsl:value-of select="$middle_x + $text_line_x - 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 135 and $text_angle &gt; 112.5">
<xsl:value-of select="$middle_x + $text_line_x - 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 157.5 and $text_angle &gt; 135">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 180 and $text_angle &gt; 157.5">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 202.5 and $text_angle &gt; 180">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 225 and $text_angle &gt; 202.5">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 247.5 and $text_angle &gt; 225">
<xsl:value-of select="$middle_x + $text_line_x + 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 265 and $text_angle &gt; 247.5">
<xsl:value-of select="$middle_x + $text_line_x + 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 275 and $text_angle &gt; 265">
<xsl:value-of select="$middle_x + $text_line_x + 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 292.5 and $text_angle &gt; 275">
<xsl:value-of select="$middle_x + $text_line_x + 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 315 and $text_angle &gt; 292.5">
<xsl:value-of select="$middle_x + $text_line_x + 6"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 337.5 and $text_angle &gt; 315">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 360 and $text_angle &gt; 337.5">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$middle_x + $text_line_x"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="y">
<xsl:choose>
<!-- when in top right/bottom left quarters of circle, bring percentage text a bit closer to the circle -->
<xsl:when test="$text_angle &lt;= 22.5">
<xsl:value-of select="$middle_y - $text_line_y + 5"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 45 and $text_angle &gt; 22.5">
<xsl:value-of select="$middle_y - $text_line_y + 4"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 67.5 and $text_angle &gt; 45">
<xsl:value-of select="$middle_y - $text_line_y + 3"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 90 and $text_angle &gt; 67.5">
<xsl:value-of select="$middle_y - $text_line_y + 2"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 112.5 and $text_angle &gt; 90">
<xsl:value-of select="$middle_y - $text_line_y + 1"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 135 and $text_angle &gt; 112.5">
<xsl:value-of select="$middle_y - $text_line_y - 1"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 157.5 and $text_angle &gt; 135">
<xsl:value-of select="$middle_y - $text_line_y + 1"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 180 and $text_angle &gt; 157.5">
<xsl:value-of select="$middle_y - $text_line_y - 0"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 202.5 and $text_angle &gt; 180">
<xsl:value-of select="$middle_y - $text_line_y - 0"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 225 and $text_angle &gt; 202.5">
<xsl:value-of select="$middle_y - $text_line_y + 1"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 247.5 and $text_angle &gt; 225">
<xsl:value-of select="$middle_y - $text_line_y - 1"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 270 and $text_angle &gt; 247.5">
<xsl:value-of select="$middle_y - $text_line_y + 1"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 292.5 and $text_angle &gt; 270">
<xsl:value-of select="$middle_y - $text_line_y + 2"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 315 and $text_angle &gt; 292.5">
<xsl:value-of select="$middle_y - $text_line_y + 3"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 337.5 and $text_angle &gt; 315">
<xsl:value-of select="$middle_y - $text_line_y + 4"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 360 and $text_angle &gt; 337.5">
<xsl:value-of select="$middle_y - $text_line_y + 5"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$middle_y - $text_line_y"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="text-anchor">
<xsl:choose>
<!-- when in top/bottom quarters of circle, text is anchored in the middle, when left on end, when right on start -->
<xsl:when
test="($text_angle &gt;= 315 or $text_angle &lt;= 45) or ($text_angle &lt;= 225 and $text_angle &gt;= 135)"
>middle</xsl:when>
<xsl:when test="$text_angle &lt; 135 and $text_angle &gt; 45"
>start</xsl:when>
<xsl:when test="$text_angle &lt; 315 and $text_angle &gt; 225"
>end</xsl:when>
<xsl:otherwise>middle</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="format-number($percentage, '##,##0.0')"/>
<xsl:text>%</xsl:text>
</svg:text>
<xsl:call-template name="pie_percentage_large_slice_style">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="middle_x" select="$middle_x"/>
<xsl:with-param name="text_line_x" select="$text_line_x"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
<xsl:with-param name="middle_y" select="$middle_y"/>
<xsl:with-param name="text_line_y" select="$text_line_y"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!--extra line pointing into the slice-->
@@ -613,37 +319,22 @@
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<svg:path stroke="black" stroke-width="1" stroke-linejoin="round">
<path xmlns="http://www.w3.org/2000/svg" stroke="black" stroke-width="1" stroke-linejoin="round">
<xsl:attribute name="fill">none</xsl:attribute>
<xsl:attribute name="d">
<xsl:value-of
select="concat('M', ' ', $middle_x + $text_x, ',', $middle_y - $text_y, ' ', 'L', ' ', $middle_x + $text_line_x, ',', $middle_y - $text_line_y, ' ', 'H', ' ', $middle_x + $text_line_x + $line_dir)"
/>
</xsl:attribute>
</svg:path>
<svg:text text-anchor="end" xsl:use-attribute-sets="PieFont">
<xsl:attribute name="x">
<!-- placement of text depends on where extra line is pointing -->
<xsl:value-of select="$text_x_relative_to_line"/>
</xsl:attribute>
<xsl:attribute name="y">
<xsl:value-of select="$middle_y - $text_line_y + 1"/>
</xsl:attribute>
<xsl:value-of select="format-number($percentage, '##,##0.0')"/>
<xsl:text>%</xsl:text>
</svg:text>
</path>
<xsl:call-template name="pie_percentage_small_slice_style">
<xsl:with-param name="text_x_relative_to_line" select="$text_x_relative_to_line"/>
<xsl:with-param name="middle_y" select="$middle_y"/>
<xsl:with-param name="text_line_y" select="$text_line_y"/>
<xsl:with-param name="percentage" select="$percentage"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<!--<svg:text text-anchor="middle" xsl:use-attribute-sets="DefaultFont">
<xsl:attribute name="x">
<xsl:value-of select="$middle_x + $text_line_x"/>
</xsl:attribute>
<xsl:attribute name="y">
<xsl:value-of select="$middle_y - $text_line_y"/>
</xsl:attribute>
<xsl:value-of select="format-number($percentage, '##,##0.0')"/>
<xsl:text>%</xsl:text>
</svg:text>-->
<!--loop until we reach the first part-->
<xsl:if test="$position > 1">
<xsl:call-template name="pie_chart_slice">
@@ -657,6 +348,253 @@
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="pie_percentage_small_slice_content">
<xsl:param name="text_x_relative_to_line"/>
<xsl:param name="middle_y"/>
<xsl:param name="text_line_y"/>
<xsl:param name="percentage"/>
<xsl:attribute name="x">
<!-- placement of text depends on where extra line is pointing -->
<xsl:value-of select="$text_x_relative_to_line"/>
</xsl:attribute>
<xsl:attribute name="y">
<xsl:value-of select="$middle_y - $text_line_y + 1"/>
</xsl:attribute>
<xsl:value-of select="format-number($percentage, '##,##0.0')"/>
<xsl:text>%</xsl:text>
</xsl:template>
<xsl:template name="pie_percentage_large_slice_content">
<xsl:param name="text_angle"/>
<xsl:param name="middle_x"/>
<xsl:param name="text_line_x"/>
<xsl:param name="percentage"/>
<xsl:param name="part_half"/>
<xsl:param name="middle_y"/>
<xsl:param name="text_line_y"/>
<xsl:attribute name="x">
<xsl:choose>
<!-- try for some better placement of percentages than the standard -->
<xsl:when test="$text_angle &lt;= 22.5">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 45 and $text_angle &gt; 22.5">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 67.5 and $text_angle &gt; 45">
<xsl:value-of select="$middle_x + $text_line_x - 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 85 and $text_angle &gt; 67.5">
<xsl:value-of select="$middle_x + $text_line_x - 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 95 and $text_angle &gt; 85">
<xsl:value-of select="$middle_x + $text_line_x - 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 112.5 and $text_angle &gt; 95">
<xsl:value-of select="$middle_x + $text_line_x - 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 135 and $text_angle &gt; 112.5">
<xsl:value-of select="$middle_x + $text_line_x - 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 157.5 and $text_angle &gt; 135">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 180 and $text_angle &gt; 157.5">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 202.5 and $text_angle &gt; 180">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 225 and $text_angle &gt; 202.5">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 247.5 and $text_angle &gt; 225">
<xsl:value-of select="$middle_x + $text_line_x + 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 265 and $text_angle &gt; 247.5">
<xsl:value-of select="$middle_x + $text_line_x + 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 275 and $text_angle &gt; 265">
<xsl:value-of select="$middle_x + $text_line_x + 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 292.5 and $text_angle &gt; 275">
<xsl:value-of select="$middle_x + $text_line_x + 8"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 315 and $text_angle &gt; 292.5">
<xsl:value-of select="$middle_x + $text_line_x + 6"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 337.5 and $text_angle &gt; 315">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$text_angle &lt;= 360 and $text_angle &gt; 337.5">
<xsl:value-of select="$middle_x + $text_line_x"/>
<xsl:call-template name="piechartdebug">
<xsl:with-param name="text_angle" select="$text_angle"/>
<xsl:with-param name="percentage" select="$percentage"/>
<xsl:with-param name="part_half" select="$part_half"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$middle_x + $text_line_x"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="y">
<xsl:choose>
<!-- when in top right/bottom left quarters of circle, bring percentage text a bit closer to the circle -->
<xsl:when test="$text_angle &lt;= 22.5">
<xsl:value-of select="$middle_y - $text_line_y + 5"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 45 and $text_angle &gt; 22.5">
<xsl:value-of select="$middle_y - $text_line_y + 4"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 67.5 and $text_angle &gt; 45">
<xsl:value-of select="$middle_y - $text_line_y + 3"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 90 and $text_angle &gt; 67.5">
<xsl:value-of select="$middle_y - $text_line_y + 2"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 112.5 and $text_angle &gt; 90">
<xsl:value-of select="$middle_y - $text_line_y + 1"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 135 and $text_angle &gt; 112.5">
<xsl:value-of select="$middle_y - $text_line_y - 1"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 157.5 and $text_angle &gt; 135">
<xsl:value-of select="$middle_y - $text_line_y + 1"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 180 and $text_angle &gt; 157.5">
<xsl:value-of select="$middle_y - $text_line_y - 0"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 202.5 and $text_angle &gt; 180">
<xsl:value-of select="$middle_y - $text_line_y - 0"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 225 and $text_angle &gt; 202.5">
<xsl:value-of select="$middle_y - $text_line_y + 1"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 247.5 and $text_angle &gt; 225">
<xsl:value-of select="$middle_y - $text_line_y - 1"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 270 and $text_angle &gt; 247.5">
<xsl:value-of select="$middle_y - $text_line_y + 1"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 292.5 and $text_angle &gt; 270">
<xsl:value-of select="$middle_y - $text_line_y + 2"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 315 and $text_angle &gt; 292.5">
<xsl:value-of select="$middle_y - $text_line_y + 3"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 337.5 and $text_angle &gt; 315">
<xsl:value-of select="$middle_y - $text_line_y + 4"/>
</xsl:when>
<xsl:when test="$text_angle &lt;= 360 and $text_angle &gt; 337.5">
<xsl:value-of select="$middle_y - $text_line_y + 5"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$middle_y - $text_line_y"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="text-anchor">
<xsl:choose>
<!-- when in top/bottom quarters of circle, text is anchored in the middle, when left on end, when right on start -->
<xsl:when
test="($text_angle &gt;= 315 or $text_angle &lt;= 45) or ($text_angle &lt;= 225 and $text_angle &gt;= 135)"
>middle</xsl:when>
<xsl:when test="$text_angle &lt; 135 and $text_angle &gt; 45">start</xsl:when>
<xsl:when test="$text_angle &lt; 315 and $text_angle &gt; 225">end</xsl:when>
<xsl:otherwise>middle</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="format-number($percentage, '##,##0.0')"/>
<xsl:text>%</xsl:text>
</xsl:template>
<xsl:template name="piechartdebug">
<xsl:param name="text_angle"/>
@@ -666,118 +604,5 @@
<xsl:message>TEXT ANGLE: <xsl:value-of select="$text_angle"/></xsl:message>-->
</xsl:template>
<xsl:template name="selectColor">
<xsl:param name="label"/>
<xsl:param name="position"/>
<xsl:choose>
<!-- specific cases -->
<!-- threat level -->
<xsl:when test="$label = 'Extreme'">
<xsl:value-of select="$color_extreme"/>
</xsl:when>
<xsl:when test="$label = 'High'">
<xsl:value-of select="$color_high"/>
</xsl:when>
<xsl:when test="$label = 'Elevated'">
<xsl:value-of select="$color_elevated"/>
</xsl:when>
<xsl:when test="$label = 'Moderate'">
<xsl:value-of select="$color_moderate"/>
</xsl:when>
<xsl:when test="$label = 'Low'">
<xsl:value-of select="$color_low"/>
</xsl:when>
<xsl:when test="$label = 'N/A'">
<xsl:value-of select="$color_na"/>
</xsl:when>
<xsl:when test="$label = 'Unknown'">
<xsl:value-of select="$color_unknown"/>
</xsl:when>
<!-- status -->
<xsl:when test="$label = 'new'">
<xsl:value-of select="$color_new"/>
</xsl:when>
<xsl:when test="$label = 'unresolved'">
<xsl:value-of select="$color_unresolved"/>
</xsl:when>
<xsl:when test="$label = 'not_retested'">
<xsl:value-of select="$color_notretested"/>
</xsl:when>
<xsl:when test="$label = 'resolved'">
<xsl:value-of select="$color_resolved"/>
</xsl:when>
<xsl:otherwise>
<!-- generic pie chart -->
<xsl:choose>
<!-- Going with shades of green, yellow and blue/purple in all cases here so as not to imply severity levels -->
<xsl:when test="$position = 1">
<xsl:value-of select="$generic_piecolor_1"/>
</xsl:when>
<xsl:when test="$position = 2">
<xsl:value-of select="$generic_piecolor_2"/>
</xsl:when>
<xsl:when test="$position = 3">
<xsl:value-of select="$generic_piecolor_3"/>
</xsl:when>
<xsl:when test="$position = 4">
<xsl:value-of select="$generic_piecolor_4"/>
</xsl:when>
<xsl:when test="$position = 5">
<xsl:value-of select="$generic_piecolor_5"/>
</xsl:when>
<xsl:when test="$position = 6">
<xsl:value-of select="$generic_piecolor_6"/>
</xsl:when>
<xsl:when test="$position = 7">
<xsl:value-of select="$generic_piecolor_7"/>
</xsl:when>
<xsl:when test="$position = 8">
<xsl:value-of select="$generic_piecolor_8"/>
</xsl:when>
<xsl:when test="$position = 9">
<xsl:value-of select="$generic_piecolor_9"/>
</xsl:when>
<xsl:when test="$position = 10">
<xsl:value-of select="$generic_piecolor_10"/>
</xsl:when>
<xsl:when test="$position = 11">
<xsl:value-of select="$generic_piecolor_11"/>
</xsl:when>
<xsl:when test="$position = 12">
<xsl:value-of select="$generic_piecolor_12"/>
</xsl:when>
<xsl:when test="$position = 13">
<xsl:value-of select="$generic_piecolor_13"/>
</xsl:when>
<xsl:when test="$position = 14">
<xsl:value-of select="$generic_piecolor_14"/>
</xsl:when>
<xsl:when test="$position = 15">
<xsl:value-of select="$generic_piecolor_15"/>
</xsl:when>
<xsl:when test="$position = 16">
<xsl:value-of select="$generic_piecolor_16"/>
</xsl:when>
<xsl:when test="$position = 17">
<xsl:value-of select="$generic_piecolor_17"/>
</xsl:when>
<xsl:when test="$position = 18">
<xsl:value-of select="$generic_piecolor_18"/>
</xsl:when>
<xsl:when test="$position = 19">
<xsl:value-of select="$generic_piecolor_19"/>
</xsl:when>
<xsl:when test="$position = 20">
<xsl:value-of select="$generic_piecolor_20"/>
</xsl:when>
<xsl:when test="$position = 21">
<xsl:value-of select="$generic_piecolor_21"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$generic_piecolor_other"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View File

@@ -1,24 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:my="http://radical.sexy" exclude-result-prefixes="xs my" version="2.0">
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:my="http://www.radical.sexy"
exclude-result-prefixes="xs my" version="2.0">
<xsl:template name="getDenomination">
<xsl:param name="placeholderElement" as="node()" select="/"/>
<xsl:choose>
<xsl:when test="$placeholderElement/ancestor-or-self::*/@denomination = 'eur'"
<xsl:when
test="$placeholderElement/ancestor-or-self::*[@denomination][1]/@denomination = 'eur'"
></xsl:when>
<xsl:when test="$placeholderElement/ancestor-or-self::*/@denomination = 'usd'"
<xsl:when
test="$placeholderElement/ancestor-or-self::*[@denomination][1]/@denomination = 'usd'"
>$</xsl:when>
<xsl:when test="$placeholderElement/ancestor-or-self::*/@denomination = 'gbp'"
<xsl:when
test="$placeholderElement/ancestor-or-self::*[@denomination][1]/@denomination = 'gbp'"
>£</xsl:when>
<xsl:otherwise>
<fo:inline xsl:use-attribute-sets="errortext">WARNING: NO DENOMINATION
FOUND</fo:inline>
<xsl:call-template name="displayErrorText">
<xsl:with-param name="string">WARNING: NO DENOMINATION FOUND</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- PLACEHOLDERS -->
<xsl:template match="client_long">
<xsl:param name="placeholderElement" select="/*/meta//client/full_name"/>
@@ -274,10 +279,12 @@
<xsl:template match="contract_activities">
<xsl:choose>
<xsl:when test="/contract/meta/work/activities/activity">
<xsl:call-template name="generate_activities_xslt"/>
<xsl:call-template name="generate_activities"/>
</xsl:when>
<xsl:otherwise>
<fo:inline xsl:use-attribute-sets="errortext">XXXXXX</fo:inline>
<xsl:call-template name="displayErrorText">
<xsl:with-param name="string">WARNING: NO ACTIVITIES FOUND</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
@@ -442,7 +449,7 @@
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="count(//finding[@threatLevel = $threatLevel])"/>
$threatLevel])"/> </xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
@@ -454,11 +461,15 @@
<xsl:template match="todo">
<xsl:choose>
<xsl:when test="@desc">
<fo:inline xsl:use-attribute-sets="errortext">### TODO: <xsl:value-of select="@desc"
/> ###</fo:inline>
<xsl:call-template name="displayErrorText">
<xsl:with-param name="string">### TODO: <xsl:value-of select="@desc"/>
###</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<fo:inline xsl:use-attribute-sets="errortext">### TODO ###</fo:inline>
<xsl:call-template name="displayErrorText">
<xsl:with-param name="string">### TODO ###</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
@@ -493,13 +504,12 @@
</xsl:when>
<xsl:when
test="(self::contract_end_date or self::contract_start_date or self::generate_raterevisiondate or self::p_startdate or self::p_enddate) and normalize-space(.) = 'TBD'">
<!-- actual TBD, don't mess with it -->
<fo:text>TBD</fo:text>
</xsl:when>
<!-- actual TBD, don't mess with it --> TBD </xsl:when>
<xsl:when
test="(self::contract_end_date or self::contract_start_date or self::generate_raterevisiondate or self::p_startdate or self::p_enddate) and not(string($placeholderElement) castable as xs:date)">
<!-- pretty printing for date -->
<fo:inline xsl:use-attribute-sets="errortext">TBD</fo:inline>
<xsl:call-template name="displayErrorText">
<xsl:with-param name="string">TBD</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when
test="self::contract_period_unit and /contract/meta/scope/contract_type = 'single_engagement'">
@@ -583,13 +593,13 @@
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<fo:inline xsl:use-attribute-sets="errortext">[ <fo:inline
xsl:use-attribute-sets="bold">WARNING</fo:inline>: Cannot resolve
placeholder <fo:inline xsl:use-attribute-sets="bold"><xsl:value-of
select="name()"/></fo:inline> in <xsl:value-of select="base-uri()"/> -
<xsl:call-template name="getReason"><xsl:with-param
name="placeholderElement" select="$placeholderElement"
/></xsl:call-template> ]</fo:inline>
<xsl:call-template name="displayErrorText">
<xsl:with-param name="string">[ WARNING: Cannot resolve placeholder
<xsl:value-of select="name()"/> in <xsl:value-of select="base-uri()"/> -
<xsl:call-template name="getReason"><xsl:with-param
name="placeholderElement" select="$placeholderElement"
/></xsl:call-template> ]</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
@@ -597,10 +607,10 @@
<xsl:template name="getReason">
<xsl:param name="placeholderElement" select="."/>
<xsl:choose>
<xsl:when test="/$placeholderElement"> element <fo:inline xsl:use-attribute-sets="bold"
>"<xsl:value-of select="name($placeholderElement)"/>"</fo:inline>
(<xsl:call-template name="getXPath"><xsl:with-param name="element"
select="$placeholderElement"/></xsl:call-template>) is empty </xsl:when>
<xsl:when test="/$placeholderElement"> element "<xsl:value-of
select="name($placeholderElement)"/>" (<xsl:call-template name="getXPath"
><xsl:with-param name="element" select="$placeholderElement"
/></xsl:call-template>) is empty </xsl:when>
<xsl:otherwise> referenced element not found </xsl:otherwise>
</xsl:choose>
</xsl:template>
@@ -619,144 +629,6 @@
</xsl:for-each>
</xsl:template>
<xsl:template name="generate_activities_xslt">
<fo:list-block xsl:use-attribute-sets="list">
<xsl:for-each select="/contract/meta/work/activities/activity">
<fo:list-item>
<!-- insert a bullet -->
<fo:list-item-label end-indent="label-end()">
<fo:block>
<fo:inline>&#8226;</fo:inline>
</fo:block>
</fo:list-item-label>
<!-- list text -->
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</xsl:for-each>
</fo:list-block>
</xsl:template>
<xsl:function name="my:calculatePeriod">
<xsl:param name="enddate"/>
<xsl:param name="startdate"/>
<xsl:variable name="startYear" as="xs:integer" select="year-from-date($startdate)"/>
<xsl:variable name="startMonth" as="xs:integer" select="month-from-date($startdate)"/>
<xsl:variable name="startDay" as="xs:integer" select="day-from-date($startdate)"/>
<xsl:variable name="endYear" as="xs:integer" select="year-from-date($enddate)"/>
<xsl:variable name="endMonth" as="xs:integer" select="month-from-date($enddate)"/>
<xsl:variable name="endDay" as="xs:integer" select="day-from-date($enddate)"/>
<xsl:variable name="startMonthNumberOfDays">
<xsl:choose>
<xsl:when test="xs:string($startMonth) = '1'">31</xsl:when>
<xsl:when test="xs:string($startMonth) = '2'">
<!-- I hate february -->
<xsl:choose>
<xsl:when test="$startYear mod 4 != 0">28</xsl:when>
<xsl:when test="$startYear mod 100 != 0">29</xsl:when>
<xsl:when test="$startYear mod 400 != 0">28</xsl:when>
<xsl:otherwise>29</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="xs:string($startMonth) = '3'">31</xsl:when>
<xsl:when test="xs:string($startMonth) = '4'">30</xsl:when>
<xsl:when test="xs:string($startMonth) = '5'">31</xsl:when>
<xsl:when test="xs:string($startMonth) = '6'">30</xsl:when>
<xsl:when test="xs:string($startMonth) = '7'">31</xsl:when>
<xsl:when test="xs:string($startMonth) = '8'">31</xsl:when>
<xsl:when test="xs:string($startMonth) = '9'">30</xsl:when>
<xsl:when test="xs:string($startMonth) = '10'">31</xsl:when>
<xsl:when test="xs:string($startMonth) = '11'">30</xsl:when>
<xsl:when test="xs:string($startMonth) = '12'">31</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="numYears">
<xsl:choose>
<xsl:when test="$endMonth > $startMonth">
<xsl:sequence select="$endYear - $startYear"/>
</xsl:when>
<xsl:when test="$endMonth &lt; $startMonth">
<xsl:sequence select="$endYear - $startYear - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$endDay >= $startDay">
<xsl:sequence select="$endYear - $startYear"/>
</xsl:when>
<xsl:otherwise>
<!-- $endDay &lt; $startDay -->
<xsl:sequence select="$endYear - $startYear - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="numMonths">
<xsl:choose>
<xsl:when test="$endDay &lt; $startDay">
<xsl:sequence select="$endMonth - $startMonth - 1"/>
</xsl:when>
<xsl:otherwise>
<!-- $endDay >= $startDay -->
<xsl:sequence select="$endMonth - $startMonth"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="numDays">
<!--<xsl:choose>
<xsl:when test="$numMonths &lt; 1 and $numYears &lt; 1">
<!-\- only displaying days if contract is for less than a month -\->
<xsl:sequence select="($enddate - $startdate) div xs:dayTimeDuration('P1D')"/>
</xsl:when>
<xsl:otherwise>
<!-\- if contract is longer than a month, don't count days -\->
<xsl:sequence select="0"/>
</xsl:otherwise>
</xsl:choose>-->
<xsl:choose>
<xsl:when test="$endDay - $startDay &lt; 0">
<xsl:value-of select="$startMonthNumberOfDays - $startDay + $endDay"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$endDay - $startDay"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$numYears > 0">
<xsl:sequence select="$numYears"/>
<xsl:text>year</xsl:text>
<xsl:if test="$numYears > 1">
<xsl:text>s</xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when
test="($numMonths > 0 and $numDays = 0) or ($numMonths = 0 and $numDays > 0)">
<xsl:text> and</xsl:text>
</xsl:when>
<xsl:when test="$numMonths > 0 and $numDays > 0">
<xsl:text>,</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:if>
<xsl:if test="$numMonths > 0">
<xsl:sequence select="$numMonths"/>
<xsl:text>month</xsl:text>
<xsl:if test="$numMonths > 1">
<xsl:text>s</xsl:text>
</xsl:if>
<xsl:if test="$numDays > 0">
<xsl:text> and</xsl:text>
</xsl:if>
</xsl:if>
<xsl:if test="$numDays > 0">
<xsl:sequence select="$numDays"/>
<xsl:text>day</xsl:text>
<xsl:if test="$numDays > 1">
<xsl:text>s</xsl:text>
</xsl:if>
</xsl:if>
</xsl:function>
</xsl:stylesheet>

View File

@@ -10,12 +10,10 @@
<xsl:choose>
<xsl:when
test="img | generate_piechart | p | div | table | section | ol | ul | pre">
<fo:block xsl:use-attribute-sets="censoredblock">
<xsl:call-template name="checkIfLast"/>
<xsl:text>[ CENSORED ]</xsl:text></fo:block>
<xsl:call-template name="censoredBlock"/>
</xsl:when>
<xsl:otherwise>
<fo:inline xsl:use-attribute-sets="censoredtext">[ CENSORED ]</fo:inline>
<xsl:call-template name="censoredInline"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
@@ -24,5 +22,7 @@
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View File

@@ -4,15 +4,7 @@
xmlns:fo="http://www.w3.org/1999/XSL/Format" version="2.0">
<!-- color scheme, just change these to change colors throughout the suite -->
<xsl:variable name="c_main">#e2632a</xsl:variable>
<xsl:variable name="c_support_light">#ededed</xsl:variable>
<xsl:variable name="c_support_subtlydarkerlight">#e4e4e4</xsl:variable><!-- used for subtle light border around support_light background -->
<xsl:variable name="c_support_medium">#999999</xsl:variable><!-- used for subtle light border around support_light background -->
<xsl:variable name="c_support_dark">#444444</xsl:variable>
<xsl:variable name="c_main_contrast">white</xsl:variable>
<xsl:variable name="border-color">#444444</xsl:variable>
<!-- Note: pie chart colors can be customized in functions_params_vars.xslt -->
<!-- variables -->

View File

@@ -8,13 +8,13 @@
<!-- Retest status colors -->
<xsl:attribute-set name="status-new"><!-- also used by unresolved -->
<xsl:attribute name="color">#CC4900</xsl:attribute>
<xsl:attribute name="color"><xsl:value-of select="$color_new"/></xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="status-resolved">
<xsl:attribute name="color">#b7aa5b</xsl:attribute>
<xsl:attribute name="color"><xsl:value-of select="$color_resolved"/></xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="status-not_retested">
<xsl:attribute name="color">#FE9920</xsl:attribute>
<xsl:attribute name="color"><xsl:value-of select="$color_notretested"/></xsl:attribute>
</xsl:attribute-set>
<!-- Text -->