1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
2 | <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
---|
3 |
|
---|
4 |
|
---|
5 |
|
---|
6 | <!-- specify xhtml output -->
|
---|
7 | <xsl:output method="xml" encoding="utf-8" indent="yes" omit-xml-declaration="yes"/>
|
---|
8 |
|
---|
9 | <!-- this is needed so that whitespace nodes
|
---|
10 | in page/*.xml are not seen as text-keys -->
|
---|
11 | <xsl:strip-space elements="*"/>
|
---|
12 |
|
---|
13 |
|
---|
14 | <xsl:template match="/">
|
---|
15 | <html>
|
---|
16 | <head>
|
---|
17 | <title>Error Report</title>
|
---|
18 | <style>.attribute-title{ min-width: 200px; }</style>
|
---|
19 | </head>
|
---|
20 | <body>
|
---|
21 | <span style="position:absolute;">Test Date:</span> <span style="margin-left: 150px;"><xsl:value-of select="/test/@time"/></span><br/>
|
---|
22 | <span style="position:absolute;">Test Passed:</span> <span style="margin-left: 150px;"><xsl:value-of select="/test/@passed"/></span><br/>
|
---|
23 | <span style="position:absolute;">SVN info:</span> <pre style="margin-left: 150px;"><xsl:value-of select="/test/svn-info"/></pre><br/>
|
---|
24 |
|
---|
25 | <xsl:if test="/test/@passed='no'">
|
---|
26 |
|
---|
27 | <span style="position: absolute;">Errors:</span> <span style="margin-left: 150px;"><xsl:value-of select="/test/@errors"/></span><br/>
|
---|
28 | <xsl:for-each select="/test/error">
|
---|
29 | <div style="border: 1px solid black;padding:0;margin:10px;background-color: #ffd;">
|
---|
30 | <h2 style="padding:0; margin:5px; font-weight:bold; font-size: 14pt;">Error</h2>
|
---|
31 | <h6 style="padding:0; margin:5px; font-weight: normal; font-size: 12pt;">Location:</h6>
|
---|
32 | <pre style="padding:5px; margin:0; margin-left:30px;">
|
---|
33 | <xsl:for-each select="location/node"><xsl:if test="position() > 1"> at </xsl:if><xsl:value-of select="normalize-space(.)"/><xsl:if test="position() < last()"><br/></xsl:if></xsl:for-each></pre>
|
---|
34 |
|
---|
35 | <xsl:variable name="error-message">
|
---|
36 | <xsl:call-template name="substitute">
|
---|
37 | <xsl:with-param name="string"><xsl:value-of select="message"/></xsl:with-param>
|
---|
38 | </xsl:call-template>
|
---|
39 | </xsl:variable>
|
---|
40 | <br/>
|
---|
41 | <h6 style="padding:0; margin:5px; font-weight: normal; font-size: 12pt;">Error Message:</h6>
|
---|
42 | <pre style="padding:10px; margin:0; margin-left:30px;"><xsl:value-of disable-output-escaping="yes" select="normalize-space($error-message)"/></pre>
|
---|
43 | </div>
|
---|
44 | </xsl:for-each>
|
---|
45 | </xsl:if>
|
---|
46 | </body>
|
---|
47 | </html>
|
---|
48 | </xsl:template>
|
---|
49 |
|
---|
50 | <xsl:template name="substitute">
|
---|
51 | <xsl:param name="string" />
|
---|
52 | <xsl:param name="from" select="'
'" />
|
---|
53 | <xsl:param name="to"><br/></xsl:param>
|
---|
54 | <xsl:choose>
|
---|
55 | <xsl:when test="contains($string, $from)">
|
---|
56 | <xsl:value-of select="substring-before($string, $from)" />
|
---|
57 | <xsl:copy-of select="$to" />
|
---|
58 | <xsl:call-template name="substitute">
|
---|
59 | <xsl:with-param name="string"
|
---|
60 | select="substring-after($string, $from)" />
|
---|
61 | <xsl:with-param name="from" select="$from" />
|
---|
62 | <xsl:with-param name="to" select="$to" />
|
---|
63 | </xsl:call-template>
|
---|
64 | </xsl:when>
|
---|
65 | <xsl:otherwise>
|
---|
66 | <xsl:value-of select="$string" />
|
---|
67 | </xsl:otherwise>
|
---|
68 | </xsl:choose>
|
---|
69 | </xsl:template>
|
---|
70 |
|
---|
71 | <!-- copy xhtml tags directly, except when certain special tags are seen -->
|
---|
72 | <xsl:template name="traverse">
|
---|
73 | <xsl:param name="root" select="/"/>
|
---|
74 |
|
---|
75 | <xsl:for-each select="node()">
|
---|
76 |
|
---|
77 | <xsl:choose>
|
---|
78 |
|
---|
79 | <!-- if a text node -->
|
---|
80 | <xsl:when test="self::text()">
|
---|
81 | <xsl:value-of select="."/>
|
---|
82 | </xsl:when>
|
---|
83 |
|
---|
84 | <!-- if a normal node -->
|
---|
85 | <xsl:when test="self::*">
|
---|
86 | <xsl:if test="not( @succeeded='yes' )">
|
---|
87 | <xsl:variable name="element-name" select="name()"/>
|
---|
88 | <xsl:element name="{$element-name}">
|
---|
89 | <xsl:for-each select="@*">
|
---|
90 | <xsl:variable name="attribute-name" select="name()"/>
|
---|
91 | <xsl:attribute name="{$attribute-name}"><xsl:value-of select="."/></xsl:attribute>
|
---|
92 | </xsl:for-each>
|
---|
93 | <xsl:call-template name="traverse"><xsl:with-param name="root" select="."/></xsl:call-template>
|
---|
94 | </xsl:element>
|
---|
95 | </xsl:if>
|
---|
96 |
|
---|
97 | </xsl:when>
|
---|
98 | </xsl:choose>
|
---|
99 | </xsl:for-each>
|
---|
100 | </xsl:template>
|
---|
101 | </xsl:stylesheet>
|
---|