xquery - cts search to test if the element is not available -


below xml structure want entries element co:isbn not available:-

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

please suggest cts:query same.

if can edit xml structure, add 1 attribute in entry element, like

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

and based on these field fire search with,

cts:element-attribute-value 

on it.

or

without editing schema, try like, ,

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

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -