2017-12-14 5 views
2

그래서 MarkLogic Query Console 및 MarkLogic 데이터베이스를 사용하는 간단한 응용 프로그램을 설계하려고합니다.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 
) 

같은 오류를 줄 것이다 경우이 작업에 대한 오류

if($startDateInput) 
    { 
    then let $startDate := xs:date($startDateInput) 
    else let $startDate := xs:date("1900-01-01") 
    } 

내 생각 엔 그 두 번째 경우 나는 예기치 않은입니다지고있어 오류 그래서 이것을이 곳에 보관하십시오.

내가 뭘 잘못하고 있는지 이해하는 사람이 있습니까?

쉼표와 세미콜론을 넣으려고했습니다. 그것들은 다른 오류를 주므로 문제는 아닙니다.

미리 감사드립니다.

답변

4

코드를 다시 작성해야합니다. if는 중괄호를 사용하지 않지만 FLWOR 문의 논리를 중단합니다. XQuery는 함수형 언어입니다. 다음과 같이하십시오.

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 
... 

HTH!

+0

고마워요, 매력처럼 작동합니다! –

0

/then/else XQuery를 수행 할 때 중괄호가 없습니다.

if (true()) then “yes” else “no” 
+0

감사합니다. 오류가 계속 발생합니다. –