Re: [xsl] Comment nodes in XSLT files.

Subject: Re: [xsl] Comment nodes in XSLT files.
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 12 Apr 2004 13:58:04 -0400
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?

I think the answer varies from one XSLT processor to another.  My particular
interest is in .NET ( don't flame me please) but I have an interest in other
processors as well.

Processors will vary, but no conformant processor will do anything with comments in the stylesheet.


Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread