跳到內容

行内元素与注释错误

本頁內容尚未翻譯。

行内元素负责表达文本样式、颜色、条目引用、表情、换行与弹出注释。当颜色或引用类型超出受校验集合、空元素包含正文内容,或出现注释嵌套时,转换器会抛出 XmlWikiConversionError。

类别总览

错误消息模式错误类型触发阶段
<color> must include a value attribute.XmlWikiConversionErrorXML 解析
Unsupported XML color '<colorValue>'.XmlWikiConversionErrorXML 解析 / JSON 渲染
Unsupported JSON color '<colorName>'.XmlWikiConversionErrorJSON 解析
<entry> must include a type attribute.XmlWikiConversionErrorXML 解析
Unsupported entry type '<entryType>'.XmlWikiConversionErrorJSON 渲染
Unsupported entry showType '<showType>'.XmlWikiConversionErrorJSON 解析
Emoji must include a nonempty id.XmlWikiConversionErrorXML / JSON 解析 / 模型校验
<emoji> must not contain content.XmlWikiConversionErrorXML 解析
<emoji> only supports the id attribute.XmlWikiConversionErrorXML 解析
gameIcon.text must be empty.XmlWikiConversionErrorJSON 解析
<br> must not contain content.XmlWikiConversionErrorXML 解析
<annotation> must contain exactly one <title> and one <content>.XmlWikiConversionErrorXML 解析
Nested annotations are not supported.XmlWikiConversionErrorXML / JSON 解析 / 模型校验
Unsupported inline tag <tag>.XmlWikiConversionErrorXML 解析
Unsupported inline kind '<kind>'.XmlWikiConversionErrorJSON 解析
Unsupported inline type.XmlWikiConversionErrorXML / JSON 渲染

<color> 属性缺失与不支持的预设色值

包含三条消息:

  • <color> must include a value attribute.

  • Unsupported XML color '<colorValue>'.

  • Unsupported JSON color '<colorName>'.

  • 错误类型:XmlWikiConversionError

  • 问题原因:<color> 缺少 value 属性,或者提供的色值不在 20 种受校验预设色值(s_1–s_4、r_1–r_6、f_orange、f_turquoise、f_green、f_sandstone、f_yellow、f_red、f_blue、f_brown、f_violet、f_blueness)之内,例如使用了 CSS 颜色名或十六进制色码。JSON 解析时若 color 字段不在对应 JSON 映射表中也会报错。

错误写法:

<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
    <itemId>1</itemId>
    <metainfo>
        <name>示例</name>
        <cover/>
        <subTypes/>
    </metainfo>
    <description>
        <color value="#ff0000">非法十六进制颜色</color>
    </description>
</sklandDocument>

修正写法:改用合法预设色值(例如 f_red)。

<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
    <itemId>1</itemId>
    <metainfo>
        <name>示例</name>
        <cover/>
        <subTypes/>
    </metainfo>
    <description>
        <color value="f_red">合法预设颜色</color>
    </description>
</sklandDocument>

<entry> 类型缺失与不支持的引用类型

包含三条消息:

  • <entry> must include a type attribute.(XML 解析)

  • Unsupported entry type '<entryType>'.(JSON 渲染,输入 XML 中使用了非法的 type 值或手工构造了非法模型)

  • Unsupported entry showType '<showType>'.(JSON 解析,JSON 中 entry.showType 不在 card-big、link-imgText、link-text 中)

  • 错误类型:XmlWikiConversionError

  • 问题原因:<entry> 缺少 type,或把 JSON 侧的名称(link-imgText、link-text)误写到了 XML 中。

错误写法:

<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
    <itemId>1</itemId>
    <metainfo>
        <name>示例</name>
        <cover/>
        <subTypes/>
    </metainfo>
    <description>
        <entry type="link-imgText" count="1" id="42"/>
    </description>
</sklandDocument>

修正写法:在 XML 中使用 card-big、link-img 或 link-txt。

<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
    <itemId>1</itemId>
    <metainfo>
        <name>示例</name>
        <cover/>
        <subTypes/>
    </metainfo>
    <description>
        <entry type="link-img" count="1" id="42"/>
    </description>
</sklandDocument>

<emoji> 属性、内容与 JSON gameIcon.text 错误

