2017-03-06 50 views
0

我喜欢编写只能通过调用xq文件执行的库模块。但是,这些还包含我想测试的功能。事情是这样的some.xql使用xqsuite for存储库模块中的db-

xquery version "3.0"; 
import module namespace xmldb="http://exist-db.org/xquery/xmldb"; 
declare namespace no="http://none"; 
declare namespace test="http://exist-db.org/xquery/xqsuite"; 

declare 
    %test:arg('1') 
    %test:assertEquals('2') 
    function no:something ($num as xs:string?) as xs:string { 
    return 
      $num + 1 
}; 

xmldb:store('/db/data/', 'two.xml',<root>{no:something(1)}</root>) 

但是我不能测试整个模块或没有:从内它的东西的功能。我一直在使用没有问题,访问在其他方面的功能:

import module namespace no="http://none" at "some.xql";

然而,试图运行从一个包装函数我不断收到xpty00004错误测试套件的时候:

xquery version "3.0"; 
import module namespace test="http://exist-db.org/xquery/xqsuite" at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql"; 
test:suite(
    inspect:module-functions(xs:anyURI("some.xql")) 
) 

我已经尝试了不同的到达no:some函数的变化,但没有锁定。我只是写了很糟糕的问题,使用xqsuite错误,还是这是一个错误?

回答

2

some.xql主模块,你只能在库模块导入和测试功能。

请考虑改用重构到一个库模块像no.xqm

xquery version "3.0"; 

module namespace no="http://none"; 

declare namespace test="http://exist-db.org/xquery/xqsuite"; 

declare 
    %test:arg('1') 
    %test:assertEquals('2') 
function no:something ($num as xs:string?) as xs:string { 
    $num + 1 
}; 

您的应用程序主要模块some.xq

xquery version "3.0"; 

import module namespace no="http://none" at "no.xqm"; 

xmldb:store('/db/data/', 'two.xml',<root>{no:something(1)}</root> 

你的测试运行主模块tests.xq

xquery version "3.0"; 
import module namespace test="http://exist-db.org/xquery/xqsuite" 
at "resource:org/exist/xquery/lib/xqsuite/xqsuite.xql"; 

test:suite(
    inspect:module-functions(xs:anyURI("no.xqm")) 
) 
+0

我害怕这是事实。但现在我知道了。感谢您的详细解答。 – duncdrum