Re: Why do you use XML?



On Feb 8, 3:15 pm, "jehugalea...@xxxxxxxxx" <jehugalea...@xxxxxxxxx>
wrote:
I think it's a good idea to use the right format for the job, but XML
has significant benefits in many places:

1) Reasonable character encoding support

How often is this a real concern? I assume you are talking about
Unicode, UTF8, etc. How hard is it to generate a Unicode file? How
often can't you figure that out?

Often. You'd be amazed at how often people guess at encodings and get
it wrong.

2) No need to manually escape and unescape data (did your SSV file have
no values with spaces in?)

SSV files don't care where the spaces are. The position and length of
fields are static.

That doesn't sound like a space-separated value file. That sounds like
a fixed record file to me. Different kettle of fish, IMO.

XML doesn't need to limit the size of a field,
however, neither does CSV. A quick regular expression can break a CSV
file apart in no time (it is slower though).

Except you've got to know exactly which flavour of CSV is being used.

3) Natural way of representing hierarchies, or multiple tables etc -
SSV/CSV really only describes a single rectangular table easily

I agree this is a good use of XML. However, a long time ago, you
handled heirarchies with a relational schema and had the entities in
separate files, searching on index(which was the line number usually),
which was typically fast and easy to code to.

Searching on line numbers only works with fixed length records (which
has limitations) *and* if you're using a fixed with encoding - so
UCS-2 is okay, but UTF-8 isn't, for example. It also means having to
manage more files.

4) Reasonably self-descriptive, with element and attribute names

I agree about this too. However, again, most other formats support a
header line that has the name of the column. Usually that is all that
is needed. Using my example above, attributes translate to values and
child elements to relations. It can be equally represented.

When you say "usually" - out of what range of uses? Most of my data
sources aren't represented in just a single table form - so I've
either got to have multiple files, or use a richer format such as XML.

5) Well-defined standard - if you give me an XML file, I need to
ask you enough information to *understand* the data, but I don't
need more information in order to *load* it. Compare that with
finding out which particular brand of SSV/CSV/etc you're using

This is another good point. Again, even XML formats are typically
application specific, not global such as XHTML. To some degree the
developer must always know what he is working with. In my opinion, it
takes as long to understand a SSV as it does to understand an XML. DTD
surely helps and having the nesting direclty in the file is also
beneficial.

There's a difference between understanding the syntax and
understanding the semantics. If it's an application-specific file,
you'll have to have some description of the semantics whatever format
you use - but with XML you don't need to have anything extra to
describe the syntax (beyond the option of using a DTD, which the
developer doesn't need to understand - they just give to the XML
parser).

But what experiences have you found XML useful in. I mostly concerned
with knowing a good time to use XML. Like I said, I hear the hype all
the time, but have rarely found a practical application of it.

I use XML all the time, in many, many situations. Persistence,
serialization, project files for Visual Studio, configuration files
for applications, RSS feeds... whereas I can't remember the last time
I had to write code to deal with a fixed size record file.

Jon
.



Relevant Pages

  • Re: Microsoft Word as competition for LaTeX
    ... LaTeX with larger workflows for scholarly publishing in a ... XML formats will be increasingly more ... the TeX scene one way or another (actually it's already here: ...
    (comp.text.tex)
  • Re: Read binary data file
    ... I think its use is quite industry-dependent: I've never seen it used in financial messaging (that's more likely to use SWIFT formats, which are tagged text) but its common in the telecommunications industry. ... Compared with XML its a LOT more compact (tags are one byte, fixed length fields don't have terminators, variable length fields are preceded by a one or two byte length) and it has a number of predefined field types as well as arrays. ...
    (comp.lang.java.programmer)
  • Re: impl a collection
    ... My objection is more from experience with opaque formats than anything ... In my experience, and in the files I have seen, most people doing XML ... There are exceptions, such as Microsoft's file formats, and some I have ... the wire and on the disk without needing any collusion by the developers ...
    (comp.lang.java.programmer)
  • Re: SQL in the base system
    ... does int32 turn into on a platform with 40 bit words and 20 bit ... a bunch of one-of file formats for each and every purpose. ... Settling on XML ... I agree that validation in XML is a strong point - but one of the reason ...
    (freebsd-hackers)
  • Re: xslt: force a start character on every output line
    ... > I'm just getting going with xml and xslt. ... Is this the sort of thing that xml and xslt are meant ... use XSLT to output it to other formats for and. ... margin caused by Octave using a proportional font to display text which ...
    (comp.text.xml)

Loading