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的初學者。