我有一个结合了以下限制和元素的 XSD 架构
<?xml version="1.0" encoding="UTF-8"?>
...
<xsd:simpleType name="dollar11neg">
<xsd:restriction base="xsd:string">
<xsd:pattern value="-?\d?\d?\d?\d?\d?\d?\d?\d\.\d\d"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="Price" type="dollar11neg"/>
<xsd:element name="Item">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="Price" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
...
XSD.exe 不会生成限制。我想知道是否有人知道可以生成包含限制的类的工具。
这样做的目的是,在序列化期间或之前,如果字段的值格式不正确(缺少小数位),我可以实现逻辑来查看值所需的格式,并根据模式限制进行更正.
而且我不想手动查看整个 xsd 模式来找出每个字段的模式并硬编码模式。