Xml XQuery出现意外的if错误
因此,我试图设计一个简单的应用程序,它利用MarkLogic查询控制台和MarkLogic数据库 我的代码如下所示:Xml XQuery出现意外的if错误,xml,xquery,marklogic,Xml,Xquery,Marklogic,因此,我试图设计一个简单的应用程序,它利用MarkLogic查询控制台和MarkLogic数据库 我的代码如下所示: declare namespace link="http://www.xbrl.org/2003/linkbase"; declare namespace bd-alg="http://www.nltaxonomie.nl/nt11/bd/20161207/dictionary/bd-algemeen"; declare namespace bd-bedr="http://www
declare namespace link="http://www.xbrl.org/2003/linkbase";
declare namespace bd-alg="http://www.nltaxonomie.nl/nt11/bd/20161207/dictionary/bd-algemeen";
declare namespace bd-bedr="http://www.nltaxonomie.nl/nt11/bd/20161207/dictionary/bd-bedrijven";
declare namespace bd-bedr-tuple="http://www.nltaxonomie.nl/nt11/bd/20161207/dictionary/bd-bedr-tuples";
declare namespace bd-dim-mem="http://www.nltaxonomie.nl/nt11/bd/20161207/dictionary/bd-domain-members";
declare namespace bd-dim-dim="http://www.nltaxonomie.nl/nt11/bd/20161207/validation/bd-axes";
declare namespace xbrldi="http://xbrl.org/2006/xbrldi";
declare namespace xbrli="http://www.xbrl.org/2003/instance";
declare namespace iso4217="http://www.xbrl.org/2003/iso4217";
declare namespace xlink="http://www.w3.org/1999/xlink";
let $startDateInput := ""
let $endDateInput := ""
if($startDateInput)
{
then let $startDate := xs:date($startDateInput)
else let $startDate := xs:date("1900-01-01")
}
if($endDateInput)
{
then let $endDate := xs:date($endDateInput)
else let $endDate := xs:date("2100-12-31")
}
for $doc in /xbrli:xbrl
let $docId := $doc/xbrli:context//xbrli:identifier/text()
let $docStartDate := xs:date($doc//xbrli:startDate/text())
let $docEndDate := xs:date($doc//xbrli:endDate/text())
where $docStartDate >= $startDate and $docEndDate <= $endDate
order by $docStartDate, $docId + 1
return
(
$docId,
$docStartDate,
$docEndDate
)
let $startDateInput := ""
let $endDateInput := ""
let $startDate :=
if($startDateInput)
then xs:date($startDateInput)
else xs:date("1900-01-01")
let $endDate :=
if($endDateInput)
then xs:date($endDateInput)
else xs:date("2100-12-31")
for $doc in /xbrli:xbrl
...
我的猜测是,第二个if将给出相同的错误,所以让我们保持在这一个
你们有谁知道我做错了什么吗
我试过用逗号和分号。这些给了我其他的错误,所以这不是问题所在
提前谢谢 执行XQuery if/then/else时没有大括号
if (true()) then “yes” else “no”
你需要重写你的代码。if没有大括号,但也中断了FLWOR语句的逻辑。请记住,XQuery是一种函数式语言。这样做:
declare namespace link="http://www.xbrl.org/2003/linkbase";
declare namespace bd-alg="http://www.nltaxonomie.nl/nt11/bd/20161207/dictionary/bd-algemeen";
declare namespace bd-bedr="http://www.nltaxonomie.nl/nt11/bd/20161207/dictionary/bd-bedrijven";
declare namespace bd-bedr-tuple="http://www.nltaxonomie.nl/nt11/bd/20161207/dictionary/bd-bedr-tuples";
declare namespace bd-dim-mem="http://www.nltaxonomie.nl/nt11/bd/20161207/dictionary/bd-domain-members";
declare namespace bd-dim-dim="http://www.nltaxonomie.nl/nt11/bd/20161207/validation/bd-axes";
declare namespace xbrldi="http://xbrl.org/2006/xbrldi";
declare namespace xbrli="http://www.xbrl.org/2003/instance";
declare namespace iso4217="http://www.xbrl.org/2003/iso4217";
declare namespace xlink="http://www.w3.org/1999/xlink";
let $startDateInput := ""
let $endDateInput := ""
if($startDateInput)
{
then let $startDate := xs:date($startDateInput)
else let $startDate := xs:date("1900-01-01")
}
if($endDateInput)
{
then let $endDate := xs:date($endDateInput)
else let $endDate := xs:date("2100-12-31")
}
for $doc in /xbrli:xbrl
let $docId := $doc/xbrli:context//xbrli:identifier/text()
let $docStartDate := xs:date($doc//xbrli:startDate/text())
let $docEndDate := xs:date($doc//xbrli:endDate/text())
where $docStartDate >= $startDate and $docEndDate <= $endDate
order by $docStartDate, $docId + 1
return
(
$docId,
$docStartDate,
$docEndDate
)
let $startDateInput := ""
let $endDateInput := ""
let $startDate :=
if($startDateInput)
then xs:date($startDateInput)
else xs:date("1900-01-01")
let $endDate :=
if($endDateInput)
then xs:date($endDateInput)
else xs:date("2100-12-31")
for $doc in /xbrli:xbrl
...
嗯