Xpath/Xquery 在 BaseX 上没有返回任何结果

Xpath/Xquery on BaseX bringing back no results

第一次尝试使用 XPath/Xquery,在 BaseX 中,我有一个 collection/database 的 opendata.gov 用于下面的停车场片段,

<?xml version="1.0" encoding="utf-8"?>
<CarParkDataImport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="http://www.transportdirect.info/carparking B:/CODE/carparks/CarParking.xsd" xmlns="http://www.transportdirect.info/carparking">
<CarPark>
    <CarParkRef>3</CarParkRef>
    <CarParkName>Nunnery Lane</CarParkName>
    <Location>York</Location>
    <Address>Nunnery Lane--York--North Yorkshire</Address>
    <Postcode>YO23 1AA</Postcode>
</CarPark>

我想做的是找到某个地方的位置,在这种情况下 "Nunnery Lane" 然后 return 停车场参考所以我尝试了(数据库称为 Car_park_data,里面有8个文档)

collection("Car_park_data")/CarParkDataImport/CarPark[Location="Nunnery Lane"]/CarParkRef

然后尝试了 flowr

for $x in collection("Car_park_data")/CarParkDataImport/CarPark
where $x/Location="Nunnery Lane"
order by $x/CarParkRef
return $x/CarParkRef

两者都没有命中..第一个查询的全部细节(basex 的结果位)

Compiling:
- pre-evaluating fn:collection("Car_park_data")
- adding text() step
- applying text index
Query:
collection("Car_park_data")/CarParkDataImport/CarPark[Location="Nunnery  Lane"]/CarParkRef
Optimized Query:
db:text("Car_park_data", "Nunnery  Lane")/parent::Location/parent::CarPark[parent::CarParkDataImport/parent::docume nt-node()]/CarParkRef
Result:
- Hit(s): 0 Items
- Updated: 0 Items
- Printed: 0 Bytes
- Read Locking: local [Car_park_data]
- Write Locking: none
Timing:
- Parsing: 1.33 ms
- Compiling: 0.54 ms
- Evaluating: 0.36 ms
- Printing: 0.28 ms
- Total Time: 2.52 ms
Query plan:
<QueryPlan>
<CachedPath>
 <ValueAccess data="Car_park_data" type="TEXT">
  <Str value="Nunnery Lane" type="xs:string"/>
 </ValueAccess>
 <IterStep axis="parent" test="Location"/>
  <IterStep axis="parent" test="CarPark">
  <CachedPath>
    <IterStep axis="parent" test="CarParkDataImport"/>
    <IterStep axis="parent" test="document-node()"/>
  </CachedPath>
   </IterStep>
   <IterStep axis="child" test="CarParkRef"/>
  </CachedPath>
</QueryPlan>

我做错了什么,正如我所说的使用 basex,你可以看到它是可行的 Xpat/Xquery,(即 basex 报告没有错误)但我猜我的 Xquery 有问题?

如果我用 BaseX 做 "find" "Nunnery Lane" 这就是返回的结果

Query:
/descendant-or-self::*[text() contains text "Nunnery Lane"]
Result:
- Hit(s): 4 Items
- Updated: 0 Items
- Printed: 601 Bytes
- Read Locking: global
- Write Locking: global

然后我尝试将包含文本添加到我的查询中,添加到相同的 avale,没有命中

感谢您的帮助

通过添加

来考虑命名空间
declare default element namespace "http://www.transportdirect.info/carparking";

参见 http://www.w3.org/TR/xquery/#id-default-namespace