Re: xml comment syntax
[email protected] Fri, 8 Aug 2014 10:55:33 +1200
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
> On 08/07/2014 09:16 PM, Carlo Capelli wrote:
>> Well, really of little importance, but I can't determine if this is
>> really
>> an error:
>>
>> <!--- Replaced so that we have a unionOf construct
>> Aug 20 02 MKS, suggestion by R. Volz.
>>
>> <owl:Class rdf:ID="Fruit">
>> <rdfs:subClassOf rdf:resource="#EdibleThing" />
>> </owl:Class>
>>
>> -->
Here is the actual rule from the XML 1.0 specification,
5th edition:
[15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
which begin translated means,
A comment begins with "<!--" and ends with "-->".
In between any characters whatsoever may appear,
including dashes. The one thing that is forbidden
is a "--" sequence that is not followed by ">".
In short, the example before us is PERFECTLY LEGAL
and MUST be accepted.
An XML processor may of course *warn* about "<!---",
but then, an XML processor may if it chooses complain
bitterly about every occurrence of the letter "e".
>> wikipedia <http://en.wikipedia.org/wiki/XML#Comments> informal
>> description
>> seems suggest that should be valid...
Why turn to the Wikipedia for information about XML when
the official specifications are just as easy to find and
quite clear about your question?
In SGML, we have
comment ::= "<!" (chunk s*)* ">"
chunk ::= "--" text "--" where text may not contain "--"
s ::= any white space character
so that in SGML, <!> is a legal comment,
and <!-- foo --
-- bar --
-- ugh --
>
is a legal comment. This is why XML forbids the sequence
"--" inside a comment rather than the expected prohibition
of "-->".
>
> The WikiPedia text is not very explicit. The code is (parser.c in sgml
> package)
>
> case S_CMT1: /* <!-- */
> { if ( f[CF_CMT] == chr ) /* <!--- */
> { if ( IS_XML_DIALECT(dtd->dialect) )
> gripe(p, ERC_SYNTAX_ERROR, L"Illegal comment", L"<!---");
> }
> p->state = S_CMT;
> return TRUE;
> }
>
This is WRONG. The comment is NOT illegal.
It is merely inadvisable.
Here's how hard it is to find the answer.
(1) Web search for "XML 1.0 specification".
(2) Scan the list and click on the obvious one.
(3) Search for "comment".
(4) See the rule.
20 seconds?
(You haven't heard from me lately because the SWI mailing list
has migrated where I have been unable to follow.)