Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 313568

Summary: JAXB Externalized Metadata: minoccurs for xml-path elements not being set and are hence required
Product: z_Archived Reporter: David McCann <david.mccann>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: blaise.doughan
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 308677    
Attachments:
Description Flags
proposed fix and updates tests none

Description David McCann CLA 2010-05-19 12:24:24 EDT
When we generate schema components based on a given xml-path we are not setting the minOccurs value on the path elements.  This results in the default value of "1" being used.  

We should be setting minOccurs on each path element up to the last one, and perhaps on the last element unless it has 'required' set to true/false.
Comment 1 David McCann CLA 2010-05-19 12:26:55 EDT
This blocks bug# 308677 (JAXB Externalized Metadata JUnit: mappings tests should validate instance docs against generated schema) because in the read-only case, to be valid against the schema the instance document must have empty elements up to and including the last element of the path.  For example:

<employee><read-only><stuff/></read-only></employee>

BUT, when we marshal we will only write out:

<employee/>

Which is not valid against the schema.
Comment 2 David McCann CLA 2010-05-19 12:32:25 EDT
Test method testSchemaGenAndValidation in externalizedmetadata.mappings.anyattribute.AnyAttributeMappingTestCases contains commented out code that can verify the fix.
Comment 3 David McCann CLA 2010-05-20 13:01:06 EDT
Test method testSchemaGenAndValidation in
externalizedmetadata.mappings.anyattribute.AnyCollectionMappingTestCases and externalizedmetadata.mappings.anyattribute.AnyObjectMappingTestCases contains commented out code that can verify the fix.
Comment 4 David McCann CLA 2010-05-20 15:25:02 EDT
Test method testSchemaGenAndValidation in
externalizedmetadata.mappings.binarydatacollection.BinaryDataCollectionMappingTestCases has a commented out section that can be enabled when this bug is fixed.
Comment 5 Matt MacIvor CLA 2010-05-20 15:42:26 EDT
Created attachment 169404 [details]
proposed fix and updates tests
Comment 6 Matt MacIvor CLA 2010-05-21 09:07:02 EDT
Attached patch checked into SVN
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:28:50 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink