xsl-list
[Top] [All Lists]

Re: [xsl] Suggestions to improve my XSL writing style

2011-01-28 03:31:53
<xsl:apply-templates></xsl:apply-templates> could also be written as
<xsl:apply-templates/>, saving some space and making it clear that
there is nothing insde.

Michel

On Fri, Jan 28, 2011 at 10:27 AM, David Carlisle 
<davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
On 28/01/2011 08:20, Jacobus Reyneke wrote:

The XSL I wrote below works, but I'm looking for ways to improve my
coding style. Is this a bad way of writing style sheets? - in
particular the fact that I call "apply-templates" about a million
times.


The usual error of beginners is that they don't use apply-templates enough
and over use for-each and value-of. apply-templates is the heart and soul of
xslt, the more times it's used the merrier.


Also, I could not get the Act numbering to be added in the Scene
title, so I left it in the Act element, where I would have liked a
Scene title like "Act 1, Scene 1" but using position() from within the
scene match gave me strange numbering.

if you just use <xsl:apply-templates/> that means select="node() so selects
all nodes includng he white space text nodes between elements and so
position() probably went up in steps of two. You could use
<xsl:apply-templates select="scene"/> in your act template 9if scenes are
the only child type) then the sequence being processed will just have scenes
and position() will reflect the scene number. but probably better would be
to use xsl:number  from="act" count="scene"

David



________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--