This article is a mirror article of machine translation, please click here to jump to the original article.

View: 29384|Reply: 1

[Source] (Error) cvc-datatype-valid.1.2.1: 'xx' is not a valid value for 'gYearMonth'.

[Copy link]
Posted on 2020-7-15 14:11:53 | | |
The original data types 'gYearMonth' and 'gMonthDay', which represent a combination of years, months, and days in the Gregorian calendar. Leading and trailing spaces are allowed and trimmed. Time zone offset is optional.

XSD 1.1 also provides 2 built-in data types "gYearMonth" and "gMonthDay" to override the combination of 2 attributes within the "date" value using the following rules:

  • The value space of "gYearMonth" is all the values of the combination of "year" and "month" in the Gregorian calendar.
  • Is the lexical space of "gYearMonth" all possible "gYearMonth" values represented by (year)(mont)(timezoneOffset)? Patten.
  • The value space of "gMonthDay" is all the values of the combination of "month" and "day" in the Gregorian calendar year.
  • Is the lexical space of "gMonthDay" all possible "gMonthDay" values represented in -(month)-(day)(timezoneOffset)? Patten.
  • The "timezoneOffset" property is optional, and the default time zone is not defined.
  • Allow and trim leading and trailing spaces.


To validate these rules, I wrote this simple XSD document that declares XML elements using the "gYearMonth" and "gMonthDay" data types:


3 valid GYearMonth values


3 invalid GYearMonth values


2 valid GMonthDay values


3 invalid GMonthDay values


If there is an error in the XML, it will prompt as follows:

herong> java XsdSchemaValidator
^^^ gYearMonth_gMonthDay_datatype_test.xsd
^^^ gYearMonth_gMonthDay_datatype_test.xml

Error:
   Line number: 13
   Column number: 42
   Message: cvc-datatype-valid.1.2.1: '101-01' is not a valid value
   for 'gYearMonth'. ("Year" must be at leat 4 digits)

Error:
   Line number: 13
   Column number: 42
   Message: cvc-type.3.1.3: The value '    101-01    ' of element
   'GYearMonth' is not valid.

Error:
   Line number: 14
   Column number: 50
   Message: cvc-datatype-valid.1.2.1: '2147483648-12Z' is not a valid
   value for 'gYearMonth'. ("year" value out of "int" range")

Error:
   Line number: 14
   Column number: 50
   Message: cvc-type.3.1.3: The value '    2147483648-12Z    ' of
   element 'GYearMonth' is not valid.

Error:
   Line number: 15
   Column number: 41
   Message: cvc-datatype-valid.1.2.1: '2013Z' is not a valid value for
   'gYearMonth'. (Missing "month")

Error:
   Line number: 15
   Column number: 41
   Message: cvc-type.3.1.3: The value '    2013Z    ' of element
   'GYearMonth' is not valid.

Error:
   Line number: 22
   Column number: 38
   Message: cvc-datatype-valid.1.2.1: '--1-1' is not a valid value for
   'gMonthDay'. (2 digits needed for "month" and "day")

Error:
   Line number: 22
   Column number: 38
   Message: cvc-type.3.1.3: The value '   --1-1    ' of element
   'GMonthDay' is not valid.

Error:
   Line number: 23
   Column number: 46
   Message: cvc-datatype-valid.1.2.1: '--13-05-05:00' is not a valid
   value for 'gMonthDay'. ("month" value out of range)

Error:
   Line number: 23
   Column number: 46
   Message: cvc-type.3.1.3: The value '   --13-05-05:00    ' of
   element 'GMonthDay' is not valid.

Error:
   Line number: 24
   Column number: 43
   Message: cvc-datatype-valid.1.2.1: '--12-05:00' is not a valid
   value for 'gMonthDay'. (Missing "day" value)

Error:
   Line number: 24
   Column number: 43
   Message: cvc-type.3.1.3: The value '   --12-05:00    ' of element
   'GMonthDay' is not valid.

Failed with errors: 12






Previous:Angular 9 Series (XI) 5 Ways to Define Styles
Next:C# Unity Series (1) Console programs implement interface dependency injection
Posted on 2020-7-15 15:00:10 |
Lalala, la, I'm a little clumsy newspaper seller
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com