W3C home > Mailing lists > Public > www-validator@w3.org > November 2001

Re: Internal DTD

From: Gannon Dick <gdick@gte.net>
Date: Sun, 18 Nov 2001 12:42:59 -0600
Message-ID: <000601c17060$d9f26f80$5b89e041@home2>
To: <www-validator@w3.org>
This is a difference in the XML DOM and the HTML DOM.

You can append a list of entities (or elements, or attributes) to a base DTD,
but it will only validate against an XML DOM.

e.g.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
  PUBLIC  "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
[

<!-- Add Entities To DOM -->
 <!ENTITY close "Sincerely Yours,">
 <!ENTITY signa "Gannon Dick">
]>
<?xml-stylesheet type="text/css" href="#internalcss"?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 <head>
  <title>Just a test</title>
  <style id="internalcss" type="text/css" xml:space="preserve">
  <!--
   .foo {color:#006666; background-color:#ffffff;}
   title {display:none;}
   h1 {display:block; font:bold 14pt sans-serif;}
   h2 {display:block; font:bold 13pt sans-serif;}
   h3 {display:block; font:bold 12pt sans-serif;}
   h4 {display:block; font:bold 10pt sans-serif;}
   h5 {display:block; font:bold 8pt sans-serif;}
   h6 {display:block; font:bold 6pt sans-serif;}
   br {display:block;}
  -->
  </style>
 </head>

 <body>
  <h1 class="foo">Test 1</h1>
  <h2 class="foo">Test 2</h2>
  <h3 class="foo">Test 3</h3>
  <h4 class="foo">Test 4</h4>
  <h5 class="foo">Test 5</h5>
  <h6 class="foo">Test 6</h6>

  <p class="foo">&close;<br />&signa;</p>
 </body>
</html>

Your external entity syntax was correct for (X)HTML, but not added to XML.  You have to add the entity file to the DTD.  DTD's do not cascade like style sheets.  Then of course STSTEM identifiers need to point to your revised DTD, and you can't use
the (unmodified) DTD's of the validator.

The modular versions of XHTML were designed for this ... and less :) meaning you can use only the elements you need and customize the DTD to include specialized entities in a consistant way.

Your other choice is an XSLT (on for example the above file) which would transparently resolve the external entities.  You get XHTML like this:

<!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" xml:lang="en">
 <head>
  <title>Just a test</title>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  <style type="text/css" xml:space="preserve">
  <!--
   .foo {color:#006666; background-color:#ffffff;}
   title {display:none;}
   h1 {display:block; font:bold 14pt sans-serif;}
   h2 {display:block; font:bold 13pt sans-serif;}
   h3 {display:block; font:bold 12pt sans-serif;}
   h4 {display:block; font:bold 10pt sans-serif;}
   h5 {display:block; font:bold 8pt sans-serif;}
   h6 {display:block; font:bold 6pt sans-serif;}
   br {display:block;}
  -->
  </style>
 </head>

 <body>
  <h1 class="foo">Test 1</h1>
  <h2 class="foo">Test 2</h2>
  <h3 class="foo">Test 3</h3>
  <h4 class="foo">Test 4</h4>
  <h5 class="foo">Test 5</h5>
  <h6 class="foo">Test 6</h6>

  <p class="foo">Sincerely Yours,<br />Gannon Dick</p>
 </body>
</html>
    

Your choice.
Received on Sunday, 18 November 2001 13:41:12 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:00 GMT