Subject: Re: [xsl] Never use for-each (was: Please check !!) From: Joerg Pietschmann <joerg.pietschmann@xxxxxx> Date: Mon, 29 Oct 2001 12:27:55 +0100 |
Joerg_Heinicke <joerg.heinicke@xxxxxx> > By the way, Chris, why 'Never use for-each'? It's a rule-of-thumb for beginners. The problem is somewhat less obvious than for d-o-e and more an educational than a technical one. Beginners in an area tend to get the idioms they used successfully deeply engrained. Now, the easiest way to teach XSL(T) to webdesigners reasonably familiar with HTML code is to work from an existing HTML document, add a few magical attributes (the XSLT namespace) and a bit of well-formedness and - voila! - they can pull in values from XMLified database queries by xsl:value-of and xsl:for-each. This approach known as "pull" leads quickly to success if the source XML is easy (for example rows queried from a DB or a catalog or log structure) and the resulting HTML is mostly static and the transformation is more ASP like. The "Literal Result Element as Stylesheet" http://www.w3.org/TR/xslt.html#result-element-stylesheet has been tailored for this, but people, not aware of this possibility, also often use a single template matching "/" or the document element and do all the work there. It is so easy because you basically see the structure of the resulting HTML document already in the style sheet. Unfortunately, if the input becomes more complex, the pull approach quickly becomes messy and unmaintainable as lots of constructs are duplicated. When this happens, newbies (and even not-quite-as-green XSLT programmers), having learned "pull" first, have a hard time to switch to the template driven "push" style, mainly because the structure of the resulting document is no longer easy to spot. That's also the main reason why many people who started learning XSLT with the "push" approach have diffucilties in the beginning and think XSLT is overly complex and hard to learn. There are other issues i don't want to comment on. I already took advantage of the "engrainment" effect several times when i managed to pull off successfull demos of actually rather buggy and incomplete software. Regards J.Pietschmann XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Escaping/converting speci, Ross Kendall | Thread | push v. pull (was[xsl] Never use fo, Graham Seaman |
Re: [xsl] Escaping/converting speci, Christopher R. Maden | Date | Re: [xsl] Escaping/converting speci, David Carlisle |
Month |