是否可以使用模式在XML文档中定义根元素?
这可能吗?我不知道该怎么做。下面应该可以,我还建议W3学校关于模式的部分是否可以使用模式在XML文档中定义根元素?,xml,xsd,Xml,Xsd,这可能吗?我不知道该怎么做。下面应该可以,我还建议W3学校关于模式的部分 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="rootElement" type="RootElementType"/> <xs:complexType name="RootElementType"> <xs:sequence> <xs:e
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="rootElement" type="RootElementType"/>
<xs:complexType name="RootElementType">
<xs:sequence>
<xs:element name="child1" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
<xs:element name="child2" type="xs:string" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="user" type="xs:string" use="required"/>
</xs:complexType>
</xs:schema>
这应该是如下XML结构的模式:
<rootElement user="Bob">
<child1>Hello</child1>
<child1>World</child1>
<child2>Optional</child2>
</rootElement>
你好
世界
可选的