{ These are for interacting with the bloody UMIX intepreter. }
rm xml.adv
/bin/umodem xml.adv STOP
{
Abstraction Anonymous - XML for O'Cult
by Daniel Lyons <fusion AT storytotell dot org>
2006-07-24 @ 2:32 PM
This file is for dealing with godforsaken "eXcessively Malleable
Language", which in some ways resembles XML by way of sequencing and
tagging.
Unfortunately I can't seem to make this one work. I wouldn't mind
hacking at it some more at some later date and finishing the
problem.
Now, in all seriousness, I think this (if it weren't intentionally
damaged) would actually make a pretty cool HTML
fixer-upper. Contemplate this:
<bold>foo</bold><bold>bar</bold>
Naturally, what the user means is this:
<bold>foo bar</bold>
This transform is expressed in O'Cult like this:
Seq (Tag a b) (Tag a c) => Tag (Seq a b);
I find that hottt. It seems like a good basis for a general tag
cleanup language. Better than XSLT, which looks something like this
(thanks to John Shipman for fighting through this, and apologies if
you try and run it and it doesn't work):
<xsl:template match="seq/a[following-sibling::a]">
<a>
<seq>
<xsl:value-of select="current()" />
<xsl:copy-of select="following-sibling::*" />
</seq>
</a>
</xsl:template>
Now, of course, there are two problems with the above XSLT:
1. It only performs a single pass of the transformation.
The equivalent O'Cult performs as many passes as it can before
it gives up, which means only handling the case of two in the
sequence will recursively handle the case of N in the sequence.
2. That code won't work, because XSLT cannot say element A
followed by element A -- it only works with concrete element
names.
I actually don't think this should be fixed. It's just more
proof that XSLT is complex but powerless.
}
{ Deal with nested sequences first of all. }
Seq (Seq d1 d2) d3 => Seq d1 (Seq d2 d3);
{
Seq (Seq d1 d2) (Seq d3 d4) => Seq (Seq (Seq (Seq d1) d2) d3) d4;
}
{ Deal with sequences of identical tags }
Seq (Tag q d1) (Tag q d2) => Tag q (Seq d1 d2);
{ Deal with nested identical tags }
Tag e (Tag e b) => Tag e b;
{ Deal with sequences of identical tags }
Seq (Tag e a) (Tag e b) => Tag e (Seq a b);
Seq (Tag e (Tag e a)) (Tag f (Tag f b)) => Seq (Tag e a) (Tag f b);
a ((Seq (Seq b) c) d) => a (Seq b (Seq c d));
{ Deal with tag priorities }
{
Tag Emph (Tag Maj a) => Tag Maj (Tag Emph a);
Tag Bold (Tag Emph a) => Tag Emph (Tag Bold a);
Tag Bold (Tag Maj a) => Tag Maj (Tag Bold a);
}
{ Tag a (Tag Maj b) => Tag Maj (Tag a b);
Tag Bold (Tag a b) => Tag a (Tag Bold b); }
{ Tag Emph (Tag Maj a) => Tag Maj (Tag Emph a); }
Tag Maj (Tag Bold a) => Tag Bold (Tag Maj a);
Tag Maj (Tag Emph a) => Tag Emph (Tag Maj a);
Tag Bold (Tag Emph a) => Tag Emph (Tag Bold a);
Seq (Tag a (Tag a b)) c => Seq (Tag a b) c;
{ render the document }
SNF x => x;
.
STOP
advise xml xml.adv