As per the title, this is the first thing that came to mind when I read the following post from earlier today from Dimitre Novatchev regarding transitive closures,

XSLT: Riding the challenge: Closure in XSLT

In a recent post to the xml-dev mailing list, “XSLT question on transitive closures“, Rick Jelliffe wrote:

 

Am I right in thinking that

 1) XPath2 functions don’t have have a function for transitive closure (along provided xpaths)

2) SAXON 8 does not have the saxon:closure() extension function that older versions of SAXON had

3) The one to use is probably still Christian Nentwich’s code from circa 2001 as adopted into EXSLT ?”

 

Michael Kay replied:

I think it would be nice to do it properly based on FXSL higher-order functions, which are much more cleanly specified. Perhaps there is already a suitable function in FXSL.

The other thing that’s needed is the ability to check for cycles. Simply blowing the stack or looping isn’t good enough.”

 

David Carlisle replied by providing a solution that would dynamically generate a new XSLT stylesheet and a closure function in it that uses only a specific function and implements its closure. He also said:

 

> I think it would be nice to do it properly based on FXSL higher-order

True (but I’ll leave that for Dimitre  :-)

 

Thanks to these nice people I felt just like… something had been left for me  :o)

So, now we have in FXSL the function

   f:closure()

which, given a function pFun and a starting set of items pstartSet, produces the transitive closure of pFun.

 

While the complete 47 lines of code can be viewed using the above link, the essence of the implementation is in the following ten lines:

More goodness at the above linked post, but in follow-up to the reasoning for the title, doesn’t this seem to be exactly the type of functionality perfectly suited for locating relationships between documents on the Semantic Web? For example, given a set of URI’s and a maximum depth, return a node-set which contains all documents that link back to a specific URI within the range specified by the maximum depth. A Six Degrees of Separation app written in XSLT 2.0 and FXSL would seem to me to be the perfect candidate to highlight this capability. Of course you would need to know who owned the URI of the current document being parsed to make the proper connections. But it seems to me that this problem could at least be partially solved using the Atom feeds of a given set of blogs as the base set.

Anybody up for the challenge? :D

Thanks for the kick a$$ code, Dimitre!

Update: Or you could just use FOAF. But limiting your scope to only FOAF would mean,

* Your limiting yourself to only those people who have specified someone as a friend as opposed to someone who has linked to a document owned by any given person.
* Your end results would be of little to no value given that FOAF has yet to meet any level of critical mass.

As per the second point, my guess is that will eventually change, but for now given the number of Atom and RSS feeds on the planet, and given point one, this seems to be a much more reasonable source of interesting data.