This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: RE:"*NEVER* use for-each"


Chris,

That sounds like a good plan, but I have come to understand that there are
several possible ways of devising HTML pages out of an XML tree. One is to
use templates for everything. Another is to use a normal HTML approach where
by you use XSL throughout the page as needed to get to dynamic data and do
conditional things with that data. I have taken the latter approach.

The question I have is if it is "better" to do everything via templates for
the sake of using templates, or because for performance reasons it is better
as well? My main concern about using XSL is performance (second would be
memory use as XSLT uses DOM to read in XML which if you have several hundred
pages with several requests each happening at the same time, its quite
possible 1000's of DOM objects will be in memory at the same time..which is
another question I had..can SAX be used to conserve memory?). I want to make
sure the optimal performance can be achieved to support 1000's of requests
at the same time. I am not objected to using multiple servers in a farm to
handle bigger loads either. I thus far haven't done any load-testing on my
use of XSL, but it appears to be the same speed as JSP returns..although I
know I am being fooled by the single-page problem..I am not testing hundreds
of pages at the same time, my perceived visual is lying to me. ;)

I think someone else said there isn't any "wrong way" in using XSL..whether
it be inlined xsl in HTML, or templates. So I ask you, and Michael Kay and
others who have alot of knowledge, is it advisable to use templates over
inlined xsl for reasons of performance, effeciency, manageability (and any
of the above combinations). I can say from looking at XSL with templates,
its harder to follow that using inline xsl inside of html. That brings
around one other concern..the ability for others to manage the page in a
fashion that doesn't require extensive time to figure out the page. What is
more manageable, as well as provides best performance/memory use.

Thanks.


> -----Original Message-----
> From: Chris Bayes [mailto:Chris@Bayes.co.uk]
> Sent: Tuesday, February 27, 2001 9:41 AM
> To: xsl-list@lists.mulberrytech.com
> Subject: RE: [xsl] RE:"*NEVER* use for-each"
> 
> 
> Mike,
> When a lot of people come to XSLT they see <xsl:for-each> and 
> think "That's
> what I need" when it most times isn't. They should be using 
> templates. As
> they start to develop their template they add <xsl:if> and 
> <xsl:choose> all
> over the place within the <xsl:for-each> to get round not 
> using templates in
> the first place. So to stop people making a bealine for 
> <xsl:for-each> I
> always say "Beginners rule #1 *NEVER* use for-each". Daniel's 
> solution to
> his own problem is
> 
> ><xsl:value-of
> >select="ANNUALSNAPSHOT[3]/CONSENSUSVALUE/ESTIMATEDATA/child::
> *[position()=$
> I
> >ndex]" />
> 
> >Now I know might not be pretty, but it DOES return what I 
> want. $Index will
> >range from 1 to 9
> 
> Next he will be asking how he can increment his $Index 
> variable which he
> can't do because you can't increment variables without using 
> recursion. As
> he hasn't got the hang of templates yet explaining to him how to do
> recursion is not going to be easy.
> To quote Francis in another thread
> 
> >People on this list find themselves bailing out people 
> who've sailed on
> >to the same old rocks, and try to let others know that 
> they're sailing
> >in that direction, that why we make suggestions of this kind.
> 
> Ciao Chris
> 
> XML/XSL Portal
> http://www.bayes.co.uk/xml
> 
> >As a beginner, who has just used for-each to solve a 
> problem, why should I
> >never use it?
> >
> >(OK, I admit having checked the <xsl:sort> description in 
> Mike Kay's book I
> >could probably have used another template, but why is that 
> preferable to
> >using for-each?)
> >
> >mike
> >
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]