xml - 创建 XML 模式
问题描述
我有一个格式如下的 XML 文件:
<information xmlns:xlink="http://www.w3.org/1999/xlink">
<fact>
<header>some text</header>
<text>some text</text>
</fact>
<information>
我想知道是否有人可以帮助我创建一个 XML 模式文件?我目前有以下内容:
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="information">
<xs:complexType>
<xs:sequence>
<xs:element name="fact">
<xs:complexType>
<xs:sequence>
<xs:element name="heading" type="xs:string"/>
<xs:element name="description" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
但是,当输入验证器时,会出现以下错误:
无效。错误 - 第 12、9 行:org.xml.sax.SAXParseException;行号:12;列号:9;cvc-complex-type.2.4.d:发现以元素“事实”开头的无效内容。此时不需要子元素。
谢谢你。
解决方案
错误消息指向您输入的第 12 行。显示的示例输入只有 7 行,因此您必须验证不同的实例。
我的猜测是,基于没有任何信息,该fact
元素作为该元素的子元素出现了不止一次information
。
如果是这种情况,那么架构需要允许这样做:更改<xs:element name="fact">
为<xs:element name="fact" maxOccurs="unbounded">
推荐阅读
- reactjs - 如何在获取数据之前等待身份验证状态加载到客户端
- list - Python 数据结构编程(列表)
- r - 嵌套数据框在使用 ifelse 条件发生变异后丢失格式
- sql - 分页很重的SQL查询
- python - 不拆分怎么解决
- python - 使用 Python 将使用 BS4 抓取的数据发送到 sqlite3 数据库
- java - Apache jClouds - 我们可以将身份验证 keystone v3 与 application_credential 一起使用吗?
- java - springdoc-openapi-ui OAuth 2.0 授权代码流与 PKCE
- python - 使用 Python 如何用字符串“abc”替换字符串中的任意数量的子字符串,以美元符号 ($) 开头?
- java - org.apache.hadoop.io.compress.GzipCodec,在这个类中GzipOutputStream没有关闭,所以内存泄漏