5 Replies Latest reply on Mar 1, 2007 7:55 AM by Tom Fennelly

    XML2POJO Transformation

    Mohamed Riyaz Newbie

      Went through the quickstart "transform_XML2POJO". But this transformation from XML to Javabean using smooks works only for fields of type String. Also it does not work for cases where the Javabean has an instance of another Javabean as a field.

      Does this require some configuration.

      Pls help.

        • 1. Re: XML2POJO Transformation
          Tom Fennelly Master

          This sample uses the Smooks Javabean Cartridge which is currently quite simple in terms of what it supports (but still quite powerful I think).

          So, the setter methods on the beans currently only support Strings, with the data coming directly from the XML. Also, as you say, it doesn't allow you to nest bean instances - it's totally flat. This last point points to a feature that would be very useful and something I've had in mind to add for some time now. Would you like to contribute this feature ?? ;-)

          Of course it depends on what you're trying to do, but the fact that the setter methods need to be Strings does not stop you having more complex types returned from whatever getter methods are added to the beans. This is typically how this might be used:
          1. String injected through the setter method,
          2. String analysed and transformed into more complex/usable object instances,
          3. More usable object instance made available from bean via getter methods.

          Thanks for the feedback!

          • 2. Re: XML2POJO Transformation
            Daniel Marchant Newbie

            As part of IR http://jira.jboss.com/jira/browse/JBESB-425 we are looking at providing an XStream way of deserializing beans.

            Similar to the way they are serialized with the existing ObjectToXStream approach.

            • 3. Re: XML2POJO Transformation
              Mohamed Riyaz Newbie

              Thankyou tfennelly


              Of course it depends on what you're trying to do, but the fact that the setter methods need to be Strings does not stop you having more complex types returned from whatever getter methods are added to the beans. This is typically how this might be used:
              1. String injected through the setter method,
              2. String analysed and transformed into more complex/usable object instances,
              3. More usable object instance made available from bean via getter methods.


              The approach that you have suggested seems to solve my problem. Will check it out.

              • 4. Re: XML2POJO Transformation
                Tom Fennelly Master

                 

                "driedtoast" wrote:
                As part of IR http://jira.jboss.com/jira/browse/JBESB-425 we are looking at providing an XStream way of deserializing beans.

                Similar to the way they are serialized with the existing ObjectToXStream approach.


                Sure, this is something "kinda" similar, except that there's a looser coupling between the XML format and the POJO i.e. you can populate the POJO(s) from different XML formats containing the same basic data elements.

                Also, I think you could do some other useful things with this type of thing e.g. generate a different object graph depending on who the participants are in the message exchange i.e. same message generating different object graphs.

                • 5. Re: XML2POJO Transformation
                  Tom Fennelly Master

                   

                  "hmrizin" wrote:
                  Thankyou tfennelly


                  Of course it depends on what you're trying to do, but the fact that the setter methods need to be Strings does not stop you having more complex types returned from whatever getter methods are added to the beans. This is typically how this might be used:
                  1. String injected through the setter method,
                  2. String analysed and transformed into more complex/usable object instances,
                  3. More usable object instance made available from bean via getter methods.


                  The approach that you have suggested seems to solve my problem. Will check it out.


                  Great. If you ever decide that you'd like to add support for nesting beans, be sure to come back to us ;-)