[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Seeking an elegant implementation of a graph traversal


Subject: Re: [xsl] Seeking an elegant implementation of a graph traversal
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Sat, 8 Oct 2011 18:37:06 -0700

Probably this XSLT 1.0 solution to a similar problem would be
interesting to you (Jan, 2004):

http://lists.xml.org/archives/xml-dev/200401/msg00444.html


Since then I have successfully developed other, more complex
graph-theory algorithms like Eulerisation used in a "Chinese
Postman"-like (The New York Street Sweeeper) algorithm.


And I have almost forgotten all this -- it was so long ago ...


--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.




On Sat, Oct 8, 2011 at 9:05 AM, Costello, Roger L. <costello@xxxxxxxxx>
wrote:
> Hi Folks,
>
> I am seeking an elegant XSLT implementation for the following problem.
>
> I have a Document consisting of a bunch of Sections. Each Section has a
unique identifier. Each Section may reference other Sections via an Include
element, e.g.,
>
> <Document>
> B  B <Section id="A">
> B  B  B  B <Include idref="B" />
> B  B  B  B <Include idref="C" />
> B  B </Section>
> B  B <Section id="B">
> B  B  B  B <Include idref="D" />
> B  B </Section>
> B  B <Section id="C">
> B  B  B  B <Include idref="D" />
> B  B </Section>
> B  B <Section id="D">
> B  B  B  B <Include idref="A" />
> B  B </Section>
> B  B <Section id="E" />
> </Document>
>
> Problem: Write a function and pass a Section to it. The function outputs the
Section and all the Sections it Includes and all the Sections each of them
Includes, and so on.
>
> Be sure there are no duplicates in the output.
>
> Example: invoke the function with Section A. Here's the output:
>
> A, B, C, D
>
> Is there an elegant XSLT implementation of this graph traversal problem?
>
> /Roger


Current Thread
Keywords