all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Basic question on choosing nxml-mode schema
       [not found] <1447994335.988177.1478636797036.ref@mail.yahoo.com>
@ 2016-11-08 20:26 ` Dr. Jennifer Nussbaum
  2016-11-09  9:06   ` tomas
  0 siblings, 1 reply; 7+ messages in thread
From: Dr. Jennifer Nussbaum @ 2016-11-08 20:26 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Hi, this question is probably more about understanding HTML than about nxml-mode. I don't use HTML often and don't keep up to date with web design. But:

I want to use nxml-mode to edit a document using reveal-js. The sample documents they use in the tutorials begins:

---
<!doctype html>
<html lang="en"> 
<head>
  <meta charset="utf-8">
  <title>Reveal.js 3 Slide Demo</title>...
---

nxml-mode has a problem with most aspects of this: the initial tag is "unknown markup declaration", the
html tag is 'missing xmlns="http://www.w3.org/1999/xhtml"', the charset is "Attribute not allowed", etc.

If I replace this header stuff with a more-usual 

---
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>---

then this works, but then later in the document, each "slide" is contained in <section> tags, and these show up as "Unknown element".

I assume that I just don't understand what format this document is (or should be) in, but how do I figure this out, and what schema do I use to process it? I don't care so much about auto-completion, I just don't want a good document to show up as "invalid" and have non-errors highlighted.

Thanks!

Jen



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Basic question on choosing nxml-mode schema
  2016-11-08 20:26 ` Basic question on choosing nxml-mode schema Dr. Jennifer Nussbaum
@ 2016-11-09  9:06   ` tomas
  2016-11-09  9:38     ` Yuri Khan
  0 siblings, 1 reply; 7+ messages in thread
From: tomas @ 2016-11-09  9:06 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Nov 08, 2016 at 08:26:37PM +0000, Dr. Jennifer Nussbaum wrote:
> Hi, this question is probably more about understanding HTML than about nxml-mode. I don't use HTML often and don't keep up to date with web design. But:
> 
> I want to use nxml-mode to edit a document using reveal-js. The sample documents they use in the tutorials begins:
> 
> ---
> <!doctype html>
> <html lang="en"> 
> <head>
>   <meta charset="utf-8">
>   <title>Reveal.js 3 Slide Demo</title>...
> ---
> 
> nxml-mode has a problem with most aspects of this: the initial tag is "unknown markup declaration", the
> html tag is 'missing xmlns="http://www.w3.org/1999/xhtml"', the charset is "Attribute not allowed", etc.
> 
> If I replace this header stuff with a more-usual 
> 
> ---
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> 
> <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
> <head>---
> 
> then this works, but then later in the document, each "slide" is contained in <section> tags, and these show up as "Unknown element".
> 
> I assume that I just don't understand what format this document is
> (or should be) in, but how do I figure this out, and what schema
> do I use to process it? I don't care so much about auto-completion,
> I just don't want a good document to show up as "invalid" and have
> non-errors highlighted.

I can't help you very much on that, since I have little practical
experience wih Emacs and HTML. But here are a few points:

What you are seeing is most probably a HTML document (it looks like
HTML5 [1]), which is *not* XML. It looks a bit like XML. It seems
that after a phase trying to nudge HTML towards XML conformance,
the trend these days is in the opposite direction. 

The header stuff you insert is declaring that the thing is XHTML
(which *is* xml). A confused nxml (or well: an angry nxml: "this
thing is full of errors") is to be expected then.

I don't know whether nxml-mode can be coerced to "do" html; perhaps
it can only cope with xml (and thus wih XHTML).

Sorry for only saying what *doesn't* work. Perhaps more knowledgeable
folks can remedy that :-)

regards

[1] https://en.wikipedia.org/wiki/HTML5

- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlgi5x4ACgkQBcgs9XrR2kb1jQCfTq2ZgkP24LrUmfNYfwL9ULLk
RIQAnjfMoOIBYS/lhieblgCXlLconrH0
=UCTt
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Basic question on choosing nxml-mode schema
  2016-11-09  9:06   ` tomas
@ 2016-11-09  9:38     ` Yuri Khan
  2016-11-09 19:58       ` Stefan Monnier
  2016-11-09 21:02       ` tomas
  0 siblings, 2 replies; 7+ messages in thread
From: Yuri Khan @ 2016-11-09  9:38 UTC (permalink / raw)
  Cc: help-gnu-emacs@gnu.org

On Wed, Nov 9, 2016 at 4:06 PM,  <tomas@tuxteam.de> wrote:

>> I want to use nxml-mode to edit a document using reveal-js. The sample documents they use in the tutorials begins:
>>
>> nxml-mode has a problem with most aspects of this: the initial tag is "unknown markup declaration", the
>> html tag is 'missing xmlns="http://www.w3.org/1999/xhtml"', the charset is "Attribute not allowed", etc.
>>
>> If I replace this header stuff with a more-usual
>>
>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>>
>> then this works, but then later in the document, each "slide" is contained in <section> tags, and these show up as "Unknown element".
>
> What you are seeing is most probably a HTML document (it looks like
> HTML5 [1]), which is *not* XML. It looks a bit like XML. It seems
> that after a phase trying to nudge HTML towards XML conformance,
> the trend these days is in the opposite direction.

HTML5 in fact defines an HTML serialization and an XHTML
serialization, which are equally valid and largely equivalent (except
for a few minor points). All major browsers support the XHTML
serialization in their current versions[1].

[1]: http://caniuse.com/#search=xhtml

You can author your document in XHTML serialization using nxml.

However, the xhtml schema bundled with nxml is that of XHTML 1.0, not
XHTML5. It does not know about <section> or <nav> or any other
newfangled elements of HTML5.

You’d need to either clone and extend the XHTML 1.0 schema to make it
accept XHTML5 on your own, or obtain schema files from somebody who
already walked this path. This thread[2] of half a year ago and this
repository[3] over at Github might help you in that.

[2]: https://lists.gnu.org/archive/html/help-gnu-emacs/2016-03/msg00204.html
[3]: https://github.com/hober/html5-el



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Basic question on choosing nxml-mode schema
  2016-11-09  9:38     ` Yuri Khan
