在XML Schema中对time属性应用限制
发布时间:2020-12-15 23:53:22 所属栏目:百科 来源:网络整理
导读:我想对 XML Schema应用一个特定的限制(我很少有经验). 我有一个xsd:time类型的属性: xsd:attribute name="hour" type="xsd:time" use="required"/ 我想要的是应用限制,以便XML仅在半小时的时间间隔内有效.例如,10:00,12:30,15:30,20:00将是小时属性的
我想对
XML Schema应用一个特定的限制(我很少有经验).
我有一个xsd:time类型的属性: <xsd:attribute name="hour" type="xsd:time" use="required"/> 我想要的是应用限制,以便XML仅在半小时的时间间隔内有效.例如,10:00,12:30,15:30,20:00将是小时属性的有效值,但不是10:45,11:12,15:34等. 我怎样才能做到这一点?我的搜索没有给出有用的东西. 先感谢您.
你可以用这种方式定义你的时间.
<xsd:attribute name="hour" type="Time" use="required"/> <xsd:simpleType name="Time"> <xsd:restriction base="xsd:time"> <xsd:enumeration value="00:00:00"/> <xsd:enumeration value="00:30:00"/> <xsd:enumeration value="01:00:00"/> <xsd:enumeration value="01:30:00"/> <xsd:enumeration value="02:00:00"/> <xsd:enumeration value="02:30:00"/> <xsd:enumeration value="03:00:00"/> <xsd:enumeration value="03:30:00"/> <!-- etc etc --> </xsd:restriction> </xsd:simpleType> 要么 <xsd:simpleType name="Time"> <xsd:restriction base="xsd:time"> <xsd:pattern value="((0[0-9]|1[0-9]|2[0-3]):[0|3][0]:[0][0])"/> </xsd:restriction> </xsd:simpleType> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |