|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Comment nodes in XSLT files.
Hi Greg,
At 12:08 PM 4/12/2004, you wrote: Traditionally comments in Interpreted language files slows things down. It there any practical experience with the impact of comment nodes in the XSLT files, or best practice guidance? If you are referring to XML comments that appear in your stylesheets, as in <xsl:template match="foo"> <!-- my comment here explains what the heck is going on --> <xsl:apply-templates/> </xsl:template> I'd be seriously surprised to see them have much impact, if any at all, in performance. XSLT tells me that comments in this tree are ignored: "the stylesheet is treated as if neither processing instruction nodes nor comment nodes were included in the tree that represents the stylesheet" [XSLT 3]. (In this they are unlike comments in the XML source document, which I can get by using the comment() node test). So the processor doesn't even see them. So your question reduces to whether the comments will slow parsing down and whether this might have any effect on time to process. The answer to this is no, not hardly. In this, XSLT is unlike interpreted languages: not only is XSLT usually (always?) compiled before execution, but also it is compiled from a parsed tree, not from the XML source from which that tree is derived. I would like to find the balance point between too much and too little. I'd urge you to stress maintainability over performance for this. Since the analogy to interpreted languages is misplaced, there's no reason to assume there's a performance problem unless you have positive evidence that it might be. We have also considered an XSLT comment scrubber between the saved source and the published source. It would be easy to build, but if the runtime impact of leaving the comments in place is sufficiently small why introduce all the other headaches? Processors will vary, but no conformant processor will do anything with comments in the stylesheet. Cheers, Wendell
|
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
|

Cart








