Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Updated from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | toXPath
Files: files | file ages | folders
SHA1: 697274d2320406a83a53b07a9a3476cf674b9f74
User & Date: rolf 2013-09-20 21:18:52
Context
2013-09-20
23:35
More tests. Minimal documentation. Closed-Leaf check-in: 9da0732eb4 user: rolf tags: toXPath
21:18
Updated from trunk. check-in: 697274d232 user: rolf tags: toXPath
21:17
xslt.tcl better usable for memory debugging. check-in: 5bb0267890 user: rolf tags: trunk
2013-09-06
22:44
Added new option -legacy to the domNode cmd error msg text. check-in: e799d2e8c5 user: rolf tags: toXPath
Changes

Changes to apps/xslt.tcl.

113
114
115
116
117
118
119


        puts [$resultDoc asText]
    }
    default {
        puts stderr "Unknown output method '$outputOpt'!"
        exit 1
    }
}









>
>
113
114
115
116
117
118
119
120
121
        puts [$resultDoc asText]
    }
    default {
        puts stderr "Unknown output method '$outputOpt'!"
        exit 1
    }
}

proc exit args {}

Changes to generic/domxslt.c.

3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
....
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
                                       Tcl_DStringValue (&dStr));
                Tcl_DStringFree (&dStr);

                if (h) {
                    for (tpl = (xsltTemplate *) Tcl_GetHashValue (h);
                         tpl != NULL;
                         tpl = tpl->next) {
                        if (tpl->precedence > xs->currentTplRule->precedence
                            || tpl == xs->currentTplRule) continue;
                        TRACE3("find element tpl match='%s' mode='%s' name='%s'\n",
                               tpl->match, tpl->mode, tpl->name);
                        TRACE4("tpl has prio='%f' precedence='%f'\n", tpl->prio, tpl->precedence, currentPrio, currentPrec);
                        rc = xpathMatches ( tpl->ast, actionNode, currentNode,
                                            &(xs->cbs), errMsg);
                        if (rc < 0) {
                            TRACE1("xpathMatches had errors '%s' \n", *errMsg);
                            return rc;
................................................................................
                        break;
                    }
                }
            }

            TRACE2("apply-imports: current template precedence='%f' mode='%s'\n", xs->currentTplRule->precedence, xs->currentTplRule->mode);
            for (tpl = xs->templates; tpl != NULL; tpl = tpl->next) {
                TRACE4("find tpl match='%s' mode='%s' modeURI='%s' name='%s'\n",
                       tpl->match, tpl->mode, tpl->modeURI, tpl->name);
                /* exclude those, which don't match the current mode
                   and the currentTplRule */
                if (   ( mode && !tpl->mode)
                       || (!mode &&  tpl->mode)
                       || ( mode &&  tpl->mode && (strcmp(mode,tpl->mode)!=0))
                       || (!modeURI && tpl->modeURI)







|

|







 







|







3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
....
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
                                       Tcl_DStringValue (&dStr));
                Tcl_DStringFree (&dStr);

                if (h) {
                    for (tpl = (xsltTemplate *) Tcl_GetHashValue (h);
                         tpl != NULL;
                         tpl = tpl->next) {
                        if (tpl->precedence >= xs->currentTplRule->precedence
                            || tpl == xs->currentTplRule) continue;
                        TRACE3("testing element tpl match='%s' mode='%s' name='%s'\n",
                               tpl->match, tpl->mode, tpl->name);
                        TRACE4("tpl has prio='%f' precedence='%f'\n", tpl->prio, tpl->precedence, currentPrio, currentPrec);
                        rc = xpathMatches ( tpl->ast, actionNode, currentNode,
                                            &(xs->cbs), errMsg);
                        if (rc < 0) {
                            TRACE1("xpathMatches had errors '%s' \n", *errMsg);
                            return rc;
................................................................................
                        break;
                    }
                }
            }

            TRACE2("apply-imports: current template precedence='%f' mode='%s'\n", xs->currentTplRule->precedence, xs->currentTplRule->mode);
            for (tpl = xs->templates; tpl != NULL; tpl = tpl->next) {
                TRACE4("testing tpl match='%s' mode='%s' modeURI='%s' name='%s'\n",
                       tpl->match, tpl->mode, tpl->modeURI, tpl->name);
                /* exclude those, which don't match the current mode
                   and the currentTplRule */
                if (   ( mode && !tpl->mode)
                       || (!mode &&  tpl->mode)
                       || ( mode &&  tpl->mode && (strcmp(mode,tpl->mode)!=0))
                       || (!modeURI && tpl->modeURI)

Added tests/OASIS-suite.tcl.



































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241

# Helper script to run xslt 1.0 conformance test suite created by the
# OASIS XSLT / XPath Conformance Technical Committee. 

package require tdom

# The following is not needed, given, that tDOM is correctly
# installed. This code only ensures, that the tDOM script library gets
# sourced, if the script is called with a tcldomsh out of the build
# dir of a complete tDOM source installation.
if {[lsearch [namespace children] ::tDOM] == -1} {
    # tcldomsh without the script library. Source the lib.
    source [file join [file dir [info script]] ../lib tdom.tcl]
}

# Import the tDOM helper procs
namespace import tDOM::*

set catalogfile ""
set skip [list]
set match [list]
set matchgroup [list]
set matchfile [list]

proc putsUsage {{channel stderr}} {
    puts $channel "usage: $argv0 ?options? path/to/catalog.xml"
}

proc processArgs {argc argv} {
    global catalogfile
    global skip
    global match
    global matchgroup
    global matchfile

    if {$argc == 0 || $argc % 2 == 0} {
        putsUsage
        exit 1
    }
    
    foreach {option value} $argv {
        if {$value eq ""} {
            break
        }
        switch $option {
            "-match" {
                set match $value
            }
            "-matchgroup" {
                set matchgroup $value
            }
            "-matchfile" {
                set matchfile $value
            }
            "-skip" {
                set skip $value
            }
            default {
                puts stderr "Unknown option \"$option\""
                putsUsage
                exit 1
            }
        }
    }
    set catalogfile [lindex $argv end]
}

set compareOK 0
set compareDIFF 0

# This is the callback proc for xslt:message elements. This proc is
# called once every time an xslt:message element is encountered during
# processing the stylesheet. The callback proc simply sends the text
# message to stderr.
proc xsltmsgcmd {msg terminate} {
    puts stderr "xslt message: '$msg'"
}

proc readCatalog {catalogPath} {
    global catalogDir
    global infoset

    set fd [open $catalogPath]
    set doc [dom parse -channel $fd]
    close $fd
    set catalogDir [file dirname $catalogPath]
    set infosetxsl [file join $catalogDir .. TOOLS infoset.xsl]
    set infosetdoc [dom parse -keepEmpties [xmlReadFile $infosetxsl]]
    set infoset [$infosetdoc toXSLTcmd]
    return $doc
}

proc checkAgainstPattern {patternlist text} {
    foreach pattern $patternlist {
        if {[string match $pattern $text]} {
            return 1
        }
    }
    return 0
}

proc runFilepath {filepath} {
    global matchgroup

    if {![llength $matchgroup]} {
        return 1
    }
    return [checkAgainstPattern $matchgroup $filepath]
}

proc runXslfile {xslfile} {
    global matchfile

    if {![llength $matchfile]} {
        return 1
    }
    return [checkAgainstPattern $matchfile $xslfile]
}

proc runPurpose {purpose} {
    global match

    if {![llength $match]} {
        return 1
    }
    return [checkAgainstPattern $match $purpose]
}

proc skip {purpose} {
    global skip

    return [checkAgainstPattern $skip $purpose]
}

proc runTest {testcase} {
    global catalogDir
    global majorpath
    global infoset
    global compareOK
    global compareDIFF

    set filepath [$testcase selectNodes string(file-path)]
    if {![runFilepath $filepath]} {
        return
    }
    set scenario [$testcase selectNodes scenario]
    if {[llength $scenario] != 1 || [$scenario @operation] ne "standard"} {
        puts "Non-standard scenario!"
        puts [$testcase asXML]
        return
    }
    set xmlfile [$scenario selectNodes \
                     {string(input-file[@role="principal-data"])}]
    set xmlfile [file join $catalogDir $majorpath $filepath $xmlfile]
    set xslfile [$scenario selectNodes \
                     {string(input-file[@role="principal-stylesheet"])}]
    if {![runXslfile $xslfile]} {
        return
    }
    set xslfile [file join $catalogDir $majorpath $filepath $xslfile]
    set xmlout [$scenario selectNodes \
                    {string(output-file[@role="principal" and @compare="XML"])}]
    set xmloutfile ""
    if {$xmlout ne ""} {
        set xmloutfile [file join $catalogDir $majorpath "REF_OUT" $filepath \
                            $xmlout]
    }
    set purpose [$testcase selectNodes string(purpose)]
    if {![runPurpose $purpose]} {
        return
    }
    if {[skip $purpose]} {
        puts "Skipping $filepath: $purpose"
        return
    }
    set xmldoc [dom parse -baseurl [baseURL $xmlfile] \
                    -externalentitycommand extRefHandler \
                    -keepEmpties \
                    [xmlReadFile $xmlfile] ]
    dom setStoreLineColumn 1
    set xsltdoc [dom parse -baseurl [baseURL $xslfile] \
                       -externalentitycommand extRefHandler \
                       -keepEmpties \
                       [xmlReadFile $xslfile] ]
    dom setStoreLineColumn 0
    set resultDoc ""
    if {[catch {$xmldoc xslt -xsltmessagecmd xsltmsgcmd $xsltdoc resultDoc} \
             errMsg]} {
        puts stderr $errMsg
    }
    if {$xmloutfile ne "" && [llength [info commands $resultDoc]]} {
        if {![catch {
            set refdoc [dom parse -keepEmpties [xmlReadFile $xmloutfile]]
        } errMsg]} {
            set refinfosetdoc [$infoset $refdoc]
            set resultinfosetdoc [$infoset $resultDoc]
            if {[$refinfosetdoc asXML] ne [$resultinfosetdoc asXML]} {
                incr compareDIFF
                puts "Result and ref differ."
                puts "Ref:"
                puts [$refinfosetdoc asXML]
                puts "Result:"
                puts [$resultinfosetdoc asXML]
            } else {
                incr compareOK
            }
            $refinfosetdoc delete
            $resultinfosetdoc delete
        } else {
            puts "Unable to parse REF doc. Reason:\n$errMsg"
        }
    }
    $xmldoc delete
    $xsltdoc delete
    catch {$resultDoc delete}
}

proc runTests {catalogRoot} {
    global majorpath
    global compareOK
    global compareDIFF

    foreach testcatalog [$catalogRoot selectNodes test-catalog] {
        if {[$testcatalog @submitter] ne "Lotus"} {
            continue
        }
        set majorpath [$testcatalog selectNodes string(major-path)]
        foreach testcase [$testcatalog selectNodes test-case] {
            runTest $testcase
        }
        puts "Finished."
        puts "Compare OK: $compareOK"
        puts "Compare FAIL: $compareDIFF"
    }
}

processArgs $argc $argv
set catalogDoc [readCatalog $catalogfile]
runTests [$catalogDoc documentElement]

proc exit args {}