• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

How XML should display in a text editor

Hello,

I recently had some development work done so that one of our systems would produce an XML file. When I open the XML file in a text editor, all of the data inside is on one line, rather than being formatted as below. The file gets generated from one of our systems, which we then send to another company. They are saying that the new file won't import because they are expecting the carriage returns like in the example, but this doesn't have them.
When I spoke to the company that developed this they are telling me XML files are not supposed to have carriage returns in them. I would like to know if this is correct, as every XML file I have opened using a text editor in the past has returns. And when I create an XML file from excel, it has carriage returns?

Could somebody please tell me if somebody is trying to fox me here?
<XML>
<Name>Dan</Name>
<Age>28</Age>
<Sex>Male</Sex>
</XML>

Open in new window

0
forzaaw
Asked:
forzaaw
  • 3
  • 2
1 Solution
 
Geert BormansInformation ArchitectCommented:
They are all right, but not quiet.

Cariage returns can be relevant in an XML document, specially if you are dealing with narrative content.
From the example I see that the your document is pretty data oriented.
So, the carriage returns are irrelevant to your document, any receiving application should work, regardless the carriage returns are there or not.

> are saying that the new file won't import because they are expecting the carriage returns like in the example, but this doesn't have them.
This means they are not using a real XML aware import filter. An XML parser doesn't care, since the carriage returns are irrelevant

> When I spoke to the company that developed this they are telling me XML files are not supposed to have carriage returns in them.
In a sense they are right. The carriage returns are irrelevant for your data, so they don't necessary have to be in there.
Most tools and editors don't respond well to extremely long lines. And they should know that.
For that, this company would have been smarter to add carriage returns in there. Basically I expect this to be a little effort for this company to add the carriage returns.

Honestly
if the receiving company requires the irrelevant carriage returns to be there (which they should not), you can ask the creating company to add the carriage returns,they should be able to do taht add a very low cost (and they should have done that in the first place)
0
 
forzaawAuthor Commented:
Hello,

Thank you for answering. The example I put up isnt what is contained in the actual file, but it was just to show the lay out.  for example their interpretation would be all of that but on one line.

They are trying to tell me that they will need to write the whole thing as its not XML im after its a text file which looks like XML. Based on what your saying I see what they are getting at. Surely it cannot be difficult for them to add the returns in?
0
 
Geert BormansInformation ArchitectCommented:
> They are trying to tell me that they will need to write the whole thing as its not XML im after its a text file which looks like XML.

That is bullshit, if it is wellformed XML, it is XML.
XML by the way is a text format, with some wellformedness rules,
the carriage returns don't play in the wellformedness checking process
So either with or without the carriage returns, it would still be XML.

One of the design principles of XML was having a language that would be machine processable and human readable at the same time
All on one line is not particularly "human readable"
So I would argue that the XML with carriage returns would fit the definition "XML" better than the one-line approach

I have to say that it is not smart from the receiving end to depend on the carriage returns to be there.
That is clearly a flaw in their application.
But in any case, it is not smart of the creating end to not put carriage returns in the XML, since a lot of tools or programming languages break on extremely long lines, or they split randomly. And that is far worse than pushing irrelevant carriage returns in the XML for convenience.

I have been working with XML since day one of its existence, and I have never encountered a company that did not put carriage returns in the XML they created... just to be on the safe side.
I think that the company that created your XML is playing this, making it sound worse than it actually is to charge you too much for the change.

There are tools or methods available to "pretty print" your XML, so that it no longer suffers from the one line issue,
and looks nice in a text editor
Both sides can apply these methods on the one line XML without too much hassle,
and it would be a sign of good contractor-customer relationship, to simply do that, without making a fuzz,
at least that is what I would do
0
 
forzaawAuthor Commented:
Excellent, and thank you very much for your advice. I have learned a hell of a lot about XML in the last few weeks, and this has really helped me. I will use this informationm to be more confident in my arguement!

Thanks again!
0
 
Geert BormansInformation ArchitectCommented:
welcome,

I hate it when colleagues are putting XML contractors in a bad light with silly arguments :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now