← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/fix_bug_1123842 into lp:zorba

 

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

Commit message:
Added DTD validation for the document that is bound to the context item in the cases where this is needed.
Because there is no Dependency for DTD validation inside the testsuite, FOTS driver needs to look for specific test case names.

Requested reviews:
  Sorin Marian Nasoi (sorin.marian.nasoi)
Related bugs:
  Bug #1123842 in Zorba: "FOTS: dtd support for fn:id and fn:idref failures (at least 33)"
  https://bugs.launchpad.net/zorba/+bug/1123842

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

Added DTD validation for the document that is bound to the context item in the cases where this is needed.
Because there is no Dependency for DTD validation inside the testsuite, FOTS driver needs to look for specific test case names.
-- 
https://code.launchpad.net/~zorba-coders/zorba/fix_bug_1123842/+merge/154671
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'test/fots/CMakeLists.txt'
--- test/fots/CMakeLists.txt	2013-03-20 22:49:58 +0000
+++ test/fots/CMakeLists.txt	2013-03-21 11:36:26 +0000
@@ -121,7 +121,6 @@
 EXPECTED_FOTS_FAILURE (app-CatalogCheck Catalog010 0)
 EXPECTED_FOTS_FAILURE (app-CatalogCheck Catalog011 0)
 EXPECTED_FOTS_FAILURE (app-CatalogCheck Catalog012 0)
-EXPECTED_FOTS_FAILURE (app-FunctxFunctx functx-functx-id-from-element-1 0)
 EXPECTED_FOTS_FAILURE (fn-adjust-date-to-timezone cbcl-adjust-date-to-timezone-002 0)
 EXPECTED_FOTS_FAILURE (fn-adjust-date-to-timezone cbcl-adjust-date-to-timezone-003 0)
 EXPECTED_FOTS_FAILURE (fn-adjust-dateTime-to-timezone cbcl-adjust-dateTime-to-timezone-001 0)
@@ -289,37 +288,6 @@
 EXPECTED_FOTS_FAILURE (fn-generate-id generate-id-015 0)
 EXPECTED_FOTS_FAILURE (fn-generate-id generate-id-017 0)
 EXPECTED_FOTS_FAILURE (fn-generate-id generate-id-018 0)
-EXPECTED_FOTS_FAILURE (fn-id fn-id-dtd-5 0)
-EXPECTED_FOTS_FAILURE (fn-id fn-id-dtd-7 0)
-EXPECTED_FOTS_FAILURE (fn-id fn-id-dtd-8 0)
-EXPECTED_FOTS_FAILURE (fn-id fn-id-dtd-9 0)
-EXPECTED_FOTS_FAILURE (fn-id fn-id-dtd-12 0)
-EXPECTED_FOTS_FAILURE (fn-id fn-id-dtd-13 0)
-EXPECTED_FOTS_FAILURE (fn-id fn-id-dtd-15 0)
-EXPECTED_FOTS_FAILURE (fn-id fn-id-dtd-16 0)
-EXPECTED_FOTS_FAILURE (fn-id fn-id-dtd-17 0)
-EXPECTED_FOTS_FAILURE (fn-id fn-id-dtd-18 0)
-EXPECTED_FOTS_FAILURE (fn-id fn-id-dtd-19 0)
-EXPECTED_FOTS_FAILURE (fn-id fn-id-dtd-20 0)
-EXPECTED_FOTS_FAILURE (fn-id fn-id-dtd-21 0)
-EXPECTED_FOTS_FAILURE (fn-id fn-id-dtd-23 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-5 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-7 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-8 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-9 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-12 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-13 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-14 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-15 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-16 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-17 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-18 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-19 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-20 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-21 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-23 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-24 0)
-EXPECTED_FOTS_FAILURE (fn-idref fn-idref-dtd-25 0)
 EXPECTED_FOTS_FAILURE (fn-iri-to-uri fn-iri-to-uri-18A 0)
 EXPECTED_FOTS_FAILURE (fn-last last-24 0)
 EXPECTED_FOTS_FAILURE (fn-matches cbcl-matches-038 1131304)

