help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Basic question on choosing nxml-mode schema


From: Stefan Monnier
Subject: Re: Basic question on choosing nxml-mode schema
Date: Thu, 10 Nov 2016 12:05:46 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

> gives me only two problems: this rejects 'lang="EN"' with "Attribute
> not allowed"; and it rejects <style> as "Element not allowed in this
> context", even when appearing within a <body> area.

I'm not very knowledgeable in XML/SGML/HTML, but I do know that HTML5
has a much tougher stance on what is allowed where, to try and help
enforce a clean separation between content (in HTML) and presentation
(in CSS).

So maybe these are bugs in html5-schema or in nxml-mode, but my gut
feeling is that it might simply be because these constructs are not
allowed in HTML5 any more.

[ Reaches for his web browser... ]
Hmm... apparently the "lang" attribute should be allowed anywhere in
HTML5, so this looks like a bug in html5-schema.

But w.r.t the `style` tag, I see:

    Note: If the "scoped" attribute is not used, each <style> tag must
    be located in the head section.

so nXml is probably right to signal an error when it sees a `style` in
the body.

> <!doctype html>
> <html lang="en">

My memory is fuzzy, but isn't XML case-sensitive (in contrast to SGML?).
So I think you want

    <!DOCTYPE html>
    <html lang="en">

I usually start my documents with

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml";>

IIRC some of those lines are redundant but server to make the document
valid both as HTML and as XML.

> then it rejects "doctype" with "Unknown markup declaration", the
> "lang" as above, "Referenced entity has not been defined" for &ndash;
> and related, and <style> as above.

W.r.t &ndash, I recommend you use an actual ndash character rather than
an entity reference.  XML is supposed to readable/parseable without
knowing the document type and schema, so the only entities you can
reliably use are those few entities that are valid in all document
types, i.e. &amp;, &lt; &quot; &apos; and &gt;.
To make up for that restriction, you get to use the full Unicode set
of characters.


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]