It seems to me that you first want to create (or imagine) a graph: in your
example there are arcs k->o, o->p, p->c, a->b, b->c, etc.
Then you want to look for cycles in this graph. If any cycles exist, there
is no solution to your problem.
If there are no cycles then there is a partial ordering, and you can for
example label each node with the length of the longest path leading to that
node, and then sort the nodes by this value of this label.
One way to implement this, depending on your data, might be to replace the
strings (k, o, p, c, f) with "full paths" (k, ko, kop, kopc, kopcf), then
group these full paths by the value of the last symbol in the path, then
sort the groups by the length of the longest path in the group.
Regards,
Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay
-----Original Message-----
From: Michael Müller-Hillebrand [mailto:mmh(_at_)cap-studio(_dot_)de]
Sent: 08 April 2010 14:29
To: XSL-List
Subject: [xsl] Ordered union of sequences
Hello experts,
I tried hard to come up with a good subject, but maybe I
failed. I am looking for pointers and terms that I can use
for further research. The task at hand, which I plan to solve
in XSLT2, is the creation of a combined master sequence of a
number of sequences in a way so the internal order of
sequence items (identified by their name) is preserved (and
inconsistencies can be reported).
There is an arbitrary number of sequences, sometimes
containing items with the same name:
(k, o, p, c, f)
(d, e, f, g)
(k, f, z, o)
(a, b, c, d)
I want to create a master sequence which contains every item
once, preserving the original order.
There are many possibilities for inconsistencies (like above
the item "o" appears before and after "f", which should be
detected as an inconsistency) and obviously there is more
than one possible solution. Luckily I am only interested in
one solution, e.g.:
(a, b, k, o, p, c, d, e, f, z, g)
The XSLT union operator treats sequences like unordered sets
and only solves the problem of removing duplicates.
BTW, the idea behind this is to create part of an XML Schema
from evaluating document instances.
I am thankful for any pointers,
- Michael Müller-Hillebrand
--
_______________________________________________________________
Michael Müller-Hillebrand: Dokumentation Technology Adobe
Certified Expert, FrameMaker Consulting and Training,
FrameScript, XML/XSL, Unicode Blog [de]: http://cap-studio.de/
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--