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

Bug 322836

Summary: Wrong default value generated for base64binary simple types
Product: [WebTools] WTP Source Editing Reporter: Valentin Baciu <valentinbaciu>
Component: wst.xsdAssignee: Valentin Baciu <valentinbaciu>
Status: CLOSED FIXED QA Contact: Valentin Baciu <valentinbaciu>
Severity: normal    
Priority: P2 CC: ccc, thatnitind
Version: 3.0.5Flags: thatnitind: review+
Target Milestone: 3.0.5 P   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 322841, 322842    
Attachments:
Description Flags
Sample schema
none
New failing JUnit
none
Patch none

Description Valentin Baciu CLA 2010-08-16 16:14:28 EDT
Created attachment 176724 [details]
Sample schema

To recreate the problem:
- place the attached schema in a workspace project (if using a simple project, add the validation builder)
- right click the schema and select Generate->XML...
- use the default values in the wizard
- click Finish

The generator produces an XML instance with the following validation errors:

Description	Resource	Path	Location	Type
cvc-datatype-valid.1.2.1: '0' is not a valid value for 'base64Binary'.	Test.xml	TestBase64	line 3	XML Problem
cvc-type.3.1.3: The value '0' of element 'tns:Test' is not valid.	Test.xml	TestBase64	line 3	XML Problem
Comment 1 Valentin Baciu CLA 2010-08-16 16:19:20 EDT
The problem code is in org.eclipse.wst.xsd.contentmodel.internal.XSDTypeUtil. The default value provided for base64Binary is the literal string 0, which is not a valid base64 value.

The solution seems to be to encode the literal string 0 as base64, which is the literal string MA==.
Comment 2 Valentin Baciu CLA 2010-08-16 16:28:30 EDT
Created attachment 176728 [details]
New failing JUnit

Apply to org.eclipse.wst.xsd.core.tests.
Comment 3 Valentin Baciu CLA 2010-08-16 16:29:04 EDT
Created attachment 176729 [details]
Patch

Apply to org.eclipse.wst.xsd.core.
Comment 4 Valentin Baciu CLA 2010-08-16 16:30:25 EDT
Hi Nitin, please review and consider approving this fix for WTP 3.0.5 patches.
Comment 5 Carl Anderson CLA 2010-08-20 08:07:56 EDT
Committed Patch to R3_0_5_patches.
Comment 6 Valentin Baciu CLA 2010-08-25 11:40:28 EDT
Verified. Closing.