简体   繁体   中英

How to generate XSD from Class with restrictions

Is there a way how to decorate property of datacontract object, so the generated xsd will contain MaxLenght restriction?

Eg I can imagine I need something like this:

[XmlElement(MaxLengthAttribute = "12")]
public string Name;

and something like this should be included in the output from xsd.exe:

<xs:element name="name">
  <xs:simpleType>
    <xs:restriction base="xs:string">
      <xs:maxLength value = "12"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>

Is there a way to do it? To define the restrictions in C# class in such way, the xsd.exe tool will generate the restrictions into the xsd file?

不,没有办法做到这一点。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM