RE: [xsl] Should You Comment XSLT And If So, How?

Subject: RE: [xsl] Should You Comment XSLT And If So, How?
From: David N Bertoni/Cambridge/IBM <david_n_bertoni@xxxxxxxxxx>
Date: Tue, 18 Feb 2003 23:09:03 -0800

Ryan Gallagher <binerman@xxxxxxxxxxxxxxxxxxxxx> wrote:
> Use XML TAGS in your xsl...
> <doc type="variable">
>   <desc>This variable is for X</desc>
> </doc>
> <xsl:variable name="foobar" select="Hello World!"/>
> <doc type="template">
>   <desc type="short">This template does foo.</desc>
>   <desc type="long">I'm the verbose desc...</desc>
> </doc>
> <xsl:template match="foo">
> ...
> </xsl:template>

Your example is illegal because top-level elements may not have a null
namespace URI:

   "In addition, the xsl:stylesheet element may contain any element not
   from the XSLT namespace, provided that the expanded-name of the element
   has a non-null namespace URI. The presence of such top-level elements
   must not change the behavior of XSLT elements and functions defined in
   this document; for example, it would not be permitted for such a
   top-level element to specify that xsl:apply-templates was to use
   different rules to resolve conflicts. Thus, an XSLT processor is always
   free to ignore such top-level elements, and must ignore a top-level
   element without giving an error if it does not recognize the namespace

> If you like you can even give your comments a namespace and DTD, but from
> i've read/understand anything not in the xsl namespace will be safely
> outside of templates.  Inside templates i'm not positive, but namespaces
> certainly resolve the conflicts.

Such elements inside templates won't work because they are literal result
elements and will be copied to the result tree:

<xsl:template match="/" xmlns:doc="";>
  <doc:doc type="something">

Other top-level elements may not allow children, may restrict what sort of
children are allowed, or will consider elements not in the XSLT namespace
as literal result elements.


 XSL-List info and archive:

Current Thread