【问题标题】:end tag for "meta" omitted, but OMITTAG NO was specified“meta”的结束标记省略,但指定了 OMITTAG NO
【发布时间】:2015-04-20 03:03:25
【问题描述】:

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

对于我的一生,我无法验证此页面。 另外,我得到了这个,这根本没有意义:

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>

....

【问题讨论】:

  • 嗯,您是要像 XHTML 一样验证这个原始 XML 源,还是要验证生成的 XHTML(在 XSLT 转换之后)?

标签: validation xslt xhtml w3c-validation


【解决方案1】:

我看到了两件事。

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

  2. 由于您使用xsl:output 输出文档类型声明,您应该删除您尝试使用xsl:text 输出的文档类型声明。您不能有多个文档类型声明。

例子:

<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>

【讨论】:

  • 你能给我语法吗!
  • 我添加了一个例子。我所做的只是删除xsl:text 并将method="html" 更改为method="xml"
  • 谢谢你,但我不明白为什么要使用 xml,因为我想要一个 Html 页面
  • 因为您指向的是 XML 的 XHTML DTD。你想让我用 HTML DTD 更新我的示例吗?
  • 我也有这个错误:错误第 35 行,第 215 列:省略“img”的结束标记,但指定了 OMITTAG NO
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多