Sorin Marian Nasoi has proposed merging 
lp:~zorba-coders/zorba/fix_schema_resolution into lp:zorba.

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

Requested reviews:
  Sorin Marian Nasoi (sorin.marian.nasoi)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fix_schema_resolution/+merge/147752

- replaced the resolver with mapper for the schema resolution
- fixed test cases 'qischema032', 'qischema032a', 'qischema032b'
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix_schema_resolution/+merge/147752
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'test/fots/CMakeLists.txt'
--- test/fots/CMakeLists.txt	2013-02-10 09:16:28 +0000
+++ test/fots/CMakeLists.txt	2013-02-11 19:52:31 +0000
@@ -1041,9 +1041,6 @@
 EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema005 0)
 EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema016 0)
 EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema031 0)
-EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema032 0)
-EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema032a 0)
-EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema032b 0)
 EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema032c 0)
 EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema040 0)
 EXPECTED_FOTS_FAILURE (prod-SchemaImport qischema040a 0)

=== modified file 'test/fots_driver/environment.xq'
--- test/fots_driver/environment.xq	2013-02-04 16:48:16 +0000
+++ test/fots_driver/environment.xq	2013-02-11 19:52:31 +0000
@@ -365,7 +365,7 @@
      "variable $contextItemQuery := xqxq:prepare-main-module('",
      env:get-schema-import($env),
      concat('validate { doc("', $ciURI, '")', "}',", " "),
-           "resolver:url-resolver#2, ());",
+           "(), mapper:uri-mapper#2);",
            "variable $contextItem := xqxq:evaluate($contextItemQuery);")
    ,"
")
 };
