开发者

Why isn't my XML date accepting dates in YYYY-MM-DD?

I don't understand why the xsd rule I have created for a date is not working. The rule is: <xs:element name="scan_date" type="xs:date" /> which, accoring to XML Schema Date on W3Schools is specified in the following form "YYYY-MM-DD", yet when the XML Parser in SQL encounters <scan_date>2006-12-15</scan_date> it fails because it doesn't acc开发者_如何学JAVAept the date as valid, yet if I swap the 12 and 15 round it does.


A possible solution using xs:string and a regex restriction:

<xs:element name="scan_date" type="dateType"/>

<xs:simpleType name="dateType">
    <xs:restriction base="xs:string">
        <xs:pattern value="\d{4}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])"/>
    </xs:restriction>
</xs:simpleType>

... adopted from XSD date format overriding

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