| Summary: | Binder is not removing null attributes | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Blaise Doughan <blaise.doughan> | ||||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | kat, matt.macivor | ||||||
| Version: | unspecified | ||||||||
| Target Milestone: | --- | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows XP | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
Created attachment 191152 [details]
Sample code to demonstrate issue.
Any chance that this could be fixed in a nightly build? I'm getting close to a release date in this bug is critical for the usage of the application. Created attachment 192120 [details]
propsed fix and tests
Attach patch has been checked in to SVN Code reviewed by Blaise Doughan This fix will be available in the next nightly 2.3 build. The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Given the following XML input: <?xml version="1.0" encoding="UTF-8"?> <root parenttool="aValue"> <!-- COMMENT --> </root> If the following code is run: import java.io.File; import javax.xml.bind.Binder; import javax.xml.bind.JAXBContext; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; public class Demo { public static void main(String[] args) throws Exception { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document document = db.parse(new File("input.xml")); JAXBContext jc = JAXBContext.newInstance(Root.class); Binder binder = jc.createBinder(); Root root = (Root) binder.unmarshal(document); root.setParentTool(null); binder.updateXML(root); TransformerFactory tf = TransformerFactory.newInstance(); Transformer t = tf.newTransformer(); t.transform(new DOMSource(document), new StreamResult(System.out)); } } The correct output should be: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <root> <!-- COMMENT --> </root> But is currently (the parenttool attribute should have been removed): <?xml version="1.0" encoding="UTF-8" standalone="no"?> <root parenttool=""> <!-- COMMENT --> </root>