Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please explain difference between inline and not inline XML

 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Could someone post some inline and not inline xml examples and explain the difference.

I'm using Simple to parse an xml file but the only way I could get it to work was to use the @ElementList(inline=true) annotation.

Here's my xml.
It does not look inline as I understand it.


Thanks,

Lou
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lou

If your XML was not inlined, it would look like this:

Notice, the enclosing types parents and children for the lists.

BTW, I assumed you have pasted your XML incorrectly as:

is not valid XML.
 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi James,

It looks to me like not inline would have tags to "group" child elements, such and <parents> and <children> in your example.

I'm just getting started with xml so could you please tell me why mine is not valid? It was not a copy/paste error.

In trying to understand why it's invalid, or not well formed, I checked it at w3, w3schools, and xmlvalidation - all reported valid.

Thanks,

Lou
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I believe this is invalid as the name element has both a value (Parent 2) and child elements. It can't have both.

 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the XML hierarchy takes care of separating the two "name" elements.

However, it will cause programmer confusion later on.

Bill
 
g tsuji
Ranch Hand
Posts: 656
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW, I assumed you have pasted your XML incorrectly as:

is not valid XML.

Whether it is a valid XML or not cannot be ascertain without a schema. It is though a perfectly well-formed XML. (The parent name element has a mixed content type, technically speaking if that helps.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic