Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XQuery空结果-为什么?_Xquery - Fatal编程技术网

XQuery空结果-为什么?

XQuery空结果-为什么?,xquery,Xquery,我想列举两个有不同宗教信仰的国家,它们是邻国。 我写过这样的东西: <result query='9'> { let $check := "" for $x in doc("m.xml")/m/country let $check := concat($check, "{$x[@car_code]}", " ") let $r1 := $x/religions[@percentage>50] for $y in doc("m.xml")/m/countr

我想列举两个有不同宗教信仰的国家,它们是邻国。 我写过这样的东西:

<result query='9'>
{
  let $check := ""
  for $x in doc("m.xml")/m/country
  let $check := concat($check, "{$x[@car_code]}", " ")
  let $r1 := $x/religions[@percentage>50]  
  for $y in doc("m.xml")/m/country[@car_code = $x/border[@country]]
  let $r2 := $y/religions[@percentage>50]
  return
    <border>
      {
        if (($r2 != $r1) and ($y[ not(@car_code = tokenize($check, "/s"))]))
        then
           (<a>
           <country name="{$x/name}" religion="{$r1}"/> 
           <country name="{$y/name}" religion="{$r2}"/>
           </a>)
        else()      
      }           
    </border>  
}  
</result>

{
让$检查:=“”
在doc(“m.xml”)/m/country中的$x
让$check:=concat($check,{$x[@car_code]},“”)
让$r1:=$x/宗教[@百分比>50]
对于文档中的$y(“m.xml”)/m/country[@car_code=$x/border[@country]]
让$r2:=$y/宗教[@百分比>50]
返回
{
如果($r2!=$r1)和($y[不是(@car_code=tokenize($check,“/s”))))
然后
(
)
else()
}           
}  
但它只会回来

<result query='9'/>

我不知道为什么。 谢谢你的帮助

编辑: 对不起。数据:

<m>
   <country car_code="AL">
     <name>Albania</name>
     <religions percentage="70">Muslim</religions>
     <religions percentage="10">Roman Catholic</religions>
     <religions percentage="20">Albanian Orthodox</religions>
     <border country="GR" length="282"/>
     <border country="MK" length="151"/>
     <border country="YU" length="287"/>
   </country>
   <country car_code="GR">
     <name>Greece</name>
     <religions percentage="1.3">Muslim</religions>
     <religions percentage="98">Greek Orthodox</religions>
     <border country="AL" length="282"/>
     <border country="MK" length="228"/>
     <border country="BG" length="494"/>
     <border country="TR" length="206"/>
   </country>
.
.
.
</m>

阿尔巴尼亚
穆斯林
罗马天主教
阿尔巴尼亚东正教
希腊
穆斯林
希腊正教
.
.
.
在这行中

for $y in doc("m.xml")/m/country[@car_code = $x/border[@country]]
您正在将
@car\u code
属性与具有
@country
属性的边界元素进行比较。不要使用谓词,而是使用轴步长:

for $y in doc("m.xml")/m/country[@car_code = $x/border/@country]

请提供一些数据。否则,我们也不知道为什么。