Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8750039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:47:45+00:00 2026-06-13T12:47:45+00:00

Say we want to Parse a XML messages to Business Objects. We split the

  • 0

Say we want to Parse a XML messages to Business Objects. We split the process in two parts, namely:

-Parsing the XML messages to XML Grammar Objects.
-Transform XML Objects to Business Objects.

The first part is done automatically, generation a grammar object for each node.

The second part is done following the XML architecture so far. Example:

If we have the XML Message(Simplified):

<Main>
  <ChildA>XYZ</ChildA>
  <ChildB att1="0">
     <InnerChild>YUK</InnerChild>
  </ChildB>
</Main>

We could find the following classes:

DecodeMain(Calls DecodeChildA and B)
  DecodeChildA
  DecodeChildB(Calls DecodeInnerChild)
     DecodeInnerChild

The main problem arrives when we need to handle versions of the same messages. Say we have a new version where only DecodeInnerChild changes(e.g.: We need to add an “a” at the end of the value)

It is really important that the solutions agile for further versions and as clean as possible. I considered the following options:


1)Simple Inheritance:Create two classes of DecodeInnerChild. One for each version.

Shortcomming: I will need to create different classes for every parent class to call the right one.


2)Version Parameter: Add to each method an Object with the version as a parameter. This way we will know what to do within each method according to each version.

Shortcoming: Not clean at all. The code of different versions is mixed.


3)Inheritance + Version Parameter: Create 2 classes with a base class for the common code for the nodes that directly changes (Like InnerChild) and add the version as a parameter in each method. When a node call the another class to decode the child object, it will use one or another class depending on the Version parameter.


4)Some kind of executor pattern(I do not know how to do it): Define at the start some kind of specifications object, where all the methods that are going to be used are indicated and I pass this object to a class that is in charge of execute them.


How would you do it? Other ideas are welcomed.

Thanks in advance. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:47:46+00:00Added an answer on June 13, 2026 at 12:47 pm

    How would you do it? Other ideas are welcomed.

    Rather than parse XML myself I would as first step let something like CodesynthesisXSD to generate all needed classes for me and work on those. Later when performance or something becomes issue I would possibly start to look aound for more efficient parsers and if that is not fruitful only then i would start to design and write my own parser for specific case.

    Edit:

    Sorry, I should have been more specific :P, the first part is done
    automatically, the whole code is generated from the XML schema.

    OK, lets discuss then how to handle the usual situation that with evolution of software you will eventually have evolved input too. I put all silver bullets and magic wands on table here. If and what you implement of them is totally up to you.

    1. Version attribute I have anyway with most things that I create. It is sane to have before backward-compatibility issue that can not be solved elegantly. Most importantly it achieves that when old software fails to parse newer input then it will produce complaint that makes immediately sense to everybody.
    2. I usually also add some interface for converter. So old software can be equipped with converter from newer version of input when it fails to parse that. Also new software can use same converter to parse older input. Plus it is place where to plug converter from totally “alien” input. Win-win-win situation. 😉
    3. On special case of minor change I would consider if it is cheap to make new DecodeInnerChild to be internally more flexible so accepts the value with or without that “a” in end as valid. In converter I have still to get rid of that “a” when converting for older versions.
    4. Often what actually happens is that InnerChild does split and both versions will be used side-by-side. If there is sufficient behavioral difference between two InnerChilds then there is no point to avoid polymorphic InnerChilds. When polymorphism is added then indeed like you say in your 1) all containing classes that now have such polymorphic members have to be altered. Converter should usually on such cases either produce crippled InnerChild or forward to older version that the input is outside of their capabilities.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I want to parse a string with various opening and closing brackets
Say, among other elements I want to parse a C structure, from file1.c :
Let's say this page www.example.com/mypage returns some html that I want to parse in
Say I want to draw a Ball in the scene and here are two
I'm looking for a Java library for SWIFT messages. I want to parse SWIFT
I'm using XML::Simple to parse an XML file which I then want to use
I want to parse information in: http://feeds.informationweek.com/infoweek/news http://feeds.news.com.au/public/rss/2.0/fs_breaking_news_13.xml http://rss.cnn.com/rss/cnn_topstories.rss using php. And save the
Im parsing an XML with NSXMLParser like say in Apple Developer Documentation. Im do
I am new to using GDataXML to parse an xml file. I want to
Say I call XElement.Parse() with the following XML string: var xml = XElement.Parse(@ <?xml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.