[JAXP-30] none value recognition of minOccurs and maxOccurs Created: 16/Apr/07  Updated: 16/Apr/07  Resolved: 16/Apr/07

Status: Resolved
Project: jaxp
Component/s: www
Affects Version/s: current
Fix Version/s: milestone 1

Type: Bug Priority: Major
Reporter: suchtdenfehler Assignee: Santiago Pericas-Geertsen
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: All
Platform: All

Issuezilla Id: 30


I have an application where xml streams needs to be validated against xsd-schemas.
Using JDK 1.5 (jdk1.5.0_07) this works well and the streams are correctly validated.

When I use Java 1.6 (build 1.6.0-b105) the minOccurs and maxOccurs seams to be
skipped from the validation process and the xml is always reported as valid.

Here is a snippet of my code:

File xmlFile = new File("occurs.xml");

SchemaFactory factory=SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = factory.newSchema(new File("occurs.xsd"));

// get a DOM factory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
// configure the factory

// set schema on the factory

DocumentBuilder documentBuilder = dbf.newDocumentBuilder();

// Check the document
try {
System.out.println(xmlFile.getName() + " is valid.");
catch (SAXException ex) {
System.out.println(xmlFile.getName() + " is not valid because ");

// And the corresponding xml and xsd.


<?xml version="1.0" encoding="ISO-8859-1"?>


<full_name>Hege Refsnes</full_name>

<full_name>Tove Refsnes</full_name>

<full_name>Stale Refsnes</full_name>



<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

<xs:element name="persons">
<xs:element name="person" maxOccurs="unbounded">
<xs:element name="full_name" type="xs:string"/>
<xs:element name="child_name" type="xs:string" minOccurs="0"


Java 1.5 reports:
occurs.xml is not valid because
cvc-complex-type.2.4.d: Invalid content was found starting with element
'child_name'. No child element is expected at this point.

while Java 1.6 reports:
occurs.xml is valid.

I browsed the JAXP Project Page to find the differences from JAXP 1.3 is
included in J2SE 5.0 and the implementation of JAXP 1.4 is part of Java SE 6.0
but found nothing linked to my problem.

Comment by Santiago Pericas-Geertsen [ 16/Apr/07 ]

Some code has changed in JDK 6.0, so this may indeed be a new issue in JDK 6.0.

Comment by Santiago Pericas-Geertsen [ 16/Apr/07 ]

As demonstrated in the test case of JAXP issue 30, the constant-space algorithm for validating a

cannot be applied when an FSA is created to accept a content model that includes, but it is not just a{n,m}

In other words, the optimization introduce for a


was a bit too aggressive and had to be restricted.

Note that the testcase should use an ErrorHandler to receive validation errors; catching a SAXException is
not enought. This patch will be available in the JAXP 1.4.1 nightly build available from this site (see
Downloads section).

Generated at Tue May 05 02:31:20 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.