Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Moderatore di Javascript L'avatar di ciro78
    Registrato dal
    Sep 2000
    residenza
    Napoli
    Messaggi
    8,505

    [xhtml] Warning nella validazione

    salve
    quando provo a validare il mio documento in xhtml 1.1 mi visualizza due warning

    codice:
     DOCTYPE Override in effect!
    
    The detected DOCTYPE Declaration "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">" has been suppressed and the DOCTYPE for "XHTML 1.1" inserted instead, but even if no errors are shown below the document will not be Valid until you update it to reflect this new DOCTYPE. 
    
     Conflict between Mime Type and Document Type
    
    The document is being served with the text/html Mime Type which is not a registered media type for the XHTML 1.1 Document Type. The recommended media type for this document is: application/xhtml+xml
    
    Using a wrong media type for a certain document type may confuse the validator and other user agents with respect to the nature of the document, and you may get some erroneous validation errors. How to fix this problem? One of the following techniques should help:
    
    If you are serving a static file on a Web server, changing its extension should help. Use e.g .xhtml for XHTML or .mathml for MathML. 
    You may need to reconfigure your Web server. This Setting up MIME Types tutorial has instructions for Apache, Tomcat and IIS. 
    If the document is generated dynamically, the scripting language should allow you to set up the mime type: this article on MIME Types and Content Negotiation has examples in PHP, Perl, and ASP.
    la pagina è una pagina di php. da qui il secondo warning ma non so come risolvere.
    grazie in anticipo
    Ciro Marotta - Programmatore JAVA - PHP
    Preferisco un fallimento alle mie condizioni che un successo alle condizioni altrui.


  2. #2
    Innanzitutto senza almento vedere le prime righe del codice è difficile rispondere per il primo warning.

    Il secondo invece è dato dal fatto che l'XHTML 1.1 non è un tipo "text/html" bensì un "application/xhtml+xml".
    L'inclusione dell'header corrispettivo nella pagina non risolve il problema in quanto è il server che deve essere avvisato che la pagina NON è un documento di testo, ma un'applicazione e deve servirla come tale.
    Vi sono diversi modi per farlo.
    Innanzitutto precisiamo che IE ha dei problemi nel visualizzare questo tipo di documento (anzi non lo visualizza affatto, a volte) e Firefox non permette l'uso di alcuni oggetti Jaascript e il concatenamento XML.
    Detto questo la soluzione che adotto generalmente è quella di restituire, in PHP, un header appropriato solo in presenza del validatore.
    Codice PHP:
    header("Vary: Accept");
    header("Cache-Control: no-cache");
    if (stristr($_SERVER["HTTP_USER_AGENT"],"W3C_Validator")) {
       header("Content-Type: application/xhtml+xml;charset=ISO-8859-1");
    } else {header("Content-Type: text/html;charset=ISO-8859-1");}
    echo'<?xml version="1.0" encoding="ISO-8859-1"?>';
    In tal modo la pagina viene servita per tutti i browser in formato testo e per il validatore in formato application/xhtml+xml

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.