Announcement Announcement Module
Collapse
No announcement yet.
Access to the Marshaller properties Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Access to the Marshaller properties

    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!

  • #2
    Originally posted by slepage_dhs
    Thanks for the great work.
    Thanks!

    Originally posted by slepage_dhs
    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/pro.../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,

    Comment


    • #3
      Many thanks. I look forward to seeing it.

      Comment


      • #4
        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.

        Cheers,

        Comment


        • #5
          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?

          Comment


          • #6
            Originally posted by slepage_dhs
            There is an issue with this solution however when using JAXB 2.0 mapped classes.
            Yes, an issue 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,

            Comment


            • #7
              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.

              Comment


              • #8
                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?

                Comment


                • #9
                  Originally posted by slepage_dhs
                  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,

                  Comment


                  • #10
                    oxm namespace support for setting marshaller properties

                    Hi Arjen,

                    Is it possible that we can extend the functionality so that you can also set these properties by using the oxm schema namespace?

                    Comment

                    Working...
                    X