章节与媒体错误
This page is not available in your language yet.
当 <chapter> 混合声明了多种模式、简单表格行单元格数不为 2、音频章节混写平铺与选项卡,或 <video> 与 <img> 缺少必要属性与可解析字段时,转换器会抛出 XmlWikiConversionError。
类别总览
| 错误消息模式 | 错误类型 | 触发阶段 |
|---|---|---|
<location> cannot mix chapter modes. | XmlWikiConversionError | XML 解析 / 模型校验 |
<location> cannot mix chapter modes with tabDataMap. | XmlWikiConversionError | JSON 解析 |
Simple table chapter '<title>' row <n> must contain exactly 2 cells. | XmlWikiConversionError | XML 解析 |
Simple table rows must contain exactly two cells. | XmlWikiConversionError | XML 渲染 |
Simple table chapter '<title>' must contain exactly two cells per row. | XmlWikiConversionError | JSON 渲染 |
Simple table chapter '<title>' must contain an even number of cells. | XmlWikiConversionError | JSON 解析 |
Audio chapter '<title>' cannot contain both direct <audios> and <tab> elements. | XmlWikiConversionError | XML 解析 |
Audio chapter '<title>' tab <n> must contain exactly one <audios> element. | XmlWikiConversionError | XML 解析 |
Audio chapter '<title>' cannot contain both flat audios and audio tabs. | XmlWikiConversionError | XML / JSON 渲染 |
<video> must include a kind attribute. | XmlWikiConversionError | XML 解析 |
Unsupported external video kind '<videoKind>'. | XmlWikiConversionError | XML / JSON 解析 |
<video> must include an id attribute. | XmlWikiConversionError | XML 解析 |
Could not infer image id and format from url '<url>'. | XmlWikiConversionError | XML 解析 |
Image width '<width>' is not numeric. | XmlWikiConversionError | 模型校验(复杂表格内) |
Unsupported widget type '<chapterType>' in chapter '<title>'. | XmlWikiConversionError | JSON 解析 |
Unsupported chapter type '<chapterType>'. | XmlWikiConversionError | JSON 渲染 |
<location> cannot mix chapter modes. 与 <location> cannot mix chapter modes with tabDataMap.
- 错误类型:
XmlWikiConversionError - 问题原因:在 XML 中对同一个
<chapter>同时声明了dialog="true"与table="true"或audio="true",或在 Wiki JSON 中对非通用/音频组件同时提供了tabDataMap。需注意:如果仅同时写了table="true"和audio="true"而不含dialog="true",@eihrteam/xmlv1.0.0 会按table="true"优先解析而不抛出此错误,但仍强烈建议每个<chapter>只声明单一模式。
错误写法:
<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
<itemId>1</itemId>
<metainfo>
<name>示例</name>
<cover/>
<subTypes/>
</metainfo>
<description/>
<chapters name="冲突测试">
<chapter size="large" name="双模式" dialog="true" table="true">
<divider kind="5">冲突</divider>
</chapter>
</chapters>
</sklandDocument>修正写法:每个 <chapter> 只保留一种模式,把不同模式拆成两个相邻 <chapter>。
<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
<itemId>1</itemId>
<metainfo>
<name>示例</name>
<cover/>
<subTypes/>
</metainfo>
<description/>
<chapters name="正常拆分">
<chapter size="large" name="参数表" table="true">
<table>
<row>
<cell label="键">值</cell>
<cell label="键2">值2</cell>
</row>
</table>
</chapter>
</chapters>
</sklandDocument>简单表格每行必须恰好包含 2 个单元格
以下四条消息均指向同一条规则——简单表格章节的每一行严格固定为 2 列:
-
Simple table chapter '<title>' row <n> must contain exactly 2 cells.(XML 解析) -
Simple table rows must contain exactly two cells.(XML 渲染) -
Simple table chapter '<title>' must contain exactly two cells per row.(JSON 渲染) -
Simple table chapter '<title>' must contain an even number of cells.(JSON 解析,要求tableList长度为偶数) -
错误类型:
XmlWikiConversionError -
问题原因:
<chapter table="true">中某个<row>内的<cell>数量少于 2 个或多于 2 个,或 JSON 中tableList项数为奇数。
错误写法:
<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
<itemId>1</itemId>
<metainfo>
<name>示例</name>
<cover/>
<subTypes/>
</metainfo>
<description/>
<chapters name="基础">
<chapter size="large" name="简表" table="true">
<table>
<row>
<cell label="生命">1000</cell>
</row>
</table>
</chapter>
</chapters>
</sklandDocument>修正写法:每行补足两个 <cell>(第二格无值时可写空元素),或改用通用章节中的复杂 <table>。
<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
<itemId>1</itemId>
<metainfo>
<name>示例</name>
<cover/>
<subTypes/>
</metainfo>
<description/>
<chapters name="基础">
<chapter size="large" name="简表" table="true">
<table>
<row>
<cell label="生命">1000</cell>
<cell label="攻击">200</cell>
</row>
</table>
</chapter>
</chapters>
</sklandDocument>音频章节平铺与选项卡冲突及 <audios> 数量错误
包含三条相关消息:
-
Audio chapter '<title>' cannot contain both direct <audios> and <tab> elements.(XML 解析) -
Audio chapter '<title>' tab <n> must contain exactly one <audios> element.(XML 解析) -
Audio chapter '<title>' cannot contain both flat audios and audio tabs.(XML / JSON 渲染,手工修改DocumentModel时触发) -
错误类型:
XmlWikiConversionError -
问题原因:
<chapter audio="true">同时写了直属<audios>和<tab>,或者某个<tab>内没有<audios>或包含多个<audios>。
错误写法:
<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
<itemId>1</itemId>
<metainfo>
<name>示例</name>
<cover/>
<subTypes/>
</metainfo>
<description/>
<chapters name="语音">
<chapter size="large" name="语音列表" audio="true">
<audios>
<audio name="默认" src="https://example.com/a.wav">台词</audio>
</audios>
<tab name="日语">
<audios>
<audio name="默认" src="https://example.com/b.wav">セリフ</audio>
</audios>
</tab>
</chapter>
</chapters>
</sklandDocument>修正写法:统一放进 <tab>,且每个 <tab> 仅含一个 <audios>。
<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
<itemId>1</itemId>
<metainfo>
<name>示例</name>
<cover/>
<subTypes/>
</metainfo>
<description/>
<chapters name="语音">
<chapter size="large" name="语音列表" audio="true">
<tab name="中文">
<audios>
<audio name="默认" src="https://example.com/a.wav">台词</audio>
</audios>
</tab>
<tab name="日语">
<audios>
<audio name="默认" src="https://example.com/b.wav">セリフ</audio>
</audios>
</tab>
</chapter>
</chapters>
</sklandDocument><video> 属性缺失与非法视频平台
包含三条消息:
-
<video> must include a kind attribute. -
Unsupported external video kind '<videoKind>'. -
<video> must include an id attribute. -
错误类型:
XmlWikiConversionError -
问题原因:
<video>缺少kind或id属性,或者kind(以及 JSON 中的externalVideo.kind)不是skland或bilibili。
错误写法:
<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
<itemId>1</itemId>
<metainfo>
<name>示例</name>
<cover/>
<subTypes/>
</metainfo>
<description>
<video kind="youtube" id="abc123"/>
</description>
</sklandDocument>修正写法:仅使用 skland 或 bilibili 并提供非空 id。
<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
<itemId>1</itemId>
<metainfo>
<name>示例</name>
<cover/>
<subTypes/>
</metainfo>
<description>
<video kind="bilibili" id="BV1xx411c7mD"/>
</description>
</sklandDocument>Could not infer image id and format from url '<url>'.
- 错误类型:
XmlWikiConversionError - 问题原因:
<img>省略了<id>或<format>,转换器尝试从<url>末尾文件名按{id}_{hash}.{format}推导,但文件名缺少下划线_或扩展名.导致推导失败。
错误写法:
<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
<itemId>1</itemId>
<metainfo>
<name>示例</name>
<cover/>
<subTypes/>
</metainfo>
<description>
<img>
<width>800</width>
<height>450</height>
<size>102400</size>
<url>https://example.com/banner.png</url>
<description/>
</img>
</description>
</sklandDocument>修正写法:显式补写 <id> 和 <format> 子元素。
<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
<itemId>1</itemId>
<metainfo>
<name>示例</name>
<cover/>
<subTypes/>
</metainfo>
<description>
<img>
<id>banner01</id>
<format>png</format>
<width>800</width>
<height>450</height>
<size>102400</size>
<url>https://example.com/banner.png</url>
<description/>
</img>
</description>
</sklandDocument>Image width '<width>' is not numeric.
- 错误类型:
XmlWikiConversionError - 问题原因:复杂表格单元格内的
<img>的<width>无法解析为有限数值(例如写成了"auto"或留空)。
错误写法:
<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
<itemId>1</itemId>
<metainfo>
<name>示例</name>
<cover/>
<subTypes/>
</metainfo>
<description>
<table header="none" widths="300">
<tr>
<td>
<img>
<id>img1</id>
<format>png</format>
<width>auto</width>
<height>100</height>
<size>1024</size>
<url>https://example.com/img1.png</url>
<description/>
</img>
</td>
</tr>
</table>
</description>
</sklandDocument>修正写法:将 <width> 改为纯数值字符串(如 240)。
<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
<itemId>1</itemId>
<metainfo>
<name>示例</name>
<cover/>
<subTypes/>
</metainfo>
<description>
<table header="none" widths="300">
<tr>
<td>
<img>
<id>img1</id>
<format>png</format>
<width>240</width>
<height>100</height>
<size>1024</size>
<url>https://example.com/img1.png</url>
<description/>
</img>
</td>
</tr>
</table>
</description>
</sklandDocument>Unsupported widget type '<chapterType>' in chapter '<title>'. 与 Unsupported chapter type '<chapterType>'.
- 错误类型:
XmlWikiConversionError - 问题原因:Wiki JSON 中某个章节组件的类型不是当前转换器支持的四种类型(
common、table、audio、dialog),或者在代码中向DocumentModel写入了未定义的chapterType。 - 修复方式:核对上游 JSON 的
widgetCommonMap[id].type是否属于平台新增的未支持组件;如为手工修改模型,请仅使用'common' | 'table' | 'audio' | 'dialog'。