From: Dmitriy S. <sha...@gm...> - 2010-08-09 04:29:14
|
On Sun, 2010-08-08 at 23:28 +0200, Pieter Deelen wrote: > > The spec you refer to states: > "The behavior of the function if the argument is omitted is exactly > the same as if the context item had been passed as the argument.", > i.e., string() is equivalent to string(.). Hence, ()/string() should > return exactly the same value as ()/string(.). I totally agree that it must be same, but the question "what should empty(()/string(.)) return?" Let go step by step: ()/string(.) have equivalent string( () ). The spec quite clear on this ( http://www.w3.org/TR/xpath-functions/#func-string ) : =================================================================== 2.3 fn:string fn:string() as xs:string fn:string($arg as item()?) as xs:string Summary: Returns the value of $arg represented as a xs:string. If no argument is supplied, the context item (.) is used as the default argument. The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument. If the context item is undefined, error [err:XPDY0002]XP is raised. If $arg is the empty sequence, the zero-length string is returned. =================================================================== So, getting empty( xs:string("") ) and it return false, because ( http://www.w3.org/TR/xpath-functions/#func-empty ) =================================================================== 15.1.4 fn:empty fn:empty($arg as item()*) as xs:boolean Summary: If the value of $arg is the empty sequence, the function returns true; otherwise, the function returns false. =================================================================== the xs:string("") is not a empty sequence. That mean empty( ()/string(.) ) == empty( ()/string() ) == false -- Cheers, Dmitriy Shabanov |