Wishing I Could Program XIM...

by Kevin Farnham


It's been an XSL kind of weekend for me, thus far. First, an associate from the AOL Developer Community pointed me to the "Ficlets enhanced author feed, an XSL scraper hack" post at the 0xDECAFBAD blog. Then, in the May issue of Dr. Dobb's Journal, I saw the article "XSL Transformations: A delivery medium for executable content over the Internet".



My interest in XSL has been on the increase, after several years of lull -- driven mostly by the fact that I was too busy with work, and none of the work required XSL. Then M. David Peterson's "Solving FizzBuzz in XSLT 1.0", along with the talk about XSLT 2.0, reawakened my interest.



FizzBuzz in XIM?


What I really wanted to accomplish, and hence be able to write about, was that I had created a XML "program" written in the Minimal Imperative Language XIM (see the Dr. Dobb's article) that would perform FizzBuzz.



Alas, it is not to be -- not this weekend anyway. XIM looked straightforward, starting with the example program from the article:



<?xml version="1.0"?>
<program>
<vars>
<var_declare name="fact"> 1 </var_declare>
<var_declare name="last"> 0 </var_declare>
<var_declare name="nb"> 5 </var_declare>
</vars>
<main>
<assign varn="last">
<var_use name="nb"/>
</assign>
<while>
<condition>
<boolop opname="gt">
<var_use name="last"/>
<num> 1</num>
</boolop>
</condition>
<statement_list>
<assign varn="fact">
<op opname="*">
<var_use name="fact"/>
<var_use name="last"/>
</op>
</assign>
<assign varn="last">
<op opname="-">
<var_use name="last"/>
<num> 1</num>
</op>
</assign>
</statement_list>
</while>
<end/> <!-- program termination -->
</main>
</program>



But my attempts to convert this into something that could print a variable each time the loop is executed did not succeed. And studying the 779-line XSL file that performs the processing implied that I'd have to change that too, in order to print variables. [Note: You can get the XSL and the sample XML in the May 2007 source code zip file: 0705.zip]



It's an interesting project. But I couldn't accomplish it yet.



On to looking at what Les Orchard has come up with his Ficlets enhanced author feed -- that XSL is a mere 93 lines long, a size that maybe I can digest before the weekend ends...


2 Comments

Dr.Kernell
2007-05-02 07:54:03

Dr.Kronvil sjhzcz
2007-05-03 15:31:22