2012-01-28

HTML5-XML: innerHTML problemo

La problemo estas simpla, sed la solvon mi ankoraŭ ne konas. Mi havas du dosieron, unu el ili estas HTML5-a (prueba.html) kaj la alia estas HTML5-XML-a (prueba.xhtml), ankaŭ konata kiel xHTML5 (kvankam ĝi ne apartenas al la bonreputacia sinsekvo XHTML). Ambaŭ enhavas precize la saman informon: The problem is simple, but I still cannot find its solution. I have two files, one of them is written in HTML5 (prueba.html) and the otherone is written in HTML5-XML (prueba.xhtml), also known as xHTML5 (even when it does not belong to the well reputed XHTML series). Both of them contain exactly the same information:

prueba.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <title>El titulo</title>
  <script id="plantilla" type="text/html">
    <h1>{{titulo}}</h1>
    <h2>{{subtitulo}}</h2>
  </script>
</head>
<body>
  <header id="cabecera">
    <h1>titulo original</h1>
    <h2>subtitulo original</h2>
  </header>
</body>
</html>

prueba.xhtml

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
  <meta charset="utf-8" />
  <title>El titulo</title>
  <script id="plantilla" type="text/xhtml+xml">
    <h1>{{titulo}}</h1>
    <h2>{{subtitulo}}</h2>
  </script>
</head>
<body>
  <header id="cabecera">
    <h1>titulo original</h1>
    <h2>subtitulo original</h2>
  </header>
</body>
</html>
Kiam mi skribas la sekvantajn ordonojn en la "linio de ordonoj de javascript" je la ttt-legilo Opera 11.61 When I write the following commands in the "javascript command line" in the web browser Opera 11.61
>>> document.getElementById('cabecera').innerHTML
"
    <h1>titulo original</h1>
    <h2>subtitulo original</h2>
  "
>>> document.getElementById('plantilla').innerHTML
"
    <h1>{{titulo}}</h1>
    <h2>{{subtitulo}}</h2>
  "
>>>
mi obtenas la samajn rezultojn por la dosiero prueba.html kaj prueba.xhtml. I obtain the same results for both files prueba.html and prueba.xhtml.
Nun, kiam mi skribas la samajn ordonojn en la "linio de ordonoj de javascript" je la ttt-legilo Fajrovulpo 9.0.1, mi obtenas la sekvantajn rezultojn por prueba.html Now, when I write the same commands in the "javascript command line" in the web browser Firefox 9.0.1, I get the following results for prueba.html
> document.getElementById('cabecera').innerHTML
"\n    <h1>titulo original</h1>\n    <h2>subtitulo original</h2>\n  "

> document.getElementById('plantilla').innerHTML
"\n    <h1>{{titulo}}</h1>\n    <h2>{{subtitulo}}</h2>\n  "
kaj la sekvantajn rezultojn por prueba.xhtml and the following results for prueba.xhtml
> document.getElementById('cabecera').innerHTML
"\n    <h1 xmlns=\"http://www.w3.org/1999/xhtml\">titulo original</h1>\n    <h2 xmlns=\"http://www.w3.org/1999/xhtml\">subtitulo original</h2>\n  "

> document.getElementById('plantilla').innerHTML
"\n    \n    \n  "
Ambaŭ dosieroj, prueba.html kaj prueba.xhtml, estis validataj per validator.nu, do, kie estas la eraro? ĉu je la ttt-legilo? kiu el la du legiloj funkcias korekte? Both files, prueba.html and prueba.xhtml, were validated by.validator.nu, so, where is the error? is it in the web browser? which of the two browsers is working properly?

Referencoj

  1. element.innerHTML. Mozilla developer network. Legita je la 28-a de januaro de 2012.
  2. innerHTML por HTML. W3C.
  3. innerHTML por HTML-XML. W3C.