Re: [FO] Bug in contains()

Michael Kay wrote:

>>Now I want to do the following query:
>>
>>    let $people := doc('people.xml')
>>    return contains($people, "Rys")
>>
>>When the query attempts to cast $people to a string, it will try to 
>>atomize the element using dm:typed-value(), and the following 
>>rule applies:
>>
>>     If the node has a complex type with complex content, raises a
>>     type error, which may be handled by the host language.
>>
>>We should see if there are other functions/operators that 
>>have this same problem.
>>
>>    
>>
>
>All string functions potentially have this problem, there is no reason
>to special-case contains. For example, it applies just as much to
>concat().
>  
>
I think there are two consistent ways to approach this.

One way is to say that elements with child elements do not have a typed 
value, and to use string-value() when you want the string value. 
<xslt:value-of/> and contains() would then be defined in terms of string 
value, which seems more appropriate to their function. Personally, I see 
no problem with concat() raising an error when you try to treat an 
element with complex content as a string.

Another approach is to say that every element has a type value. Your 
proposal is a reasonable way to do that, and I find it less 
objectionable than the status quo.

A third approach is to say that elements with child elements do not have 
a typed value, but any element can be implicitly cast to a string.

I prefer all three of these approaches to the status quo. Of these three 
approaches, I prefer the first and the third.

Jonathan

Received on Monday, 16 February 2004 13:53:25 UTC