7 Replies Latest reply on Feb 3, 2010 7:35 AM by Francisc

    VO to XML and XML to VO mapping?

    ForestDemon

      Are there any tools out there to map VOs to XML and back?

       

      The server is not invloved here and I just need a valid solution in AS. I'm finding that doing this is becomming a pain anytime I add to one of the VOs or the XML structure. My VOs follow the XML structure in that there are some VOs enbedded in others, etc...

       

      I've googled a few options but nothing that looks promising.

       

      Thank folks...

        • 1. Re: VO to XML and XML to VO mapping?
          jake_flex Level 2

          Could you provide a bit more information on your problem. Answering at least some of the following questions helps others to understand your problem

           

          - By VO you mean Value Object?

          - What is your use case for the VOs?

          - Why you need to map them to XML and back?

          - What are the tools you have found and what is the problem with those?

          - What prevents you from writing this code yourself?

          • 2. Re: VO to XML and XML to VO mapping?
            ForestDemon Level 1

            1) yes, VO = Value Object.

             

            2) without writing a novel about the use cases for the VOs, they interact between two systems. there is a top level(root VO if you will) with other VOs that are embedded. these follow the XML structure i talk about exactly.

             

            3) we have them defined on disk in the form of XML cuz we need to use that structure in different apps on different systems...no server and no ORM(such as WebOrb or Lucene) involved.

             

            4) i have found no tools so far that fit my needs. that's why i'm asking on here.

             

            5) i have written some classes that somewhat do what i need to do, but it becomes harder and harder to manage if we change the VO or XML structure. it's a maintenance struggle. and when i say struggle, i mean it's hard to maintain the classes that manage the mapping between the two. the app is structured to a MVC type of architecture, etc...

             

             

            - if there is nothing out there that can manage such mapping, so be it. i already have something that works, but again, it's becoming rough to manage and maintain and i'd like to keep the app as true to our architecture as possible.

             

            thanks to all...

            • 3. Re: VO to XML and XML to VO mapping?
              jake_flex Level 2

              OK, that clarifies few things.

               

              I think your needs are so specific that finding a ready-made tool is a bit hard.

               

              5) i have written some classes that somewhat do what i need to do, but it becomes harder and harder to manage if we change the VO or XML structure. it's a maintenance struggle. and when i say struggle, i mean it's hard to maintain the classes that manage the mapping between the two. the app is structured to a MVC type of architecture, etc...

               

              I don't quite understand how are you doing the conversion at the moment. Can you give an example of your XML structure and how do you convert it to a VO? Do you need to map them at run-time?

               

              I'd try to define the XML and VO structure as detailed as possible, so that as few modifications as possible would be made to those. I know sometimes it  is is hard to know in advance what is actually needed.

              • 4. Re: VO to XML and XML to VO mapping?
                ForestDemon Level 1

                thanks for your input jake. i totally agree with you with regards to having a well thought out defininition of the VOs and XML structure ahead of time. if there are minor changes, it's not too bad to deal with, but if there are larger changes down the road it becomes a pain in the ***.

                 

                cheers...

                • 5. Re: VO to XML and XML to VO mapping?
                  Francisc Level 3

                  If you know the structure of the XML incoming, just parse the XML, instantiate the VO and pass in the values of the XML that should be in an Array or ArrayCollection after parsing.

                   

                  For the second part is exactly the opposite:

                  Run a FOR loop to get all the Array's/ArrayCollection's data, create the XML as a long string, then write a file on the disk with that data in it.

                  • 6. Re: VO to XML and XML to VO mapping?
                    ForestDemon Level 1

                    i'm already doing that.

                    • 7. Re: VO to XML and XML to VO mapping?
                      Francisc Level 3

                      That should be fine then, AS3 is fast enough.