xsd - How do I set a minimum length for an integer in an XML Schema? -


i in process of creating xml schema , 1 of values year. such, i'd ensure values have 4 characters. so, using following syntax:

<xs:element name="publish_year" maxoccurs="1">   <xs:simpletype>     <xs:restriction base="xs:positiveinteger">       <xs:totaldigits value="4"/>     </xs:restriction>   </xs:simpletype>                                       </xs:element> 

if i'm understanding "totaldigits" correctly, pass in "publish_year" value of "2008" or "200". both valid. such, how can structure xsd ensure 4 digits required? @ first blush, i'm guessing i'd use regex, i'd know if i'm overlooking that's baked in (like "totaldigits")

update:

i went following solution. may overkill, gets point across:

<xs:simpletype>     <xs:restriction base="xs:positiveinteger">         <xs:totaldigits value="4" fixed="true"/>         <xs:mininclusive value="1900"/>         <xs:pattern value="^([1][9]\d\d|[2]\d\d\d)$"/>     </xs:restriction> </xs:simpletype> 

how plage of value additional restriction ?

(mininclusive - maxinclusive)

for instance ?

<xs:mininclusive value="1900"/> et <xs:maxinclusive value="2008"/> 

but totaldigits constraint, why not set fixed attribute true ?

if {fixed} true, types current type {base type definition} cannot specify value totaldigits other {value}.

<xs:totaldigits value="4" fixed="true" /> 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -