RE: Many sets of eyes ...
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  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
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