对话章节错误
对话章节(<chapter dialog="true">)在 XML 解析、JSON 解析与统一模型校验三个阶段均执行严格检查,包括位置限制、属性白名单、分支起止顺序、首条消息无图以及文本样式限制。本页汇总全部对话相关的 XmlWikiConversionError。
类别总览
| 错误消息模式 | 错误类型 | 触发阶段 |
|---|---|---|
A dialog <chapter> must be directly inside a top-level <chapters> element. | XmlWikiConversionError | XML 解析 |
<tag> must be inside a dialog chapter. | XmlWikiConversionError | XML 解析 |
<location> cannot contain text directly inside <tag>. | XmlWikiConversionError | XML 解析 |
<location> has unsupported attribute '<attr>' on <tag>. | XmlWikiConversionError | XML 解析 |
<location> <divider> only supports plain text. | XmlWikiConversionError | XML 解析 |
<branchLocation> must be a <branch> with a name attribute. | XmlWikiConversionError | XML 解析 |
<location> cannot contain <tag>. | XmlWikiConversionError | XML 解析 |
<location> must be a <message> with side 'me' or 'other'. / must be a message with side 'me' or 'other'. | XmlWikiConversionError | XML 解析 / 模型校验 |
<location> <image> cannot contain content. | XmlWikiConversionError | XML 解析 |
<location> must be <text> or <image>. / must be text or an image. | XmlWikiConversionError | XML 解析 / 模型校验 |
<location> cannot contain <tag> inside <text>. | XmlWikiConversionError | XML 解析 |
<location> only supports left-aligned body paragraphs. | XmlWikiConversionError | 模型校验 |
<location> emoji must include a nonempty id. | XmlWikiConversionError | 模型校验 |
<location> only supports unstyled text and emoji. | XmlWikiConversionError | 模型校验 |
<location> must include a nonempty avatar. | XmlWikiConversionError | 模型校验 |
<contentLocation> must include a nonempty image src. | XmlWikiConversionError | 模型校验 |
<location> must contain at least one dialog entry. | XmlWikiConversionError | 模型校验 |
<entryLocation> must include a nonempty divider kind. | XmlWikiConversionError | 模型校验 |
<entryLocation> must contain at least one branch. | XmlWikiConversionError | 模型校验 |
<branchLocation> must start with 'me' and end with 'other'. | XmlWikiConversionError | 模型校验 |
<branchLocation> first message cannot contain an image. | XmlWikiConversionError | 模型校验 |
<entryLocation> must be a message, a divider or a branch group. | XmlWikiConversionError | 模型校验 |
<location> cannot contain <key> entries. | XmlWikiConversionError | JSON 解析 |
<branchLocation> must be a branch-group-item. | XmlWikiConversionError | JSON 解析 |
Unsupported dialog entry type '<type>' at <location>. | XmlWikiConversionError | JSON 解析 |
<location> must contain a dialog-me or dialog-other message. | XmlWikiConversionError | JSON 解析 |
<location> refers to missing documentMap[<documentId>]. | XmlWikiConversionError | JSON 解析 |
Unsupported dialog content type '<type>' at <location>. | XmlWikiConversionError | JSON 解析 |
对话章节与专属元素的放置位置错误
包含两条消息:
-
A dialog <chapter> must be directly inside a top-level <chapters> element. -
<tag> must be inside a dialog chapter. -
错误类型:
XmlWikiConversionError -
问题原因:把
<chapter dialog="true">放在非顶层<chapters>的位置,或者把对话专属元素(<message>、<text>、<image>、<branches>、<branch>、<divider>)写在了普通章节、<description>或其他非对话容器内。
错误写法:
<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
<itemId>1</itemId>
<metainfo>
<name>示例</name>
<cover/>
<subTypes/>
</metainfo>
<description>
<message side="other" avatar="https://example.com/a.png">
<text>不能放在简介中</text>
</message>
</description>
</sklandDocument>修正写法:把 <message> 移入顶层 <chapters> 下的 <chapter dialog="true"> 中。
<?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">
<message side="other" avatar="https://example.com/a.png">
<text>正确放置在对话章节内。</text>
</message>
</chapter>
</chapters>
</sklandDocument>属性白名单、直接文本与非法子元素错误
包含六条 XML 结构校验消息:
-
<location> cannot contain text directly inside <tag>.(在<chapter dialog="true">、<message>、<branches>或<branch>内写了非空白裸文本) -
<location> has unsupported attribute '<attr>' on <tag>.(在对话元素上写了允许清单之外的属性) -
<location> cannot contain <tag>.(对话章节内包含<message>/<branches>/<divider>之外的子元素) -
<location> <divider> only supports plain text.(<divider>内包含子元素) -
<location> <image> cannot contain content.(<image>内包含文本或子元素) -
<location> must be <text> or <image>./<contentLocation> must be text or an image.(<message>内包含<text>和<image>之外的元素) -
错误类型:
XmlWikiConversionError -
问题原因:对话章节对每一层的属性与子元素执行严格白名单校验,不允许未知属性或裸文本。
错误写法:
<?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">
<message side="other" avatar="https://example.com/a.png" role="npc">
<text>role 不是合法属性</text>
</message>
</chapter>
</chapters>
</sklandDocument>修正写法:仅保留允许的属性(<message> 仅支持 side、avatar、name)。
<?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">
<message side="other" avatar="https://example.com/a.png" name="联络员">
<text>仅使用合法属性。</text>
</message>
</chapter>
</chapters>
</sklandDocument>对话 <text> 内容与样式限制错误
包含四条消息:
-
<location> cannot contain <tag> inside <text>.(在<text>中使用了<emoji>与<br>之外的元素) -
<location> only supports left-aligned body paragraphs.(模型或 JSON 中的对话文本段落带有标题或非左对齐) -
<location> emoji must include a nonempty id.(对话文本中的<emoji>缺少有效id) -
<location> only supports unstyled text and emoji.(模型或 JSON 中的对话文本包含加粗、颜色、链接等富文本样式) -
错误类型:
XmlWikiConversionError -
问题原因:对话气泡内的
<text>只支持无样式纯文本、<emoji id="..."/>与<br/>。
错误写法:
<?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">
<message side="other" avatar="https://example.com/a.png">
<text>这里不能使用 <b>加粗</b></text>
</message>
</chapter>
</chapters>
</sklandDocument>修正写法:移除富文本样式元素,只保留纯文本、<br/> 和 <emoji/>。
<?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">
<message side="other" avatar="https://example.com/a.png">
<text>使用纯文本并可附带表情<emoji id="emoji_001"/></text>
</message>
</chapter>
</chapters>
</sklandDocument>必填字段缺失、空章节与空分支错误
包含七条消息:
-
<location> must be a <message> with side 'me' or 'other'./must be a message with side 'me' or 'other'. -
<location> must include a nonempty avatar. -
<contentLocation> must include a nonempty image src. -
<location> must contain at least one dialog entry.(<chapter dialog="true">为空) -
<entryLocation> must include a nonempty divider kind.(<divider>的kind缺失或为空白) -
<entryLocation> must contain at least one branch.(<branches>为空) -
<branchLocation> must be a <branch> with a name attribute.(<branches>下包含非<branch>或缺少name属性) -
<entryLocation> must be a message, a divider or a branch group.(手工修改DocumentModel写入未知对话项类型) -
错误类型:
XmlWikiConversionError -
问题原因:缺少必填的非空属性(
side、avatar、src、kind、name)或容器为空。
错误写法:
<?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"/>
</chapters>
</sklandDocument>修正写法:至少写入一条有效的 <message>、<branches> 或 <divider>,并填全必填属性。
<?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">
<divider kind="5">通讯开始</divider>
</chapter>
</chapters>
</sklandDocument>分支起止发言人与首条无图约束
包含两条最常遇到的分支校验消息:
-
<branchLocation> must start with 'me' and end with 'other'. -
<branchLocation> first message cannot contain an image. -
错误类型:
XmlWikiConversionError -
问题原因:每个
<branch>内的消息序列必须由side="me"开始且由side="other"结束(至少 2 条消息),并且第一条side="me"消息中不能包含<image>。
错误写法:
<?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">
<branches>
<branch name="仅一条消息">
<message side="me" avatar="https://example.com/me.png">
<text>缺少对方回复</text>
</message>
</branch>
</branches>
</chapter>
</chapters>
</sklandDocument>修正写法:确保首条为无图片的 side="me",末条为 side="other"。
<?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">
<branches>
<branch name="完整对话">
<message side="me" avatar="https://example.com/me.png">
<text>收到,马上出发。</text>
</message>
<message side="other" avatar="https://example.com/other.png">
<text>一路顺风。</text>
</message>
</branch>
</branches>
</chapter>
</chapters>
</sklandDocument>JSON 对话结构解析错误
以下六条消息仅在将 Wiki JSON 或提交态 JSON 转换为 XML 时触发:
-
<location> cannot contain <key> entries.:对话组件同时包含不合法的非空并列字段(如tableList、audioList)。 -
<branchLocation> must be a branch-group-item.:branch-group的children中出现非branch-group-item类型节点。 -
Unsupported dialog entry type '<type>' at <location>.:dialogList中出现dialog-me、dialog-other、branch-group、dividing-line之外的节点类型。 -
<location> must contain a dialog-me or dialog-other message.:分支项内部节点不是dialog-me或dialog-other。 -
<location> refers to missing documentMap[<documentId>].:对话文本节点引用的documentId在documentMap中不存在。 -
Unsupported dialog content type '<type>' at <location>.:对话消息内容项不是text或img。 -
错误类型:
XmlWikiConversionError -
修复方式:检查上游 JSON 中的
dialogList类型字段与documentMap引用完整性。