summaryrefslogtreecommitdiff
path: root/tools/regression/xsl_reports/xsl/common.xsl
blob: 0029eeaebba4f53b9a878b85dfe8456cc2b8dbde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?xml version="1.0" encoding="utf-8"?>
<!--

Copyright MetaCommunications, Inc. 2003-2004.

Distributed under the Boost Software License, Version 1.0. (See
accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)

-->

<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exsl="http://exslt.org/common"
    xmlns:func="http://exslt.org/functions"
    xmlns:str="http://exslt.org/strings"
    xmlns:meta="http://www.meta-comm.com"
    extension-element-prefixes="func"
    version="1.0">

    <xsl:variable name="output_directory" select="'output'"/>

    <xsl:template name="get_toolsets">
    <xsl:param name="toolsets"/>
    <xsl:param name="required-toolsets"/>

    <xsl:variable name="toolset_output">
        <xsl:for-each select="$toolsets">
        <xsl:variable name="toolset" select="."/>
        <xsl:element name="toolset">
            <xsl:attribute name="toolset"><xsl:value-of select="$toolset"/></xsl:attribute>
            <xsl:choose>
            <xsl:when test="$required_toolsets[ $toolset = @name ]">
                <xsl:attribute name="required">yes</xsl:attribute>
                <xsl:attribute name="sort">a</xsl:attribute>
            </xsl:when>
            <xsl:otherwise>
                <xsl:attribute name="required">no</xsl:attribute>
                <xsl:attribute name="sort">z</xsl:attribute>
            </xsl:otherwise>
            </xsl:choose>
        </xsl:element>
        </xsl:for-each>
    </xsl:variable>

    <xsl:for-each select="exsl:node-set( $toolset_output )/toolset">
        <xsl:sort select="concat( @sort, ' ', @toolset)" order="ascending"/>
        <xsl:copy-of select="."/>
    </xsl:for-each>

    </xsl:template>

  <func:function name="meta:show_output">
      <xsl:param name="explicit_markup"/>     
      <xsl:param name="test_log"/>     
      <func:result select="$test_log/@result != 'success' and not( meta:is_unusable( $explicit_markup, $test_log/@library, $test_log/@toolset )) or $test_log/@show-run-output = 'true'"/>
  </func:function>

    <func:function name="meta:is_test_log_a_test_case">
        <xsl:param name="test_log"/>      
        <func:result select="$test_log/@test-type='compile' or $test_log/@test-type='compile_fail' or $test_log/@test-type='run' or $test_log/@test-type='run_pyd'"/>
    </func:function>

    <func:function name="meta:is_unusable">
        <xsl:param name="explicit_markup"/>
        <xsl:param name="library"/>
        <xsl:param name="toolset"/>
        
        <func:result select="$explicit_markup//library[ @name = $library ]/mark-unusable[ toolset/@name = $toolset or toolset/@name='*' ]"/>
    </func:function>

    <func:function name="meta:re_match">
        <xsl:param name="pattern"/>
        <xsl:param name="text"/>
        
        <xsl:choose>
            <xsl:when test="not( contains( $pattern, '*' ) )">
                <func:result select="$text = $pattern"/>
            </xsl:when>
            <xsl:when test="$pattern = '*'">
                <func:result select="1 = 1"/>
            </xsl:when>
            <xsl:when test="substring( $pattern, 1, 1 ) = '*' and substring( $pattern, string-length($pattern), 1 ) = '*' ">
                <func:result select="contains( $text, substring( $pattern, 2, string-length($pattern) - 2 ) ) "/>
            </xsl:when>
            <xsl:when test="substring( $pattern, 1, 1 ) = '*'">
                <xsl:variable name="pattern_tail" select="substring( $pattern, 2, string-length($pattern) - 1 )"/>
                <func:result select="substring( $text, string-length($text) - string-length($pattern_tail) + 1, string-length($pattern_tail) ) = $pattern_tail"/>
            </xsl:when>
            <xsl:when test="substring( $pattern, string-length($pattern), 1 ) = '*' ">
                <xsl:variable name="pattern_head" select="substring( $pattern, 1, string-length($pattern) - 2 )"/>
                <func:result select="substring( $text, 1, string-length($pattern_head) ) = $pattern_head "/>
            </xsl:when>
        </xsl:choose>
    </func:function>

    <func:function name="meta:encode_path">
        <xsl:param name="path"/>
        <func:result select="translate( translate( $path, '/', '-' ), './', '-' )"/>
    </func:function>

    <func:function name="meta:toolset_name">
        <xsl:param name="name"/>
        <func:result select="$name"/>
    </func:function>

    <func:function name="meta:output_file_path">
        <xsl:param name="path"/>
        <func:result select="concat( $output_directory, '/', meta:encode_path( $path ), '.html' )"/>
    </func:function>

    <xsl:template name="show_notes">
        <xsl:param name="explicit_markup"/>
        <xsl:param name="notes"/>
        <div class="notes">
            <xsl:for-each select="$notes">
            <div>
                <xsl:variable name="refid" select="@refid"/>
                <xsl:call-template name="show_note">
                    <xsl:with-param name="note" select="."/>
                    <xsl:with-param name="reference" select="$explicit_markup//note[ $refid = @id ]"/>
                </xsl:call-template>
            </div>
            </xsl:for-each>
        </div>
    </xsl:template>

    <xsl:template name="show_note">
        <xsl:param name="note"/>
        <xsl:param name="reference"/>
        <div class="note">
            <xsl:variable name="author">
                <xsl:choose>
                    <xsl:when test="$note/@author">
                        <xsl:value-of select="$note/@author"/>
                    </xsl:when>
                    <xsl:when test="$reference">
                        <xsl:value-of select="$reference/@author"/>                               
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:text/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>

            <xsl:variable name="date">
                <xsl:choose>
                    <xsl:when test="$note/@date">
                        <xsl:value-of select="$note/@date"/>
                    </xsl:when>
                    <xsl:when test="$reference">
                        <xsl:value-of select="$reference/@date"/>                      
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:text/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>

        <span class="note-header">
            <xsl:choose>
                <xsl:when test="$author != '' and $date != ''">
                    [&#160;<xsl:value-of select="$author"/>&#160;<xsl:value-of select="$date"/>&#160;]
                </xsl:when>
                <xsl:when test="$author != ''">
                    [&#160;<xsl:value-of select="$author"/>&#160;]                        
                </xsl:when>
                <xsl:when test="$date != ''">
                    [&#160;<xsl:value-of select="$date"/>&#160;]                        
                </xsl:when>
            </xsl:choose>
        </span>

        <xsl:if test="$reference">
            <xsl:copy-of select="$reference/node()"/>                
        </xsl:if>
        <xsl:copy-of select="$note/node()"/>      

        </div>
    </xsl:template>

</xsl:stylesheet>