RE: [xsl] [Ann - Zvon] Templatotron

Subject: RE: [xsl] [Ann - Zvon] Templatotron
From: Miloslav Nic <nicmila@xxxxxxxxxxxx>
Date: Wed, 20 Feb 2002 08:10:16 +0100 (CET)
On Tue, 19 Feb 2002, Evan Lenz wrote:

> Are you familiar with the "literal result element as stylesheet"[1] feature
> of XSLT? It seems that rather than trying to make Templatotron more
> expressive by introducing instructions like t:choose, t:if, etc., one would
> be better off using the simplified stylesheet syntax. 


I was partially aware of it :) I knew about this possibility but I somehow 
made  a mental shortcut and I thought that this was applicable only to 
html output :) . But in Templatotron case this possibility  would remove 
some  elements from ti:namespace which are anyway not used  to much in 
Templatotorn and I am  using keys regularly in my programming style not 
only for efficiency reasons but also because I find some solutions using 
them more natural for my way of thinking an so I need them in Templatotron. 


> 
> To make Templatotron fit into this picture, I think it would need to be
> radically simplified. 

I have some user cases where I need most of the Templatotron power 
including namespace handling.  But there is no problem to derive another 
language out of it which will retain the bits you consider useful.
You can use as much code of the Templatotorn implementation as you wish,
just change the namespace for your language.
 
 

> In the end, I'm not sure how practical or necessary Templatotron is given
> that we already have the LRE as stylesheet syntax (which doesn't even
> require a pre-process). Perhaps you weren't aware of the simplified syntax.
> If not, I'd be interested in hearing if you think differently about it now.


I will reply with a user case:

I have an XML document with a lot of numbers and I would like to make some 
mathematics on it or  I find an interesting function on:
http://functions.wolfram.com/
which offers functions in MathML and I would like to find out how it 
behaves on some of my numeric files.  I would like to have the answer as 
soon as possible as I may test many functions.

So I will copy the function. 
Any XML document is a Templatotron template and so I will just add 
templatotron namespace and I will use Templatotron to make substitutions 
for variables. 

in XSLT:

<math xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
      xmlns="http://www.w3.org/1998/Math/MathML"; >
     <apply>
          <plus/>
           <xsl:for-each select="//aaa">
                <cn><xsl:value-of select="."/><cn>
           </xsl:for-each>			
     </apply>
</math>

Templatotron:


<math xmlns="http://www.w3.org/1998/Math/MathML"; 
xmlns:t="http://zvon.org/templatotron"; >
     <apply>
          <plus/>
          <t:cn t:select="//aaa"/>
     </apply>
</math>


You will agree that this saves quite a lot of typing even for something as 
simple as addition and in formulas there can be quite a few substitutions. 


I expect that in most cases there will be no need for namespace handling 
as the default one is reasonable, but sometimes it is useful to have this 
possibility, e.g. for addition of XLink attributes.


I agree that Temlatotron is a bit too magic and probably it breaks a lot 
of design principles :) .  But it works for one user I was targeting ( for 
me :) ), but I guess that there may be others there who will find it 
useful as a fast prototyping tool. 

And at least it can demonstrate the power of XSLT for prototyping of new 
XML based vocabularies and languages. It is not so easy to write a 
useful 100 lines code in imperative languages :)
 

> 
> Evan Lenz
> 
> [1] http://www.w3.org/TR/xslt#result-element-stylesheet
> [2] http://www.xmlportfolio.com/desimplify.xsl
> 
> 
> Miloslav Nic wrote:
> > Templatotron  is a simple language for template based XML processing. It
> > can be also thought of as a language designed to  save some writing in
> > XSLT stylesheets and for keeping your attention focused on the
> > XML syntax
> > not on the XSLT one. I do  not personally mind the rather verbose XSLT
> > syntax and so in my eyes the second point is much more important
> > but there
> > are  others who may appreciate Templatotron terseness.
> >
> > You will find Templatotron at:
> > http://www.zvon.org/ZvonSW/Templatotron/Output/index.html
> >
> > There is a tutorial:
> > http://www.zvon.org/ZvonSW/Templatotron/Output/page1.html
> >
> > and a reference:
> > http://www.zvon.org/ZvonSW/Templatotron/Output/qr.html
> >
> > The stylesheet implementing Zvon Templatotron has about 100 lines and 3.5
> > kB :
> > http://www.zvon.org/ZvonSW/Templatotron/Output/download.html
> >
> 

-- 
******************************************
<firstName> Miloslav </firstName>
<surname>   Nic      </surname>

<mail>    nicmila@xxxxxxxxxxxx    </mail>
<support> http://www.zvon.org  </support>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread