Wednesday, 13 June 2012

XSD: restriction on type to not be empty or blank

I wanted to create a SimpleType called 'ValidInput', basically i don't want to allow empty spaces. I started with below but for some reasons it worked on XML SPY, but not thru c#.

  <xs:simpleType name="ValidInput">
    <xs:restriction base="xs:string">
      <xs:minLength value="1"/>
      <xs:whiteSpace value="collapse"/>
    </xs:restriction>
  </xs:simpleType>

But below worked, can't figure out why


<xs:simpleType name="ValidInput">
    <xs:restriction base = "xs:string">
       <xs:minLength value="1" />
       <xs:pattern value=".*[^\s].*" />
   </xs:restriction>
</xs:simpleType>

No comments: