【发布时间】:2020-01-22 12:23:46
【问题描述】:
我有一个可能看起来像这样的元素:
<MyElement start="12.5. 2020" end="6.6 2020" info="Hello world!"/>
还有这个:
<!-- This element still can contain useful info, but is not time-bound -->
<MyElement info="42" />
所以我想设置节点的定义,以便必须存在非属性或两个属性。到目前为止,我只是使用文档来记录需求,但如果它直接在架构中会更好:
<xsd:complexType name="MyElement">
<xsd:attribute name="start" type="MyDate" use="optional">
<xs:annotation>
<xs:documentation>end date must also be present!</xs:documentation>
</xs:annotation>
</xsd:attribute>
<xsd:attribute name="end" type="MyDate" use="optional">
<xs:annotation>
<xs:documentation>start date must also be present!</xs:documentation>
</xs:annotation>
</xsd:attribute>
<xsd:attribute name="info" type="xsd:string" use="required" />
</xsd:complexType>
【问题讨论】:
标签: xml xsd xsd-validation xml-validation