=== modified file 'test/fots_driver/environment.xq'
--- test/fots_driver/environment.xq	2013-03-12 21:04:04 +0000
+++ test/fots_driver/environment.xq	2013-03-21 11:36:26 +0000
@@ -389,11 +389,14 @@
  :             test case.
  : @param $envBaseURI The absolute pathname of the directory containing the
  :        file that defines the environment.
+ : @param $needsDTDValidation If true then the document that is bound as
+ :        context item needs to be DTD validated.
  : @return the string for setting the context item if needed.
  :)
 declare function env:set-context-item(
-  $env        as element(fots:environment)?,
-  $envBaseURI as xs:anyURI?
+  $env                as element(fots:environment)?,
+  $envBaseURI         as xs:anyURI?,
+  $needsDTDValidation as xs:boolean
 ) as xs:string?
 {
   if (exists($env/fots:source[@role = "."]))
@@ -401,7 +404,7 @@
     string-join
     (
     (
-    env:compute-context-item($env, $envBaseURI),
+    env:compute-context-item($env, $envBaseURI, $needsDTDValidation),
     "",
     'xqxq:bind-context-item($queryID, $contextItem);'
     )
@@ -414,15 +417,22 @@
 
 
 declare %private function env:compute-context-item(
-  $env        as element(fots:environment)?,
-  $envBaseURI as xs:anyURI?
+  $env                as element(fots:environment)?,
+  $envBaseURI         as xs:anyURI?,
+  $needsDTDValidation as xs:boolean
 ) as xs:string
 {
   let $ciURI := resolve-uri($env/fots:source[@role = "."]/@file, $envBaseURI)
   return
   if (empty($env/fots:source[@validation = "strict"]))
   then
-    concat('variable $contextItem := doc("', $ciURI, '");')
+  {
+    if($needsDTDValidation)
+    then concat('variable $contextItem := zorba-xml:parse(fn:unparsed-text("',
+                $ciURI,
+                '"),<opt:options><opt:DTD-validate/></opt:options> );')
+    else concat('variable $contextItem := doc("', $ciURI, '");')
+  }
   else 
     string-join
     (

=== modified file 'test/fots_driver/fots-driver.xq'
--- test/fots_driver/fots-driver.xq	2013-03-18 12:53:46 +0000
+++ test/fots_driver/fots-driver.xq	2013-03-21 11:36:26 +0000
@@ -690,6 +690,8 @@
 
           let $depMet := env:check-dependencies($testCase/fots:dependency,
                                                 $FOTSZorbaManifest)
+          (: the following 3 test sets contain some test cases that need DTD validation for the document bound as context item :)
+          let $mayNeedDTDValidation := exists(index-of(('fn-id', 'fn-idref', 'app-FunctxFunctx'), $testSetName))
 
           where empty($testCaseNames) or $testCaseNames[. eq $testCase/@name]
 
@@ -727,7 +729,8 @@
                           $testSetURI,
                           $verbose,
                           $expectedFailures//TestSet[@name eq $testSetName]/Test[@name eq $testCase/@name],
-                          $cliMode)
+                          $cliMode,
+                          $mayNeedDTDValidation)
             }
             else
             {
@@ -740,7 +743,8 @@
                           $testSetURI,
                           $verbose,
                           $expectedFailures//TestSet[@name eq $testSetName]/Test[@name eq $testCase/@name],
-                          $cliMode)
+                          $cliMode,
+                          $mayNeedDTDValidation)
             }
           }
         }
@@ -770,18 +774,21 @@
  :        about the test-case.
  : @param $expectedFailure the Test element from the ExpectedFailures.xml file.
  : @param $cliMode the cli command.
