Re: [REX] Inserting comments?

On Feb 10, 2006, at 10:01, Stephane Bortzmeyer wrote:
> On Thu, Feb 09, 2006 at 07:01:31PM +0100,
>  Robin Berjon <robin.berjon@expway.fr> wrote
>  a message of 28 lines which said:
>> No, actually, if the target DOM supports comments, then this comment
>> will in fact be inserted into the target document.
>
> This is not obvious at all.

I'd be happy to clarify the text if you give me an idea of where this  
clarification would have most helped you.

> And I believe that REX patches like:
>
> <!-- This comment is in the REX source file only -->
> <event target='/some/where' name='DOMNodeInserted'>
>   <!-- This comment will be inserted in the target -->
> </event>
>
> are quite confusing.

In the way it's interpreted, it's just like:

<foo:bar/>
<event target='/some/where' name='DOMNodeInserted'>
   <foo:bar/>
</event>

XML comments are nodes like any other nodes. It's probably silly in  
the first place to want to transmit them, but if you do it just  
works. XSLT is a programming language, it has xsl:comment because it  
needs comments of its own. REX is not a programming language, just a  
message format.

>> Is there any part of the specification which makes you believe that
>> it would not
>
> I agree with Ian Hickson, it seems to me that general XML rules (not
> REX or DOM specific) would prevent it to be inserted.

No, there is no "general XML rule" that prevent comment insertion.

> When I write a
> XSLT template:
>
> <xsl:template match="foo/bar">
>    <xsl:comment>This one will be added as a comment in the
>    output.</xsl:comment>
>    <!-- This one is a real comment, it will be ignored -->
> </xsl:template>
>
> The "real" comment (between <!-- and -->) is not inserted.

Right, but XSLT had to specify this behaviour explicitly: "processing  
instructions and comments in the stylesheet are ignored: the  
stylesheet is treated as if neither processing instruction nodes nor  
comment nodes were included in the tree that represents the  
stylesheet". Without this rule it would have been logical to assume  
that nodes in the tree would be included in the output.


-- 
Robin Berjon
    Senior Research Scientist
    Expway, http://expway.com/

Received on Friday, 10 February 2006 09:19:08 UTC