Merge lp:~zorba-coders/zorba/fix_schema_resolution into lp:zorba

Proposed by Sorin Marian Nasoi
Status: Merged
Approved by: Chris Hillery
Approved revision: 11147
Merged at revision: 11232
Proposed branch: lp:~zorba-coders/zorba/fix_schema_resolution
Merge into: lp:zorba
Diff against target: 206 lines (+73/-42)
4 files modified
test/fots/CMakeLists.txt (+0/-3)
test/fots_driver/environment.xq (+50/-28)
test/fots_driver/feedback.xq (+4/-6)
test/fots_driver/fots-driver.xq (+19/-5)
To merge this branch: bzr merge lp:~zorba-coders/zorba/fix_schema_resolution
Reviewer Review Type Date Requested Status
Chris Hillery Approve
Sorin Marian Nasoi Approve
Review via email: mp+147752@code.launchpad.net

Commit message

- replaced the resolver with mapper for the schema resolution
- fixed test cases 'qischema032', 'qischema032a', 'qischema032b'

Description of the change

- replaced the resolver with mapper for the schema resolution
- fixed test cases 'qischema032', 'qischema032a', 'qischema032b'

To post a comment you must log in.
Revision history for this message
Sorin Marian Nasoi (sorin.marian.nasoi) :
review: Approve
Revision history for this message
Chris Hillery (ceejatec) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job fix_schema_resolution-2013-02-12T02-05-51.123Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'test/fots/CMakeLists.txt'
2--- test/fots/CMakeLists.txt 2013-02-10 09:16:28 +0000
3+++ test/fots/CMakeLists.txt 2013-02-11 19:52:31 +0000
4@@ -1041,9 +1041,6 @@
5 EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema005 0)
6 EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema016 0)
7 EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema031 0)
8-EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema032 0)
9-EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema032a 0)
10-EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema032b 0)
11 EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema032c 0)
12 EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema040 0)
13 EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema040a 0)
14
15=== modified file 'test/fots_driver/environment.xq'
16--- test/fots_driver/environment.xq 2013-02-04 16:48:16 +0000
17+++ test/fots_driver/environment.xq 2013-02-11 19:52:31 +0000
18@@ -365,7 +365,7 @@
19 "variable $contextItemQuery := xqxq:prepare-main-module('",
20 env:get-schema-import($env),
21 concat('validate { doc("', $ciURI, '")', "}',", " "),
22- "resolver:url-resolver#2, ());",
23+ "(), mapper:uri-mapper#2);",
24 "variable $contextItem := xqxq:evaluate($contextItemQuery);")
25 ,"
")
26 };
27@@ -464,37 +464,14 @@
28 $testSetBaseURI as xs:anyURI
29 ) as xs:string?
30 {
31- let $envSchema := $env/fots:schema,
32- $tcSchema := $case/fots:environment/fots:schema,
33- $schemas := ($envSchema, $tcSchema),
34- $modules := $case/fots:module,
35- $resources := ($env/fots:resource, $case/fots:environment/fots:schema)
36+ let $modules := $case/fots:module
37+ let $resources := $env/fots:resource
38 return
39- if (empty($schemas) and empty($modules) and empty($resources))
40+ if (empty($modules) and empty($resources))
41 then ()
42 else string-join(
43- ("declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';",
44- $env:hof,
45- "declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {",
46+ ("declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {",
47 "switch($entity)",
48- if (exists($schemas))
49- then string-join(("case 'schema'",
50- " return switch($namespace)",
51- (for $schema in $envSchema
52- return concat(" case '",
53- data($schema/@uri),
54- "' return doc('",
55- resolve-uri($schema/@file, $envBaseURI),
56- "')"),
57- for $schema in $tcSchema
58- return concat(" case '",
59- data($schema/@uri),
60- "' return doc('",
61- resolve-uri($schema/@file, $testSetBaseURI),
62- "')")),
63- " default return ()"),
64- "
")
65- else (),
66 if (exists($modules))
67 then string-join(("case 'module'",
68 " return switch($namespace)",
69@@ -530,6 +507,51 @@
70 "
")
71 };
72
73+(:~
74+ : Returns the XQXQ URL mapper declaration.
75+ : @param $case the test case.
76+ : @param $env the environment.
77+ : @param $envBaseURI URI of the environment.
78+ : @param $testSetBaseURI URI to the test set that defines the test case.
79+ : @return the XQXQ URL mapper declaration.
80+ :)
81+declare function env:mapper(
82+ $case as element(fots:test-case),
83+ $env as element(fots:environment)?,
84+ $envBaseURI as xs:anyURI?,
85+ $testSetBaseURI as xs:anyURI
86+) as xs:string?
87+{
88+ let $envSchema := $env/fots:schema,
89+ $tcSchema := $case/fots:environment/fots:schema,
90+ $schemas := ($envSchema, $tcSchema)
91+ return
92+ if (empty($schemas))
93+ then ()
94+ else string-join(
95+ ("declare function mapper:uri-mapper($namespace as xs:string, $entity as xs:string) {",
96+ "switch($entity)",
97+ if (exists($schemas))
98+ then string-join(("case 'schema'",
99+ " return switch($namespace)",
100+ (for $schema in $envSchema
101+ return concat(" case '",
102+ data($schema/@uri),
103+ "' return '",
104+ resolve-uri($schema/@file, $envBaseURI),
105+ "'"),
106+ for $schema in $tcSchema
107+ return concat(" case '",
108+ data($schema/@uri),
109+ "' return '",
110+ resolve-uri($schema/@file, $testSetBaseURI),
111+ "'"),
112+ " default return ()")),
113+ "
")
114+ else (),
115+ "default return ()","};"),
116+ "
")
117+};
118
119 (:~
120 : Checks that a set of dependencies (associated with some test-set or test-case)
121
122=== modified file 'test/fots_driver/feedback.xq'
123--- test/fots_driver/feedback.xq 2013-02-09 12:51:32 +0000
124+++ test/fots_driver/feedback.xq 2013-02-11 19:52:31 +0000
125@@ -176,8 +176,7 @@
126 }
127 }
128 else <fots:test-case name="{data($case/@name)}"
129- result="{$status}"
130- executionTime="{$duration}" />
131+ result="{$status}"/>
132 };
133
134
135@@ -212,6 +211,7 @@
136 if ($expectedFailure)
137 then insert node attribute comment{$info} as last into $case
138 else (),
139+ insert node attribute executionTime{$duration} as last into $case,
140 insert node
141 <fots:info>
142 {$env}
143@@ -231,12 +231,10 @@
144 else if ($expectedFailure)
145 then <fots:test-case name="{data($case/@name)}"
146 result="{$status}"
147- comment="{$info}"
148- executionTime="{$duration}"/>
149+ comment="{$info}"/>
150
151 else <fots:test-case name="{data($case/@name)}"
152- result="{$status}"
153- executionTime="{$duration}"/>
154+ result="{$status}"/>
155 };
156
157
158
159=== modified file 'test/fots_driver/fots-driver.xq'
160--- test/fots_driver/fots-driver.xq 2013-01-31 18:06:16 +0000
161+++ test/fots_driver/fots-driver.xq 2013-02-11 19:52:31 +0000
162@@ -752,16 +752,26 @@
163 $env,
164 $envBaseURI,
165 $testSetBaseURI)
166+ let $mapper as xs:string? := env:mapper($case,
167+ $env,
168+ $envBaseURI,
169+ $testSetBaseURI)
170 return
171 string-join
172 (
173 (
174 "",
175 "import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';",
176- "",
177 if (exists($resolver))
178- then ($resolver, "")
179- else (),
180+ then "declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';"
181+ else (),
182+ if (exists($mapper))
183+ then "declare namespace mapper = 'http://www.zorba-xquery.com/modules/xqxq/uri-mapper';"
184+ else (),
185+ if (exists($resolver) or exists($mapper)) then $env:hof else (),
186+ "",
187+ if (exists($resolver)) then ($resolver, "") else (),
188+ if (exists($mapper)) then ($mapper, "") else (),
189
190 concat("variable $queryID := xqxq:prepare-main-module(",
191 "&#xA;",
192@@ -772,8 +782,12 @@
193 "'",
194 "&#xA;",
195 if (exists($resolver))
196- then ", resolver:url-resolver#2, ());"
197- else ");"),
198+ then if(exists($mapper))
199+ then ", resolver:url-resolver#2, mapper:uri-mapper#2);"
200+ else ", resolver:url-resolver#2, ());"
201+ else if(exists($mapper))
202+ then ", (), mapper:uri-mapper#2);"
203+ else");"),
204
205 env:set-context-item($env, $envBaseURI),
206 env:set-context-item($case/fots:environment, $testSetBaseURI),

Subscribers

People subscribed via source and target branches