JDK-8144117 : XML Schema: wrong error for facet with
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxp
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2015-11-26
  • Updated: 2022-08-24
  • Resolved: 2022-05-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 19
19 b23Fixed
Related Reports
Relates :  
Description
Java: JRE: XML Schema: wrong error for facet <xs:length> 

The JRE has an implementation of XML Schema. 

One feature of XML Schema is facets, which are conditions 
on a simple type.  The facets include <xs:length> and <xs:minLength>. 

One simple type can be derived from another, by restriction. 
The rules about using <xs:length> in conjunction with <xs:minLength> 
are here: 

http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#length-coss 

  4.3.1.4 Constraints on length Schema Components 

  Schema Component Constraint: length and minLength or maxLength 

  If length is a member of {facets} then 

  1 It is an error for minLength to be a member of {facets} unless 

  1.1 the {value} of minLength <= the {value} of length and 

  1.2 there is type definition from which this one is derived 
  by one or more restriction steps in which minLength has 
  the same {value} and length is not specified. 

The problem is, the JRE does not appear to honour those rules. 
It is forbidding a combination that I think is legal; 
and, the error message that it issues does not relate correctly 
to the XML Schema that was provided. 

Please fix the JRE so that it honours the rules correctly; 
and also correct the broken error message.
Comments
Fixed by JDK-8282280.
25-05-2022

More information from submitter : ============================= Consider the following example of an XML Schema: <?xml version='1.0'?> <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'> <xs:simpleType name='mjtype1'> <xs:restriction base='xs:string'> <xs:minLength value='3'/> </xs:restriction> </xs:simpleType> <xs:simpleType name='mjtype2'> <xs:restriction base='mjtype1'> <xs:minLength value='3'/> <xs:length value='4'/> </xs:restriction> </xs:simpleType> <xs:element name='top' type='mjtype2'/> </xs:schema> It defines two simple types, mjtype1 and mjtype2. The type mjtype1 is defined by restriction on xs:string, and it adds a facet for <xs:minLength>. The type mjtype2 is defined by restriction on mjtype1, and it repeats the facet for <xs:minLength>, and it adds the facet for <xs:length>. I think that it satisfies the rule from the W3C standard that I quoted above. The value of <xs:minLength> is 3, and of <xs:length> is 4, so it is true: minLength <= length And, mjtype2 is derived by 1 restriction step from mjtype1; and mjtype1 and mjtype2 have the same value for <xs:minLength>; and in mjtype1, <xs:length> is NOT specified. And yet, when compiling it, the JRE issues an error: $ java -cp . tmp jre tmp.xml tmp.xsd ============================================================ mj: building schema... Exception in thread "main" org.xml.sax.SAXParseException; systemId: file:/.../tmp.xsd; lineNumber: 11; columnNumber: 36; length-minLength-maxLength.1.1: For type mjtype2, it is an error for the value of length '-1' to be less than the value of minLength '3'. I have no idea where it is getting the value "-1" for "length", but it's clearly wrong.
26-11-2015