Re: saxon-help Digest, Vol 26, Issue 27

View: New views
1 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: saxon-help Digest, Vol 26, Issue 27

by max toro q :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I realized the problem is not with ICollection, but with IDictionary
(which derives from ICollection).

The feature of converting -any- collection to a sequence is good,
-except- with IDictionary. The main use case of dictionaries is to get
and set values by key, you tipically don't want to deal with the whole
collection of values.

The good part is that IDictionary defines 2 properties, Keys and
Values, both of type ICollection, which you can use if you want a
sequence of all keys/values, that should make everyone happy, right?

> Message: 2
> Date: Fri, 11 Jul 2008 23:18:46 +0100
> From: "Michael Kay" <mike@...>
> Subject: Re: [saxon] Converting the Result of a .NET Extension
>        Function
> To: "'Mailing list for the SAXON XSLT and XQuery processor'"
>        <saxon-help@...>
> Message-ID: <6EF00EA45A4D4EA98906D3548864BEE1@Sealion>
> Content-Type: text/plain;       charset="us-ascii"
>
> The design is clearly a compromise, but I don't accept that it's wrong. For
> many use cases it's very convenient that if an extension function returns a
> collection of strings, the stylesheet or query can process the returned
> value as a sequence of strings. Cross-language programming across dissimilar
> type systems is never going to be perfect. As you say, there's a workaround
> which is to supply a wrapper class that provides the methods you need.
>
> Michael Kay
> http://www.saxonica.com/
>
>> -----Original Message-----
>> From: saxon-help-bounces@...
>> [mailto:saxon-help-bounces@...] On Behalf
>> Of max toro q
>> Sent: 11 July 2008 23:06
>> To: saxon-help@...
>> Subject: [saxon] Converting the Result of a .NET Extension Function
>>
>> Hello Michael,
>>
>> In
>> http://www.saxonica.com/documentation/extensibility/function-r
>> esult.net.html
>> says:
>>
>> "If the returned value is an instance of the .NET interface
>> System.Collections.ICollection, or if it is an array, the
>> XPath value will be the sequence represented by the contents
>> of this collection or array. The members of the list or array
>> will each be converted to an XPath value, as if each member
>> was supplied from a separate function call. An error is
>> reported if the result contains a list or array nested within
>> another list or array. The contents of the list or array are
>> copied immediately on return from the function, so the
>> original collection or array object itself may be safely re-used."
>>
>> I think this behaviour is very wrong, because:
>>
>> - You cannot get only 1 item of an ICollection.
>> - You cannot access instance level methods or properties of
>> an ICollection, for instance Add, Remove, Count or other
>> type-specific members.
>>
>> I'm trying to use instance level members of the QueryString
>> and Form properties of the System.Web.HttpRequest object,
>> also the Session property of the System.Web.HttpContext
>> object. The idea is being able to get, set and remove objects
>> by key or index.
>>
>> I know the workaround, write a class that would act as a
>> gateway to all the functionality I need. However I still
>> think the processor should return the "wrapped object" for
>> ICollection(s), and apply the conversion-to-a-sequence only
>> to arrays (System.Array is a special class which you cannot
>> derive from).
>>
>> --
>> max toro q
>>

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 
LightInTheBox - Buy quality products at wholesale price