?
Solved

How XML should display in a text editor

Posted on 2009-04-20
5
Medium Priority
?
258 Views
Last Modified: 2012-06-27
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
Comment
Question by:forzaaw
  • 3
  • 2
5 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24183349
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
 
LVL 1

Author Comment

by:forzaaw
ID: 24183553
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
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 24184546
> 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
 
LVL 1

Author Comment

by:forzaaw
ID: 24184599
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
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 24184623
welcome,

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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question