Xquery cts搜索以测试元素是否不可用
下面是XML结构,我想从中获取元素co:isbn不可用的条目:-Xquery cts搜索以测试元素是否不可用,xquery,marklogic,cts,Xquery,Marklogic,Cts,下面是XML结构,我想从中获取元素co:isbn不可用的条目:- <tr:trackingRecord xmlns:tr="https://www.mla.org/Schema/Tracking/tr" xmlns:co="https://www.mla.org/Schema/commonModule/co" xmlns:r="http://www.rsuitecms.com/rsuite/ns/metadata"> <tr:journal>
<tr:trackingRecord xmlns:tr="https://www.mla.org/Schema/Tracking/tr"
xmlns:co="https://www.mla.org/Schema/commonModule/co"
xmlns:r="http://www.rsuitecms.com/rsuite/ns/metadata">
<tr:journal>
<tr:trackingDetails>
<tr:entry>
<co:trackingEntryID>2015323313</co:trackingEntryID>
<co:publicationDate>2015</co:publicationDate>
<co:volume>21</co:volume>
</tr:entry>
<tr:entry>
<co:trackingEntryID>2015323314</co:trackingEntryID>
<co:publicationDate>2015</co:publicationDate>
<co:isbn>
<co:entry>NA</co:entry>
<co:value>1234567890128</co:value>
</co:isbn>
</tr:entry>
<tr:entry>
<co:trackingEntryID>2015323315</co:trackingEntryID>
<co:publicationDate>2015</co:publicationDate>
<co:volume>21</co:volume>
<co:isbn></co:isbn>
</tr:entry>
<tr:entry>
<co:trackingEntryID>2015323316</co:trackingEntryID>
<co:publicationDate>2015</co:publicationDate>
<co:volume>21</co:volume>
</tr:entry>
</tr:trackingDetails>
</tr:journal>
</tr:trackingRecord>
2015323313
2015
21
2015323314
2015
NA
1234567890128
2015323315
2015
21
2015323316
2015
21
请建议使用cts:query进行相同的查询。如果可以编辑xml结构,请在entry元素中添加一个属性,如
<tr:entry isbnPresent="yes"> for isbn present,
<tr:entry isbnPresent="no"> for isbn absent
在上面
或
在不编辑模式的情况下,尝试如下操作:
看起来可能是添加属性所需架构更改的重复。这是我们不想做的。在不改变XML结构的情况下,我们可以做些什么吗?检查fn:存在上面给出的迭代器,因为它可能会减慢对大型文件的操作
cts:element-attribute-value
for $i in cts:search(//tr:entry,"2015")
return if(fn:exists($i//co:isbn)) then () else $i