[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Suggestions to improve my XSL writing style
<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@xxxxxxxxx> 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. > ________________________________________________________________________
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|