Xml cvc复合型。2.3:元素';集团';不能有字符[子项],因为类型为';的内容类型仅为元素
我需要从这个XSD创建XML:Xml cvc复合型。2.3:元素';集团';不能有字符[子项],因为类型为';的内容类型仅为元素,xml,xsd,xsd-validation,xml-validation,Xml,Xsd,Xsd Validation,Xml Validation,我需要从这个XSD创建XML: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="group"> <xs:complexType> <xs:sequence> <xs
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="group">
<xs:complexType>
<xs:sequence>
<xs:element name="person" minOccurs="5" maxOccurs="20" type="xs:string"/>
</xs:sequence>
<xs:attribute name="name" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" ?>
<group name="abcd">
xmlns="www.example.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="ex1.xsd">
<person>Joao</person>
<person>Andre</person>
<person>Filipe</person>
<person>Joaquim</person>
<person>Rui</person>
</group>
以下是我尝试过的XML:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="group">
<xs:complexType>
<xs:sequence>
<xs:element name="person" minOccurs="5" maxOccurs="20" type="xs:string"/>
</xs:sequence>
<xs:attribute name="name" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" ?>
<group name="abcd">
xmlns="www.example.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="ex1.xsd">
<person>Joao</person>
<person>Andre</person>
<person>Filipe</person>
<person>Joaquim</person>
<person>Rui</person>
</group>
xmlns=“www.example.org”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance“xsi:schemaLocation=“ex1.xsd”>
若奥
安德烈
菲利佩
华金
芮
我收到此错误:
无效。
错误-第10行,第9行:org.xml.sax.SAXParseException;行号:10;列数:9;cvc复杂类型.2.3:元素“组”不能有字符[子项],因为该类型的内容类型仅为元素
发行数量:
- 正如Filburt提到的,您过早地关闭了开始的
标签。这是导致您立即出错的直接原因。它导致 解析器会将您想要的属性误解为文本 将内容添加到组
元素组
必须采用命名空间XSD对schemaLocation
elementFormDefault=“qualified”
- 等等
XML
若奥
安德烈
菲利佩
华金
芮
将XSD中的“组”定义更改为包含mixed=“true”
当我从Skype复制一个插入了奇怪编码的代码时,出现了这个错误。解决方案是删除粘贴的代码,并手动重写所有错误的编码部分,而不使用任何粘贴的编码字符。在命名空间声明之前关闭
。在这里,您可以通过代码着色很好地看到它。我之前在ex1.xsd的末尾关闭了它,它说它不是有效的xml元素类型组,后面必须跟>或/>在第二个名称空间之后,将关闭开头的组
。相信我,现在的情况是,如果没有任何模式验证它,它甚至都不是有效的Xml。你是什么意思?你的Xml中会有一个悬空的
:..=“ex1.xsd”>
当带有随机缩进的Xml对模式失败时,这对我很有帮助。
<xs:element name="group">
<xs:complexType mixed="true">