Subject: RE: [xsl] [Ann - Zvon] Templatotron From: "Evan Lenz" <elenz@xxxxxxxxxxx> Date: Tue, 19 Feb 2002 17:47:12 -0800 |
Hi Miloslav, Sorry to reply to this thread so late; xmlhack's posting reminded me to take a closer look at this. 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. However, there still may be a place for Templatotron. I see Templatotron as a "simplified simplified stylesheet". When working with a simplified stylesheet, it sometimes becomes necessary to abandon the simple syntax because more expressive power is needed, usually by way of applying template rules (which you can't do in the simplified syntax). I've generally avoided the simplified stylesheet syntax altogether because it ends up being more work to switch the stylesheet's syntax (along with indentation) than to just use the full syntax to begin with. This doesn't have to be the case if we have an automatic way of converting from the simple syntax to the full syntax. In fact, I think it would make sense to have two stylesheets that do this for us, the first converting from "simple simple" (Templatotron) to simple, and the second converting from simple to full. When we find that more expressive power is needed, we simply drop into the next syntax by applying the appropriate converter. Templatotron template -> LRE as stylesheet -> xsl:stylesheet To make Templatotron fit into this picture, I think it would need to be radically simplified. I would get rid of the magical automatic namespace aliasing (arguably bad practice and unnecessary in any case), introduce just two attributes, t:for-each (alternative name to t:select) and t:value-of, and interpret {} as an AVT in all attributes but the two I just mentioned. In the end, only one namespace is used, only two attributes (and no elements) are used in that namespace, and there will be no need for the "tn" namespace whose purpose was to fill in the gap left by the automatic namespace aliasing. Also, by requiring t:value-of when you want dynamic text content, you eliminate the need for the ti:empty element. As it happens, all of your tutorial examples can still be expressed using just t:for-each and t:value-of, except for the one that uses a variable. The one that uses a key can (as always) easily be rewritten using an XPath expression that doesn't use keys. If you need variables, switch to LRE as stylesheet. If you absolutely need keys, switch to full syntax. Etc., etc. Templatotron inspired me to write a stylesheet that converts from the "LRE as stylesheet" syntax to the full syntax (including indentation adjustments). I posted the stylesheet to my website[2]. Having such a converter around would make the simplified syntax more extensible and a little more amenable to use. To use an example from the XSLT 1.0 recommendation, my converter transforms the following simplified stylesheet: <html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/xhtml1/strict"> <head> <title>Expense Report Summary</title> </head> <body> <p>Total Amount: <xsl:value-of select="expense-report/total"/></p> </body> </html> into the following stylesheet using the full syntax: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/xhtml1/strict" version="1.0"> <xsl:template match="/"> <html> <head> <title>Expense Report Summary</title> </head> <body> <p>Total Amount: <xsl:value-of select="expense-report/total"/></p> </body> </html> </xsl:template> </xsl:stylesheet> 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. 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 > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: [xml-dev] [Ann - Zvon] Te, Miloslav Nic | Thread | RE: [xsl] [Ann - Zvon] Templatotron, Miloslav Nic |
Re: [xsl] Grouping (yet again), G. Ken Holman | Date | [xsl] Structuring Re-useable XSLT C, gary cor |
Month |