More news from my XML experiment. I didn't have a lot of time to work on this after I last posted. Originally I intended to write some perl to help generate XML. I didn't really get started on that. I started downloading some tools for evaluation. I started playing with a windows-based editor called XSLerator. To try it out, I wrote an XSL stylesheet to convert the files I had sent last time into completion functions. (XSLerator is nice to use.) I had to make some tweaks to my original .xml to make the files consistent. But I was able to regenerate the original completion scripts. Well, almost, there were some white space differences. I also started writing XSL scripts for editting these XML files. It occured to me that if these scripts could perform editting operations on the XML it would be possible to harness the completion system to help with the creation and modification of the XML files. The completion system turns command line creation into a multiple choice quiz. It would be possible to use the completion system's documentation on demand to help guide the user, so the user wouldn't need to stare at the man page. I've attached the XSL for generating a completion function from .xml. ll I'post some XML files later in the week that can be used with it. To give you an idea, I've created a completion function for the Xalan XSLT processor (lastest Xalan Java 2) from the Apache folks. For those who are interested in size, the XML file is 2.2 times larger than the generated completion function, though about 4 times as many lines... There is no extra help or much indenting. The process I performed to get this file is listed below. XSL Scripts and XML Files attached. There is a lot of gratuitous perl code here. My feeling is that hese throw away scripts could be replaced by more general purpose tools. #Create the initial xml file. java org.apache.xalan.xslt.Process -IN null.xml -OUT xalan.xml \ -XSL new_service.xsl \ -PARAM Service "org.apache.xalan.xslt.Process" \ -PARAM Filename "_xalan" #Create a list of the flags from the help output #(flags start with '-' and are separated # by whitespace/sq brackets, or equal signs.) flags=(`java org.apache.xalan.xslt.Process| perl -ne 'chop;@w = split(/[\s\[\]=]+/); print join(" ",grep(/^-/ ,@w))," "; END{ print "\n";}' `) #Add the flags to the file. java org.apache.xalan.xslt.Process -IN xalan.xml -OUT xalan2.xml \ -XSL add_flags.xsl \ -PARAM Service "org.apache.xalan.xslt.Process" \ -PARAM Filename "_xalan" -PARAM Flags "$flags" #Get the explanations typeset -A help eval "help=(" $(java org.apache.xalan.xslt.Process | \ perl -n -e 'chop; m#\[(-\w+).*\((.*)\)#; $flag = $1;$help = $2; print "\"", $flag , "\" \"",$help,"\"\n" if ($flag ne "" && $help ne "");') ")" # Add the extracted explanations to the files. cp xalan2.xml xalan3.xml foreach f (${(k)help}) { java org.apache.xalan.xslt.Process -IN xalan3.xml \ -OUT xalan3b.xml -XSL add_explanation.xsl \ -PARAM Service "org.apache.xalan.xslt.Process" \ -PARAM Flag "$f" \ -PARAM Explanation "$help[$f]" cp xalan3b.xml xalan3.xml } #By hand to get final version of attached xalan.xml, I # did the following 1) Added descriptions and actions. 2) Prolog code, code for parameter_name state. 3) Added some missing explanations. #Generate the completion function java org.apache.xalan.xslt.Process -IN xalan3.xml \ -OUT _xalan -XSL arg.xsl Much of the manual edits could be done via XSL scripts. Though I wanted to post some of this before going much further. Also, adding the explanations was slower than I had hoped. I suspect that there is a lot of start up costs associated with the java vm, and re-parsing add_explanation.xsl. So if it was possible to batch a bunch of edits I think that would be better. I suspect the way to do this is via an XSL merge script. The idea being to create a new XML file with deltas, and have the XSL script take the master XML file and perform the edits from the new XML file. -FR. Files included: null.xml Shell XML file used by new_service.xsl new_service.xsl From null.xml creates an empty completion XML file add_flags.xsl Add the specified flags to the service file. add_explanation.xsl Add the explanation for the given Service and Flag arg.xsl Takes a completion XML file and generates ZSH func. xalan.xml The final XML file, after generation and hand edits. _xalan The generated completion function __________________________________________________ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/