+ : @param $mayNeedDTDValidation true if the test case may need DTD validation
+ :        for the document boud as context item.
  : @return an XML tree containing info about the result of running the test case.
  :)
 declare %ann:sequential function driver:test(
-  $case               as element(fots:test-case),
-  $env                as element(fots:environment)?,
-  $envBaseURI         as xs:anyURI?,
-  $deps               as element(fots:dependency)*,
-  $testSetName        as xs:string?,
-  $testSetBaseURI     as xs:anyURI,
-  $verbose            as xs:boolean,
-  $expectedFailure    as element(Test)?,
-  $cliMode            as xs:string
+  $case                 as element(fots:test-case),
+  $env                  as element(fots:environment)?,
+  $envBaseURI           as xs:anyURI?,
+  $deps                 as element(fots:dependency)*,
+  $testSetName          as xs:string?,
+  $testSetBaseURI       as xs:anyURI,
+  $verbose              as xs:boolean,
+  $expectedFailure      as element(Test)?,
+  $cliMode              as xs:string,
+  $mayNeedDTDValidation as xs:boolean
 ) as element(fots:test-case)?
 {
 (:TODO Cover the "(:%VARDECL%:)"when there are tests in FOTS that use it:)
@@ -827,7 +834,8 @@
                                                     $case,
                                                     $env,
                                                     $envBaseURI,
-                                                    $testSetBaseURI);
+                                                    $testSetBaseURI,
+                                                    $mayNeedDTDValidation);
 
     (:if $verbose then print the query to a file:)
     if ($verbose and
@@ -895,14 +903,17 @@
  : @param $envBaseURI URI of the environment.
  : @param $testSetBaseURI the URI of the directory that contains the file of the
           associated test set.
+ : @param $mayNeedDTDValidation true if the test case may need DTD validation
+ :        for the document boud as context item.
  : @return the query that will be evaluated.
  :)
 declare %private function driver:create-XQXQ-query(
-  $queryText      as xs:string,
-  $case           as element(fots:test-case),
-  $env            as element(fots:environment)?,
-  $envBaseURI     as xs:anyURI?,
-  $testSetBaseURI as xs:anyURI
+  $queryText            as xs:string,
+  $case                 as element(fots:test-case),
+  $env                  as element(fots:environment)?,
+  $envBaseURI           as xs:anyURI?,
+  $testSetBaseURI       as xs:anyURI,
+  $mayNeedDTDValidation as xs:boolean
 ) as xs:string
 {
   let $resolver as xs:string? := env:resolver($case,
@@ -913,13 +924,23 @@
                                           $env,
                                           $envBaseURI,
                                           $testSetBaseURI)
+  let $needsDTDValidation := if (not($mayNeedDTDValidation))
+                             then $mayNeedDTDValidation
+                             else ((xs:string($case/@name) = 'functx-functx-id-from-element-1') or
+                                   starts-with(xs:string($case/@name), 'fn-id-dtd-') or
+                                   starts-with(xs:string($case/@name), 'fn-idref-dtd-'))
   return
     string-join
     (
     (
     "",
     "import module namespace xqxq = 'http://www.zorba-xquery.com/modules/xqxq';",
-
+    
+    if ($needsDTDValidation) 
+    then ("import module namespace zorba-xml = 'http://www.zorba-xquery.com/modules/xml#2.1';",
+          "import schema namespace opt       = 'http://www.zorba-xquery.com/modules/xml-options';")
+    else (),
+    
     if (exists($resolver))
     then "declare namespace resolver = 'http://www.zorba-xquery.com/modules/xqxq/url-resolver';"
     else (),
@@ -972,8 +993,8 @@
                 then ", (), mapper:uri-mapper#2&#xA;);"
                 else "&#xA;);"),
 
-    env:set-context-item($env, $envBaseURI),
-    env:set-context-item($case/fots:environment, $testSetBaseURI),
+    env:set-context-item($env, $envBaseURI, $needsDTDValidation),
+    env:set-context-item($case/fots:environment, $testSetBaseURI, $needsDTDValidation),
     env:set-variables($env, $envBaseURI),
     env:set-variables($case/fots:environment, $testSetBaseURI),
 


Follow ups