Basic numeric = comparison in xquery
Added by Anonymous over 17 years ago
Legacy ID: #4470245 Legacy Poster: tracknerd (tracknerd2003)
I am having a issue with the = comparison on a number field. I am getting a FORG001:ValidationException: Cannot convert string "" to a double. I understand I am getting this becuase the 2nd price is a empty tag, but how do I avoid getting this error when I can not change the xml? Example xml <books> <book> <title>Title 1</title> <price>2</price> </book> <book> <title>Title 2</title> <price></price> </book> </books> Example xq for $X in //books where $X/book/price < 5.00 return $X/book/title Thanks
Replies (2)
RE: Basic numeric = comparison in xquery - Added by Anonymous over 17 years ago
Legacy ID: #4470269 Legacy Poster: Michael Kay (mhkay)
This question is about the XQuery language, not about Saxon, so it would be best asked on the XQuery-talk list at www.x-query.com. If you want to treat empty price elements in the same way as if they were not there at all, then write book/price[.!=''] < 5 or you could ignore all non-numeric price elements using book/price[. castable as xs:double] < 5 Michael Kay http://www.saxonica.com/
RE: Basic numeric = comparison in xquery - Added by Anonymous over 17 years ago
Legacy ID: #4470471 Legacy Poster: tracknerd (tracknerd2003)
Sorry for posting in the wrong place. Thanks for answering though.
Please register to reply