Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327031 - Schema Validation on Marshal Operation
Summary: Schema Validation on Marshal Operation
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-05 14:03 EDT by Blaise Doughan CLA
Modified: 2022-06-09 10:29 EDT (History)
3 users (show)

See Also:


Attachments
Core - Fix (9.32 KB, patch)
2010-11-08 16:42 EST, Blaise Doughan CLA
no flags Details | Diff
MOXy - Fix (33.50 KB, patch)
2010-11-08 16:43 EST, Blaise Doughan CLA
no flags Details | Diff
MOXy - Test Cases (42.72 KB, patch)
2010-11-10 16:54 EST, Blaise Doughan CLA
no flags Details | Diff
Core - Fix (17.64 KB, patch)
2010-11-10 16:54 EST, Blaise Doughan CLA
no flags Details | Diff
MOXy - Fix (555 bytes, patch)
2010-11-10 16:55 EST, Blaise Doughan CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Blaise Doughan CLA 2010-10-05 14:03:02 EDT
When an XML Schema is set on Marshaller, the Marshaller should perform validation based on that schema during the marshal operation.  Currently this is not supported.
Comment 1 Fabrizio Fortino CLA 2010-11-03 08:40:38 EDT
I think the same problem is present in the unmarshaller. I am not able to validate an xml file. Digging into the source code I have found the following in the initialize() method of the class org.eclipse.persistence.oxm.XMLUnmarshaller

// Waiting on XDK to fix bug #3697940 to enable this code
//initializeSchemas();
setValidationMode(NONVALIDATING);

Unfornately any bug with id #3697940 is present in bugzilla. Is this feature in development? if yes, when is the expected release date?

Thanks,
Fabrizio
Comment 2 Blaise Doughan CLA 2010-11-03 16:57:38 EDT
I have opened the following bug for the unmarshal issue:

- https://bugs.eclipse.org/bugs/show_bug.cgi?id=329398

I believe I have the fix (see attachments on bug), but I still need to do more formal testing tomorrow.
Comment 3 Blaise Doughan CLA 2010-11-08 16:42:42 EST
Created attachment 182667 [details]
Core - Fix
Comment 4 Blaise Doughan CLA 2010-11-08 16:43:06 EST
Created attachment 182668 [details]
MOXy - Fix
Comment 5 Blaise Doughan CLA 2010-11-10 16:54:03 EST
Created attachment 182847 [details]
MOXy - Test Cases
Comment 6 Blaise Doughan CLA 2010-11-10 16:54:31 EST
Created attachment 182849 [details]
Core - Fix
Comment 7 Blaise Doughan CLA 2010-11-10 16:55:17 EST
Created attachment 182850 [details]
MOXy - Fix
Comment 8 Blaise Doughan CLA 2010-11-11 13:20:48 EST
Fix checked into trunk at rev:  8492

Code reviewed by:  Matt MacIvor

Core Fix:
- Create a new class called ValidatingMarshalRecord.  This class wraps a MarshalRecord and a ContentHandlerRecord that delegates calls to a ValidatorHandler.
- Added an ErrorHandler property to xmlmarshaller/CustomErrorValidationEventHandler.java

MOXy Fix:
- Similar to what we do in JAXBUnmarshaller, the JAXBMarshaller now sets a JAXBErrorHandler on the underlying XMLMarshaller.

MOXy Test Cases:
- Added some tests specifically to handle schema validation.
- Added a new marshal test to XMLMappingTestCases that runs all the child tests using a ValidatingMarshalRecord.
Comment 9 Eclipse Webmaster CLA 2022-06-09 10:29:39 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink