As discussed in my last post (I'll get back to Delphi topics, don't worry!) I'm working on 8and with) an XML-based scripting language, which provides great flexibility for assembling the XML data behind a web page, which is than turned into the actual page using an XSL transformation.

I cannot certainly post the language manual in a blog post, so here are only some examples, mostly taken from this site (actually form this page!). The first key idea is that the script is a mix of XML nodes and processing instructions, like in:

  <link><gxi:get name="link"/></link>

In this case the content of a "link" tag is the value of the "link" variable. This can be either set in code or be a parameter of the web page, as in this specific case (it can also be one of the special HTTP-related values passed by the environment). Here is how you can define and set a variable and use it in an expression later on:

  <gxi:string name="feedId">{5E1C3716-ECD8-4F7B-BAC0-89ED6C49491A}</gxi:string>
<feedId><gxi:get name="feedId"/></feedId>

You can declare strings, integers and few other basic data types, plus a nodeset, a very powerful datatype representing a document fragment. You can write expressions with standard operations plus about 50 predefined functions, which use variables with a $ prefix. For example, in a  blog page I have a nodeset called "backtalk" holding a list of talkbacks and execute an xpath expression to extract their number and store it in an integer variable:

<gxi:integer name="howmany"><gxi:eval expr="xpath($backtalk,'count(/talkBacks/talkBack)')"/></gxi:integer>

You can also run local transformation to process a nodeset, save it to a file, add it to a log, or return it to the web page. The processing power comes from executing commands, like accessing a document by id or executing a query with a filter (we have probably a hundred different commands in our system):

    <gxi:process using="GetDoc">
      <gxi:param name="DocID">entry:<gxi:get name="id"/></gxi:param>
    <gxi:process using="connecto_blogs">
      <gxi:param name="schema">AtomEntryConcept.xsd</gxi:param>
      <gxi:param name="Xpath">[(entries/entry/feedId equals "<gxi:get name="feedId"/>"]</gxi:param>

Here is a simple conditional expression (there are also while loops, with for loops coming soon) that assigns a default value to a variable, in case it is empty:

  <gxi:if test="$title=''">
    <gxi:set name="title">[no title]</gxi:set>

Again, as I mentioned in my previous post, I'm not exactly sure what will come next. If there is enough interest, I might evaluate open-sourcing the scripting portion of our project. But the code is badly mixed up with proprietary code, so that might not be an easy task. In any case, I'm interested in your thoughts...