@@ -464,37 +464,14 @@
   $testSetBaseURI as xs:anyURI
 ) as xs:string?
 {
-  let $envSchema := $env/fots:schema,
-      $tcSchema := $case/fots:environment/fots:schema,
-      $schemas := ($envSchema, $tcSchema),
-      $modules := $case/fots:module,
-      $resources := ($env/fots:resource, $case/fots:environment/fots:schema)
+  let $modules := $case/fots:module
+  let $resources := $env/fots:resource
   return
-    if (empty($schemas) and empty($modules) and empty($resources))
+    if (empty($modules) and empty($resources))
     then ()
     else string-join(
-            ("declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';",
-             $env:hof,
-            "declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {",
+            ("declare function resolver:url-resolver($namespace as xs:string, $entity as xs:string) {",
             "switch($entity)",
-    if (exists($schemas))
-    then string-join(("case 'schema'",
-                     "  return switch($namespace)",
-                    (for $schema in $envSchema
-                     return concat("    case '",
-                                  data($schema/@uri),
-                                   "' return doc('",
-                                   resolve-uri($schema/@file, $envBaseURI),
-                                   "')"),
-                      for $schema in $tcSchema
-                      return concat("    case '",
-                                   data($schema/@uri),
-                                   "' return doc('",
-                                   resolve-uri($schema/@file, $testSetBaseURI),
-                                   "')")),
-                      "    default return ()"),
-                      "
")
-    else (),
     if (exists($modules))
     then string-join(("case 'module'",
                       "  return switch($namespace)",
@@ -530,6 +507,51 @@
     "
")
 };
 
+(:~
+ : Returns the XQXQ URL mapper declaration.
+ : @param $case the test case.
+ : @param $env the environment.
+ : @param $envBaseURI URI of the environment.
+ : @param $testSetBaseURI URI to the test set that defines the test case.
+ : @return the XQXQ URL mapper declaration.
+ :)
+declare function env:mapper(
+  $case           as element(fots:test-case),
+  $env            as element(fots:environment)?,
+  $envBaseURI     as xs:anyURI?,
+  $testSetBaseURI as xs:anyURI
+) as xs:string?
+{
+  let $envSchema := $env/fots:schema,
+      $tcSchema := $case/fots:environment/fots:schema,
+      $schemas := ($envSchema, $tcSchema)
+  return
+    if (empty($schemas))
+    then ()
+    else string-join(
+            ("declare function mapper:uri-mapper($namespace as xs:string, $entity as xs:string) {",
+            "switch($entity)",
+    if (exists($schemas))
+    then string-join(("case 'schema'",
+                     "  return switch($namespace)",
+                    (for $schema in $envSchema
+                     return concat("    case '",
+                                   data($schema/@uri),
+                                   "' return '",
+                                   resolve-uri($schema/@file, $envBaseURI),
+                                   "'"),
+                      for $schema in $tcSchema
+                      return concat("    case '",
+                                   data($schema/@uri),
+                                   "' return '",
+                                   resolve-uri($schema/@file, $testSetBaseURI),
+                                   "'"),
+                      "    default return ()")),
+                      "
")
+    else (),
+    "default return ()","};"),
+    "
")
+};
 
 (:~
  : Checks that a set of dependencies (associated with some test-set or test-case)

=== modified file 'test/fots_driver/feedback.xq'
--- test/fots_driver/feedback.xq	2013-02-09 12:51:32 +0000
+++ test/fots_driver/feedback.xq	2013-02-11 19:52:31 +0000
@@ -176,8 +176,7 @@
     }
   }
   else <fots:test-case  name="{data($case/@name)}"
-                        result="{$status}"
-                        executionTime="{$duration}" />
+                        result="{$status}"/>
 };
 
 
@@ -212,6 +211,7 @@
        if ($expectedFailure)
        then insert node attribute comment{$info} as last into $case
        else (),
+       insert node attribute executionTime{$duration} as last into $case,
        insert node
          <fots:info>
            {$env}
@@ -231,12 +231,10 @@
   else if ($expectedFailure)
   then <fots:test-case name="{data($case/@name)}"
                        result="{$status}"
-                       comment="{$info}"
-                       executionTime="{$duration}"/>
+                       comment="{$info}"/>
  
   else <fots:test-case name="{data($case/@name)}"
-                       result="{$status}"
-                       executionTime="{$duration}"/>
+                       result="{$status}"/>
 };
 
 

=== modified file 'test/fots_driver/fots-driver.xq'
--- test/fots_driver/fots-driver.xq	2013-01-31 18:06:16 +0000
+++ test/fots_driver/fots-driver.xq	2013-02-11 19:52:31 +0000
@@ -752,16 +752,26 @@
                                               $env,
                                               $envBaseURI,
                                               $testSetBaseURI)
+  let $mapper as xs:string? := env:mapper($case,
+                                          $env,
+                                          $envBaseURI,
+                                          $testSetBaseURI)
   return
     string-join
     (
     (
     "",
     "import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';",
-    "",
     if (exists($resolver))
-    then ($resolver, "")
-    else (),
+    then "declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';"
+    else (),
+    if (exists($mapper))
+    then "declare namespace mapper = 'http://www.zorba-xquery.com/modules/xqxq/uri-mapper';"
+    else (),
+    if (exists($resolver) or exists($mapper)) then $env:hof else (),
+    "",
+    if (exists($resolver)) then ($resolver, "") else (),
+    if (exists($mapper)) then ($mapper, "") else (),
 
     concat("variable $queryID := xqxq:prepare-main-module(",
            "&#xA;",
@@ -772,8 +782,12 @@
            "'",
            "&#xA;",
            if (exists($resolver))
-           then ", resolver:url-resolver#2, ());"
-           else ");"),
+           then if(exists($mapper))
+                then ", resolver:url-resolver#2, mapper:uri-mapper#2);"
+                else ", resolver:url-resolver#2, ());"
+           else if(exists($mapper))
+                then ", (), mapper:uri-mapper#2);"
+                else");"),
 
     env:set-context-item($env, $envBaseURI),
     env:set-context-item($case/fots:environment, $testSetBaseURI),

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to