开发者

XSD minLength not defined, what will be default minLegnth?

I have a xsd definition as below

<xs:simpleType name="ShortNam开发者_如何学Pythone">
    <xs:restriction base="xs:string">
      <xs:maxLength value="3"/>
    </xs:restriction>
  </xs:simpleType>

I have given only maxLength and not defined minLength. Does it mean that I can have length of 'ShortName' can be 0,1,2,3 characters?

If I haven't explicitly set the minimum length, will the minimum length will be defaulted to 0 (minLength=0)?


http://www.w3schools.com/schema/schema_facets.asp

minLength: Specifies the minimum number of characters or list items allowed. Must be equal to or greater than zero.

If not specified I think default is Zero.


From the w3c:

Validation Rule: maxLength Valid

A value in a value space is facet-valid with respect to maxLength, determined as follows:

1 if the {variety} is atomic then

1.1 if {primitive type definition} is string or anyURI, then the length of the value, as measured in characters must be less than or equal to {value};

1.2 if {primitive type definition} is hexBinary or base64Binary, then the length of the value, as measured in octets of the binary data, must be less than or equal to {value};

1.3 if {primitive type definition} is QName or NOTATION, then any {value} is facet-valid.

2 if the {variety} is list, then the length of the value, as measured in list items, must be less than or equal to {value}

According to this definition, and in the absence of a minLength restriction, any length value which is less than or equal to the maxLength you define will be valid. Ergo, zero will be the default minLength for a specification-compliant XML validator.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