@ 2016-11-09 19:58       ` Stefan Monnier
  2016-11-10 14:37         ` Dr. Jennifer Nussbaum
  2016-11-09 21:02       ` tomas
  1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2016-11-09 19:58 UTC (permalink / raw)
  To: help-gnu-emacs

> However, the xhtml schema bundled with nxml is that of XHTML 1.0, not
> XHTML5. It does not know about <section> or <nav> or any other
> newfangled elements of HTML5.

> You’d need to either clone and extend the XHTML 1.0 schema to make it
> accept XHTML5 on your own, or obtain schema files from somebody who
> already walked this path. This thread[2] of half a year ago and this
> repository[3] over at Github might help you in that.

The `html5-schema` package in GNU ELPA is supposed to do that.
It's still limited to "html" (whereas HTML5 really includes SVG and
a few other XML sub-schemas), but it might be good enough for him.


        Stefan




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Basic question on choosing nxml-mode schema
  2016-11-09  9:38     ` Yuri Khan
  2016-11-09 19:58       ` Stefan Monnier
@ 2016-11-09 21:02       ` tomas
  1 sibling, 0 replies; 7+ messages in thread
From: tomas @ 2016-11-09 21:02 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, Nov 09, 2016 at 03:38:04PM +0600, Yuri Khan wrote:
> On Wed, Nov 9, 2016 at 4:06 PM,  <tomas@tuxteam.de> wrote:

[half-truths about HTML5 and XHTML]

> HTML5 in fact defines an HTML serialization and an XHTML
> serialization, which are equally valid and largely equivalent (except
> for a few minor points). All major browsers support the XHTML
> serialization in their current versions[1].

Ah, much better, thanks. Now I'm a bit wiser :-)

regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlgjjvEACgkQBcgs9XrR2kb50QCcCKI8Foaeqs2b/PkFKKiPSbQ2
wfkAn2kQaaMg6L0yniOzUGRiFzn3Ixuq
=teYg
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Basic question on choosing nxml-mode schema
  2016-11-09 19:58       ` Stefan Monnier
@ 2016-11-10 14:37         ` Dr. Jennifer Nussbaum
  2016-11-10 17:05           ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Dr. Jennifer Nussbaum @ 2016-11-10 14:37 UTC (permalink / raw)
  To: Stefan Monnier, help-gnu-emacs@gnu.org

----- Original Message -----

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> To: help-gnu-emacs@gnu.org
> Sent: Wednesday, November 9, 2016 2:58 PM
> Subject: Re: Basic question on choosing nxml-mode schema
> 
>>  However, the xhtml schema bundled with nxml is that of XHTML 1.0, not
>>  XHTML5. It does not know about <section> or <nav> or any other
>>  newfangled elements of HTML5.
> 
>>  You’d need to either clone and extend the XHTML 1.0 schema to make it
>>  accept XHTML5 on your own, or obtain schema files from somebody who
>>  already walked this path. This thread[2] of half a year ago and this
>>  repository[3] over at Github might help you in that.
> 
> The `html5-schema` package in GNU ELPA is supposed to do that.
> It's still limited to "html" (whereas HTML5 really includes SVG 
> and
> a few other XML sub-schemas), but it might be good enough for him.


Her ;-)

I'm still not sure how all this works, but this seems mostly better for some
things. 

Using this schema with a file beginning:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="EN">

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.

If I try to use the original,

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

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.

I do control the HTML files, and I don't mind using different header info, but if the 
basic form is "supposed" to work, I'd sort of like it to work. I'd also like <script>
to work....

Thank you all.

Jen



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Basic question on choosing nxml-mode schema
  2016-11-10 14:37         ` Dr. Jennifer Nussbaum
@ 2016-11-10 17:05           ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2016-11-10 17:05 UTC (permalink / raw)
  To: Dr. Jennifer Nussbaum; +Cc: help-gnu-emacs@gnu.org

> 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



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-11-10 17:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1447994335.988177.1478636797036.ref@mail.yahoo.com>
2016-11-08 20:26 ` Basic question on choosing nxml-mode schema Dr. Jennifer Nussbaum
2016-11-09  9:06   ` tomas
2016-11-09  9:38     ` Yuri Khan
2016-11-09 19:58       ` Stefan Monnier
2016-11-10 14:37         ` Dr. Jennifer Nussbaum
2016-11-10 17:05           ` Stefan Monnier
2016-11-09 21:02       ` tomas

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.