0
我有困难的声明包含一个文本字符串,并有两个文本属性的元素:如果我把属性Setting元素内容属性
<?xml version="1.0" encoding="UTF-8"?>
<!-- This schema is not valid -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Favorite" type="xs:string">
<xs:complexType>
<xs:attribute name="car" type="xs:string"/>
<xs:attribute name="fruit" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:schema>
架构通过,像这样:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Favorite" type="xs:string">
</xs:element>
</xs:schema>
或者,如果我省略<xs:element name="Favorite" type="xs:string">
的type="xs:string"
。
所需要的模式应该是验证下面的XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<Favorite car="Volvo" fruit="banana">These are a few of my favorite things</Favorite>
PS:我很抱歉,如果这个问题是相当琐碎。我仍然是XSD的初学者。