Null and the empty sequence are two different concepts.
Null is an item (an atomic value), and can be a member of an array or of a sequence, or the value associated with a key in an object. Sequences cannot, as they represent the absence of any item.
Example 216. Null values in an array
[ null, 1, null, 2 ]
Result (run with Zorba): [ null, 1, null, 2 ]
Example 217. Null values in an object
{ "foo" : null }
Result (run with Zorba): { "foo" : null }
Example 218. Null values in a sequence
(null, 1, null, 2)
Result (run with Zorba): null 1 null 2
If an empty sequence is found as an object value, it is automatically converted to null.
Example 219. Automatic conversion to null.
{ "foo" : () }
Result (run with Zorba): { "foo" : null }
In an arithmetic opration or a comparison, if an operand is an empty sequence, an empty sequence is returned. If an operand is a null, an error is raised except for equality and inequality.
Example 220. Empty sequence in an arithmetic operation.
() + 2
Result (run with Zorba):
Example 221. Null in an arithmetic operation.
null + 2
Result (run with Zorba): An error was raised: arithmetic operation not defined between types "js:null" and "xs:integer"
Example 222. Null and empty sequence in an arithmetic operation.
null + ()
Result (run with Zorba):
Example 223. Empty sequence in a comparison.
() eq 2
Result (run with Zorba):
Example 224. Null in a comparison.
null eq 2
Result (run with Zorba): false
Example 225. Null in a comparison.
null lt 2
Result (run with Zorba): true
Example 226. Null and the empty sequence in a comparison.
null eq ()
Result (run with Zorba):
Example 227. Null and the empty sequence in a comparison.
null lt ()
Result (run with Zorba):