Subject: RE: [xsl] Many sets of eyes ... From: Curtis Burisch <burisch@xxxxxxxxxxx> Date: Thu, 14 Feb 2002 10:33:58 +0000 |
Hi Jeni, thanks for your reply! >There are a couple of stylistic things that I'd do slightly >differently. First, I'd use simply * rather than ./* - paths are >always evaluated relative to the context node, so having ./ at the >start of a path doesn't change what the path returns, just adds a >couple of "line noise" characters (as the XQuery guys would apparently >call them ;) to the expression. I'd also personally use [1] rather >than [position() = 1] but that's just to avoid typing. How embarassing ;-) ... I knew that!! I was .. er.. just testing you ;-) >More importantly from a performance point of view, I'd use xsl:choose >where I could. You currently have: (snip!) >The two conditions are mutually exclusive - either one is true or the >other is true. So there's no need to test both of them - instead you >can just use an xsl:choose, with one xsl:when (and the test) and an >xsl:otherwise to catch the case when the test isn't true: There are other cases which aren't currently handled by the stlyesheet. For instance, Alice, Andrew, and Alicia are known to drop by from time to time ;-) However, the choose/otherwise structure is far better. (snip!) >So the above is equivalent to: > > <xsl:apply-templates select="joe" /> > <xsl:apply-templates select="ann" /> > >Which is also equivalent to: > > <xsl:apply-templates select="joe | ann" /> > >Which is actually in this case equivalent to: > > <xsl:apply-templates select="*" /> I've decided to go with your second suggestion -- in real life the wrap element potentially contains many different tags... >Oh, and I suppose that you could derive the "Joe says" or "Ann says" >algorithmically from the name of the child element, by translating the >first letter to a capital, with: (snip) I used 'Joe says' and 'Ann says' for demonstration purposes. In reality, this is header data, and cannot be derived algorighmically from the source data. Interesting idea though! And a nice opportunity to use the translate function!! >The final thing is that rather than having a template matching the >root element and iterating over the wrap elements with an >xsl:for-each, I'd have a separate template for the wrap elements - >that's just stylistic thing, really. Since you're stripping out >whitespace, and not adding anything in the template for the root >element, you can get rid of the template for the root element >altogether. Done. (snip) >I hope you find these comments helpful, Extremely. Thanks for your help Jeni -- I've managed to shave 12.5% off the execution time as a result. Regards, Curtis. -- XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Many sets of eyes ..., Thomas B. Passin | Thread | [xsl] how to reflect on the namexpa, Gunther Schadow |
Re: [xsl] determining position of a, Gennady Loskutov | Date | Re: [xsl] match on attribute anywhe, Trevor Nash |
Month |