Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml xsd:具有特定精度的日期时间_Xml_Xsd_Precision - Fatal编程技术网

Xml xsd:具有特定精度的日期时间

Xml xsd:具有特定精度的日期时间,xml,xsd,precision,Xml,Xsd,Precision,我使用的XSD具有如下元素: <xsd:element name="TdlOrderTimestamp" type="xsd:dateTime" minOccurs="0"/> 我们应该要求: <TdlOrderTimestamp>2015-05-12T18:58:02+00:00</TdlOrderTimestamp> <TdlOrderTimestamp>2015-05-12T18:58:02.123+00:00</TdlOrderT

我使用的XSD具有如下元素:

<xsd:element name="TdlOrderTimestamp" type="xsd:dateTime" minOccurs="0"/>
我们应该要求:

<TdlOrderTimestamp>2015-05-12T18:58:02+00:00</TdlOrderTimestamp>
<TdlOrderTimestamp>2015-05-12T18:58:02.123+00:00</TdlOrderTimestamp>
2015-05-12T18:58:02.123+00:00

在XSD中指定此需求的最简单方法是什么?理想情况下,我希望尽可能接近
xsd:dateTime
和ISO8601的其他习惯用法和特性。

一个简单的解决方案是定义一个新的简单类型,扩展xsd:dateTime,并添加一个模式限制,指示值必须包含一个后跟三位数字的点。例如:

<xsd:simpleType name="dateTimeWithPrecision">
    <xsd:restriction base="xsd:dateTime">
        <xsd:pattern value=".*\.\d{3}.*"/>
    </xsd:restriction>
</xsd:simpleType>

如果需要,可以将该模式调整为其他所需的日期时间格式