2010-02-08 2 views
0

xquery version "1.0";이 코드의 이상 내용 (xquery)

선언 함수 콘 (XS은 $ S1 : anyAtomicType, $ S2 XS로서 : anyAtomicType) 등 XS : 문자열 {
복귀 CONCAT ($ S1, S2의 $) };

변수 $ str1을 xs : string : = "samah"로 선언하십시오. 변수 $ str2를 xs : string : = "sama"로 선언하십시오. 변수 선언 $ comstring : = con ($ str1, $ str2); {$ comstring}

답변

0

쿼리에 구문 오류가 있습니다. returnfor, let, where 또는 order by 절 뒤에 만 유효합니다. 단어 return을 제거하십시오.

둘째, { 및및및 }은 노드 내용 내부에서만 유효하므로 제거해야합니다.

마지막으로 함수와 변수를 XQuery 함수 네임 스페이스에서 선언 할 수 없으므로 이러한 함수와 변수를 다른 네임 스페이스에서 선언해야합니다.

확실히 컴파일러 오류가이 모든 것을 말 했어야 했습니까?

declare namespace test = "http://www.example.org/test"; 

declare function test:con($s1 as xs:anyAtomicType, $s2 as xs:anyAtomicType) as xs:string 
{ 
    concat($s1, $s2) 
}; 

declare variable $test:str1 as xs:string:="samah"; 
declare variable $test:str2 as xs:string:="sama"; 
declare variable $test:comstring:=test:con($test:str1 ,$test:str2); 

$test:comstring 
1

이 너무 작동합니다

xquery version "1.0"; 

declare namespace local = "local"; 

declare variable $str1 as xs:string:="samah"; 
declare variable $str2 as xs:string:="sama"; 
declare variable $comstring := local:con($str1 ,$str2); 

declare function local:con($s1 as xs:anyAtomicType, $s2 as xs:anyAtomicType) as xs:string 
{ 
    concat($s1, $s2) 
}; 

$comstring