Tuesday, 24 February 2015

Xquery: No xml tag



I am using xQuery using xbase to query an xml file using the below code



for $v in doc("C:/Users/Evan/Documents/Orders.xml")/dataroot/*

let $date1 := xs:date((substring-before($v/Order_x0020_Date, 'T')))
let $date2 := xs:date((substring-before($v/Shipped_x0020_Date, 'T'))) +
xs:dayTimeDuration("P10D")
where $date1 > $date2
return concat ($date1, " ", $date2)


The problem is that in some of the records there is no Shipped Date element and so the query returns an invalid date error.


How can I skip records where there is no Shipped Date element.


If you need me to post a sample of the xml file please ask


No comments:

Post a Comment