【问题标题】:ITMS-9000 "element "img" not allowed here; expected..."ITMS-9000“此处不允许元素“img”;预期...”
【发布时间】:2016-07-19 01:32:41
【问题描述】:

试图让 ePub 文件通过 Apple 的 ePub 检查器,但多次出现两个错误。

(1) 此处不允许使用元素“img”;期望元素...

这是页面上的编码:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../Styles/Style.css" type="text/css" rel="stylesheet"/>
<title></title>
</head>
<body>
<h2>Tokyo</h2>
<p>Japan is made up of five main islands: Hokkaido, Honshu, Shikoku, Kyushu, and Okinawa. Over three-quarters of the 127 million people in Japan live on Honshu, the largest and most developed island. Tokyo, the capital, lies on its eastern shore.</p>
<img alt="Tokyo Metropolis" src="../Images/Tokyo-Metropolis.jpg"/>
<p>Tokyo Metropolis, one of Japan’s 47 prefectures, is comprised of two areas: the <a class="hook" id="Special-Wards-23">23 special wards</a>, which together make up what most consider to be Tokyo, and the rest—the cities and towns that lie to the west. It is best thought of as a constellation of cities that have, over the course of time, merged into one vast urban sprawl which is home to over 13 million people.</p>

我正确插入了 alt 标签,它在 iBooks 中显示正确。

img 的 CSS 如下:

img
{
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 15px;
margin-bottom: 15px;
padding: 1px;
border: 1px solid #021a40;
background-color: #FFFFFF;
}

我浏览了许多论坛,但对我为什么会收到此错误一无所知。

(2) 相同的错误,但与标签有关(此处不允许使用“元素“ul”;预期结束标签或元素“li”...”)

这里是 HTML...

<ul>
<li><a href="../Text/Introduction.xhtml"><b>Introduction</b></a></li>
    <ul>
    <li><a href="../Text/Tokyo.xhtml">Tokyo</a></li>
    <li><a href="../Text/A%20Brief%20History.xhtml">A Brief History</a></li>
        <ul>
        <li><a href="../Text/A%20Brief%20History.xhtml#The-Emergence-of-Japan">The Emergence of Japan</a></li>

[Html 很短,因为它是一个目录并且很长]。

我认为这是因为我有嵌套列表,但这在 iBooks 中完美运行,所以我不知道为什么它会导致验证错误。

非常感谢您的帮助!

【问题讨论】:

    标签: epub


    【解决方案1】:

    第二个很清楚:列表只能包含列表项。就是这样。
    您说“这在 iBooks 中完美运行”,但事实并非如此。它不能完美地工作。只是应用程序的错误处理例程恰好以这样一种方式处理此问题,结果看起来大致与您预期的一样。这在其他机器、其他版本的应用程序等上不会相同。避免此类错误。

    第一个错误信息更加微妙。
    文件将自身标识为什么版本的 HTML?
    如果它是严格的 XHTML 1.x 或 HTML 4.x,那么在正文级别正式不允许纯文本和内联元素。不要问我为什么,我不知道。
    如果文件版本是 HTML 4.01 Transitional 或 HTML5(或 XHTML 等价物),那么作为 body 子级的图像就可以了。

    如果有人能告诉我为什么存在这种差异,我会很高兴!

    至于解决方案,如果您无法将 HTML 版本更改为 HTML5 或 XHTML5,那么只需将正文中的所有内容放在一个大 div 中即可。只需将&lt;div&gt; 放在&lt;body&gt; 之后和&lt;/div&gt; 就在&lt;/body&gt; 之前。

    【讨论】:

    • 感谢您的回复。我通过反复试验解决了这个问题,但我的问题正是您在上面提出的问题。
    • 那么请将问题标记为已回答。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-10
    • 2016-09-12
    • 1970-01-01
    • 2014-11-02
    • 2015-08-02
    • 1970-01-01
    相关资源
    最近更新 更多