包含四条消息:

  • Emoji must include a nonempty id.(id 缺失或仅含空白字符)

  • <emoji> must not contain content.(<emoji> 内部写了文本或子元素)

  • <emoji> only supports the id attribute.(<emoji> 上出现了 id 以外的额外属性)

  • gameIcon.text must be empty.(JSON 解析时 gameIcon 节点的 text 不为空字符串)

  • 错误类型:XmlWikiConversionError

  • 问题原因:<emoji> 必须是只含非空 id 属性的空元素。

错误写法:

<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
    <itemId>1</itemId>
    <metainfo>
        <name>示例</name>
        <cover/>
        <subTypes/>
    </metainfo>
    <description>
        <emoji id="emoji_001" alt="微笑">不能写内容</emoji>
    </description>
</sklandDocument>

修正写法:移除多余属性与内容,改写为自闭合空元素。

<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
    <itemId>1</itemId>
    <metainfo>
        <name>示例</name>
        <cover/>
        <subTypes/>
    </metainfo>
    <description>
        <emoji id="emoji_001"/>
    </description>
</sklandDocument>

<br> must not contain content.

  • 错误类型:XmlWikiConversionError
  • 问题原因:<br> 元素内包含非空文本或子元素(即使在纯文本容器如 <cell>、<audio> 或普通段落内都不允许)。

错误写法:

<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
    <itemId>1</itemId>
    <metainfo>
        <name>示例</name>
        <cover/>
        <subTypes/>
    </metainfo>
    <description>第一行<br>多余文本</br>第二行</description>
</sklandDocument>

修正写法:使用空元素 <br/> 或 <br></br>。

<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
    <itemId>1</itemId>
    <metainfo>
        <name>示例</name>
        <cover/>
        <subTypes/>
    </metainfo>
    <description>第一行<br/>第二行</description>
</sklandDocument>

<annotation> 结构错误与禁止嵌套

包含两条消息:

  • <annotation> must contain exactly one <title> and one <content>.

  • Nested annotations are not supported.

  • 错误类型:XmlWikiConversionError

  • 问题原因:<annotation> 缺少 <title> 或 <content>、出现多个 <title>/<content>、包含多余子元素,或在 <title> 或 <content> 内部(直接或间接)再次嵌套了 <annotation>。

错误写法:

<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
    <itemId>1</itemId>
    <metainfo>
        <name>示例</name>
        <cover/>
        <subTypes/>
    </metainfo>
    <description>
        <annotation>
            <title>外层注释</title>
            <content>
                <annotation>
                    <title>非法内层注释</title>
                    <content>不可嵌套</content>
                </annotation>
            </content>
        </annotation>
    </description>
</sklandDocument>

修正写法:确保每个 <annotation> 恰好有一个 <title> 和一个 <content>,并将内层说明改为普通段落或强调样式。

<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
    <itemId>1</itemId>
    <metainfo>
        <name>示例</name>
        <cover/>
        <subTypes/>
    </metainfo>
    <description>
        <annotation>
            <title>外层注释</title>
            <content>使用 <b>粗体</b> 或普通段落解释次级概念。</content>
        </annotation>
    </description>
</sklandDocument>

Unsupported inline tag <tag>.、Unsupported inline kind '<kind>'. 与 Unsupported inline type.

  • 错误类型:XmlWikiConversionError
  • 问题原因:在行内样式容器(如 <b>、<i>、<color>、<title>)中放入了不支持的行内元素或块级元素(例如在 <b> 中放 <table> 或 <span>);JSON 解析遇到未知 inline.kind;或手工构造的 DocumentModel 含有未定义的 inlineType。

错误写法:

<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
    <itemId>1</itemId>
    <metainfo>
        <name>示例</name>
        <cover/>
        <subTypes/>
    </metainfo>
    <description>
        <b><span>不支持 span</span></b>
    </description>
</sklandDocument>

修正写法:仅使用合法的行内元素组合。

<?xml version="1.0" encoding="UTF-8"?>
<sklandDocument>
    <itemId>1</itemId>
    <metainfo>
        <name>示例</name>
        <cover/>
        <subTypes/>
    </metainfo>
    <description>
        <b><color value="f_blue">合法行内组合</color></b>
    </description>
</sklandDocument>

另见