Re: Validating XHTML with embedded RDF

"Aaron Swartz" <me@aaronsw.com> wrote:

> Our priorities are:
>   1. Ease of use
>   2. Not breaking things
>   3. Ease of extraction
> 
> Adding a script tag obviously helps 3 without hurting any of the others.

Unfortunately, no.  In HTML 4, the content model of the script element
was CDATA so what looked like a comment was not really treated as
a comment but just character data.  And CDATA content ends at
the first ETAGO ("</") delimiter followed by a name start character,
e.g. </License>, so it breaks validity at that point.

In XHTML the content model of the script element is #PCDATA, so a comment
is really a comment and adding <script>...</script> around it doesn't
really help.  Comments are not guaranteed to be passed to an application
from an XML processor.

If people really really want to embed RDF inside XHTML's body as data
AND still want to validate AND still don't want it to be rendered
right now, using CDATA section would be slightly less inelegant than
comments, something like:

  <div class="license">
  <![CDATA[
    ... your RDF here ...
  ]]>
  </div>

and add 

  div.license { display: none }

to your style sheet.  Unlike comments, contents of the CDATA section
are preserved and passed to an application, so while RDF is not treated
as markup (and thus won't affect DTD validation), applications could
reliably extract data inside CDATA section.  If folks really want to
hide RDF even if style sheet is disabled, well, then you could put
CDATA section inside the script element as a last resort.

I'm not really advocating this,	it's still a hack.  Just slightly
better than comments, if you really can't choose any other
alternatives.

Regards,
-- 
Masayasu Ishikawa / mimasa@w3.org
W3C - World Wide Web Consortium

Received on Friday, 27 June 2003 14:45:16 UTC