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