xsl-list
[Top] [All Lists]

RE: [design question]

2003-02-05 08:05:13
From: TP [mailto:tpass001(_at_)hotmail(_dot_)com]
Sent: Wednesday, February 05, 2003 6:59 AM
Subject: Re: [xsl] [design question]

< snip >


Could I use import/include to put all the javascript in a 
separate .js
file
and include it when the stylesheet loads. Would this slow 
down or fasten
the
process.

I don't know about the impact on performance, but putting client-side
scripts in external files certainly helps in terms of maintenance.  Plus the
browser will typically cache those files locally.

When we need to combine XSLT with our JavaScript, we have found that we can
put them in a separate stylesheet and call it with an HTML <script> tag:

<script language="javascript" src="/trs/trip/home/js_home.xsl"/>

To my embarassment, I had no idea we could invoke our servlet and do
transformations via a src attribute in the <script> tag.  This has made our
lives much easier when writing script that works with a variety of different
site settings.  

Performance depends on a lot of things: the optimizations your processor
uses, how expensive your Xpath is (i.e., are you using a lot of '//' in your
syntax, especially high on the input tree'?  Are you doing this:

<xsl:variable name="foo"><xsl:value-of select="@bar"/></xsl:variable>

and generating a lot of result tree fragments?) and on your app server
setup.  If you cache stylesheets server-side, for example, that will help
reduce disk I/O but not necessarily processing performance.

Could I do the same for templates in the stylesheets, for 
example, each
stylesheet has a status bar, I could put that in a status.xsl and
include/import on it later.

Yes, your status bar, if its design is consistent from page to page, could
be rendered via a single template, which you could import into each
stylesheet that needs it.

If your page layout is consistent, you could build a "master layout"
stylesheet that creates all the common navigational elements and the basic
HTML framework for each page.  Then you would import (or include) this
stylesheet in your other, page-specific stylesheets.  Note that you'll want
to group related templates together, but don't throw all of them into a
massive library and then import or include it on every stylesheet.  That
will almost certainly degrade performance.

Notice that I use import/include because I dont know what 
the difference
is.

xsl:include works as a textual inclusion: it inserts the contents of the
included stylesheet into the local stylesheet.  xsl:import is more dynamic,
in that it is possible to override templates and top-level variables by
redefining them locally (since the local elements will take precedence over
those that are imported).  So it is possible to write:

<xsl:variable name="page-layout" select="'standard'"/>

in an imported stylesheet, then write this in your local stylesheet:

<xsl:variable name="page-layout" select="'custom'"/>

Even though both $page-layout definitions are technically in the same scope,
the value of the last definition will be bound to the variable.

I know these are very generalized comments but I hope they help.

cheers,
b.

| brian martinez                              
brian(_dot_)martinez(_at_)trip(_dot_)com |
| senior gui programmer                                  303.708.7248 |
| trip network, inc.                                 fax 303.790.9350 |
| 6436 s. racine cir.                             englewood, co 80111 |
| http://www.cheaptickets.com/                   http://www.trip.com/ |

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



<Prev in Thread] Current Thread [Next in Thread>