View Full Version : Access to the Marshaller properties
slepage_dhs
Mar 21st, 2006, 06:09 PM
Thanks for the great work.
In the OXM package, do you have any plans to expose the various marshaller properties? For instance the ability to 'pretty print' the XML file resides in the jaxb.formatted.output for JAXB and in the XMLOptions class for XMLBeans. Or am I missing something?
Thanks!
Arjen Poutsma
Mar 21st, 2006, 06:35 PM
Thanks for the great work.
Thanks!
In the OXM package, do you have any plans to expose the various marshaller properties? For instance the ability to 'pretty print' the XML file resides in the jaxb.formatted.output for JAXB and in the XMLOptions class for XMLBeans. Or am I missing something?
You're not missing something, though the XmlBeansMarshaller already has a setter for a XmlOptions object. It just so happens that XmlOptions does not follow the JavaBeans contract, so that you cannot configure it in your application context. So I guess we will need to make some sort of XmlOptionsFactoryBean.
In any case, it sound like a great feature to add. I've created a JIRA issue for it here: http://opensource2.atlassian.com/projects/spring/browse/SWS-16, which you can scan to track progress. We'll probably include this in the next release, scheduled for the beginning of April.
Cheers,
slepage_dhs
Mar 21st, 2006, 06:43 PM
Many thanks. I look forward to seeing it.
Arjen Poutsma
Mar 22nd, 2006, 05:36 AM
Added in CVS.
JaxbMarshaller now has a marshallerProperties and a unmarshallerProperties. These can be used to set JAXB properties on the underlying marshaller and unmarshaller respectively. For instance, to pretty print the output XML, use "jaxb.formatted.output" as a key, and true as a value.
Additionally, a validating property was added to the JaxMarshaller, to validate incoming XML.
I also created an XmlOptionsFactoryBean. It has an options property, which can be used to specific XMLBeans options. For instance, to pretty print the output XML, use "SAVE_PRETTY_PRINT" as a key, and true as a value. The possible options can be found here (http://xmlbeans.apache.org/docs/2.0.0/reference/org/apache/xmlbeans/XmlOptions.html).
Cheers,
slepage_dhs
Apr 18th, 2006, 05:06 PM
Thanks for the great and quick work.
There is an issue with this solution however when using JAXB 2.0 mapped classes. The setValidating method is deprecated for JAXB 2.0 Unmarshallers and when called throws an UnsupportedOperation exception. According to the API we need call the setSchema(javax.xml.validation.Schema schema) to enable validation. I don't know if the intention was support JAXB 1.0 and 2.0 but in my case 2.0 was requested by the architect. :)
Thoughts?
Arjen Poutsma
Apr 19th, 2006, 01:57 AM
There is an issue with this solution however when using JAXB 2.0 mapped classes.
Yes, an issue (http://opensource.atlassian.com/projects/spring/browse/SWS-22) was already created for this, and it has been fixed in CVS. However, since anonymous CVS has not been in sync with developer CVS, it pretty difficult to get the new sources :-(. Hopefully, this will be fixed by sourceforge soon.
Cheers,
Arjen Poutsma
Apr 19th, 2006, 04:57 AM
As a quick workaround, you can comment out the setValidating() in the sources you downloaded as part of the release, and do an "ant dist" to create a new spring-oxm jar.
slepage_dhs
Apr 19th, 2006, 09:24 AM
I was heading in that direction. Thank you again for your quick response on this. Sorry I didn't catch the JIRA issue before I posted. Any eta on the release of the fix?
Arjen Poutsma
Apr 19th, 2006, 06:05 PM
Any eta on the release of the fix?
Well, I don't have a release planned for this month, because there are still a lot of outstanding issues to be implemented. But I do want to make nightly builds available asap. Stay tuned.
Cheers,
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.