2017-04-06 40 views
0

下面是我想要得到的條目的XML結構的哪個元素聯合:ISBN不可用: -CTS搜索測試是否元素不可

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

請建議CTS:查詢一樣。

+0

貌似http://stackoverflow.com/questions/43251178/search-xmls-which-do-not的可能重複-have-particular-element-in-marklogic – grtjn

回答

0

如果你可以編輯XML結構,在條目元素添加一個屬性,像

<tr:entry isbnPresent="yes"> for isbn present, 
<tr:entry isbnPresent="no"> for isbn absent 

,並根據這些現場防火搜索着,

cts:element-attribute-value 

OR

沒有編輯模式,嘗試像,

for $i in cts:search(//tr:entry,"2015") 
return if(fn:exists($i//co:isbn)) then() else $i 
+0

也需要添加屬性所需的模式更改。我們不想這樣做。 不改變XML結構我們可以做些什麼? –

+0

檢查fn:存在與上面給出的迭代器,因爲它可能會減慢對大文件的操作 –