OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

xri message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Service selection


We should be able to express the service selection process using a series of functions that operate on a list.

Here's some pseudo python code that implements how I interpreted the spec:

# 8.3 #1 - discard services with a child element with match="none" 
services = filter(matchIsNotNone, services)

# 8.2.1 #1 - add missing Type/Path/MediaType elements with match="default"
services = map(addMatchDefaults, services)

# 8.2.1 #3 and #4 - apply rules for match=(content|any|null|non-null)
#                   removing Type/Path/MediaType elements that do not match
services = map(matchContent, services)

# 8.2.1 #4 - find any remaining <Type match!="default"> elements
if matchedServices.any(findTypeMatch)
        # remove all elements with <Type match="default">
        services = map(removeTypeMatchDefaults, services)

# repeat above for Path
if matchedServices.any(findPathMatch)
        services = map(removePathMatchDefaults, services)

# repeat above for MediaType
if matchedServices.any(findMediaTypeMatch)
        services = map(removeMediaTypeMatchDefaults, services)

# 8.3 #2 and #3 - apply selection rules
return services.filter(canSelect) 


Note that 8.3 is done first in order to filter out inactive services. Also, this process actually tinkers with the nodes within the services. In reality, we would store the indices of the matching services and return the copies in the original XRD.

I would also like to get rid of the "if" statements above without too much taekwondo. You can reduce it to a single loop to find all three matching elements, but is just an optimization.

Does anyone have any suggestions? I strongly feel that if we can solve this function programming piece, it'll help us refactor the spec to be more succinct. 


=wil (http://xri.net/=wil)
 
 



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]