结束标记为" meta"省略,但指定了OMITTAG NO

时间:2015-02-18 22:17:01

标签: validation xslt xhtml w3c-validation

当我尝试验证联系支持页面时,我收到以下错误。

对于我的生活,我无法通过此页面进行验证。 而且,我得到了这个,这根本没有意义:

Error Line 35, Column 215: end tag for "img" omitted, but OMITTAG NO was specified

Line 1, Column 112: DTDs other than base allowed only if CONCUR YES or EXPLICIT YES
Line 1, Column 112: DTDs other than base allowed only if CONCUR YES or EXPLICIT YES
…rg/TR/xhtml1/DTD/xhtml1-strict.dtd"><!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1…
✉
Error Line 1, Column 206: DTD did not contain element declaration for document type name
…//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html>
✉
A DOCTYPE declares the version of the language used, as well as what the root (top) element of your document will be. For example, if the top element of your document is <html>, the DOCTYPE declaration will look like: "<!DOCTYPE html".

In most cases, it is safer not to type or edit the DOCTYPE declaration at all, and preferable to let a tool include it, or copy and paste it from a trusted list of DTDs.

Error Line 1, Column 207: Missing xmlns attribute for element html. The value should be: http://www.w3.org/1999/xhtml
…//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html>
✉
Many Document Types based on XML need a mandatory xmlns attribute on the root element. For example, the root element for XHTML might look like:
<html xmlns="http://www.w3.org/1999/xhtml">

Error Line 3, Column 75: end tag for "meta" omitted, but OMITTAG NO was specified
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
✉
You may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">".

Info Line 3, Column 3: start tag was here
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
Error Line 4, Column 59: end tag for "link" omitted, but OMITTAG NO was specified
        <link rel="stylesheet" type="text/css" href="style.css">
✉
You may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">".

以下是我的信息页的来源:

<?xml version="1.0" encoding="ISO-8859-1"?>
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
  <xsl:output method="html"
        encoding="ISO-8859-1"
        doctype-public="-//W3C//DTD XHTML 1.1//EN"
        doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
        indent="yes"></xsl:output>
<xsl:template match="/">
<xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"></xsl:text>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<link rel="stylesheet" type="text/css" href="style.css"></link>
<title>Titre</title> 

</head>
    <body>

<img alt="image" style="margin-top:8px;"><xsl:attribute name="src" >images/D.png</xsl:attribute></img>

....

1 个答案:

答案 0 :(得分:0)

我看到两件事。

  1. 您的输出方法是html,但您引用的是XML DTD(xhtml)。将输出方法更改为xml或引用HTML DTD(HTML DTD为SGML)。

  2. 由于您使用xsl:output输出了doctype声明,因此您应该删除您尝试使用xsl:text输出的doctype声明。您不能拥有多个doctype声明。

  3. 示例:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output 
            method="html" 
            encoding="ISO-8859-1" 
            doctype-public="-//W3C//DTD HTML 4.01//EN"
            doctype-system="http://www.w3.org/TR/html4/strict.dtd" 
            indent="yes"/>
    
        <xsl:template match="/">
            <html>
                <head>
                    <link rel="stylesheet" type="text/css" href="style.css"/>
                    <title>Titre</title>
                </head>
                <body>
                    <img alt="image" style="margin-top:8px;">
                        <xsl:attribute name="src">images/D.png</xsl:attribute>
                    </img>
                </body>
            </html>
        </xsl:template>
    
    </xsl:stylesheet>