Saturday 15 May 2010

validation - XML Schema restrictions on the current date -


Is it possible to restrict the date and time data types for the current date XSD? For example, if you want a maximum notification of the date on the current date:

  & lt; Xs: element name = "DateOfBirths" type = "date of birth" /> & Lt; X: Simple Type Name = "Date of Birth" & gt; & Lt; Xs: restriction base = "x: date" & gt; & Lt; Xs: minInclusive value = "1920-01-01" /> & Lt; Xs: maxInclusive value = "current-date ()" fixed = "true" /> & Lt; / XS: Ban & gt; & Lt; / XS: simpleType & gt;   

If the default copy of this copy is not possible, is there an alternate solution? Any help would be appreciated.

XSD does not support XPath functions to set values ​​in proximity, therefore (as That you probably already know) code in the work won in question.

The most obvious solution is

  • Use XSD 1.1 and check constraint in one argument.
  • Use schematron and check the constraint in a logic.
  • Check the barrier at the application level.
  • Announcement of date of birth type is a schema document of its own; From time to time, prepare a new version of that schema document, using the hand or cron job or something similar in today's schema document

      & lt; Xs: maxInclusive value = "2013-06-20" /> Will happen.   

    and in the schema document prepared yesterday

      & lt; Xs: maxInclusive value = "2013-06-21" /> Will happen.      

No comments:

Post a Comment