Slashdot Mirror


An Overview of Modern XML Processing Techniques and APIs

Dare Obasanjo writes with a link to his article "A Survey of APIs and Techniques for Processing XML" on xml.net. It starts off "In recent times the landscape of APIs and techniques for processing XML has been in the process of reinventing itself as developers and API designers learn from their experiences and some past mistakes. APIs such as DOM and SAX which used to be the bread and butter of XML APIs are giving way to new models of examining and processing XML. However although some of these techniques have become widespread amongst developers who primarily work with XML they are still unknown to the general body of developers. Nothing highlights this better than a recent article by Tim Bray one of the co-inventors of XML entitled XML is too Hard for Programmers and the subsequent responses on Slashdot." Read the entire article to learn more about the state of the XML art. Added in the missing link.

40 comments

  1. You know... by avalys · · Score: 0, Offtopic

    With the new technology known as a hyperlink, we can simply click a location on the screen and be taken to the article, instead of having to go to xml.net and find it ourself.

    Argh...

    --
    This space intentionally left blank.
    1. Re:You know... by ComputerSlicer23 · · Score: 4, Funny
      Don't worry, it'll get fixed up on the duplicate post in about 4 hours...

      Kirby

  2. Um....link? by Figaro · · Score: 0, Offtopic

    Um....link?

    --
    :wq
  3. Actually on xml.com by DeathBunny · · Score: 5, Informative

    The article is actually on xml.com, not xml.net. Here is the url: http://www.xml.com/pub/a/2003/07/09/xmlapis.html

  4. No Link? by Snerdley · · Score: 4, Insightful

    This is a horrible post!

    There is no link to the article, and the one link that comes close (to xml.net ) points to a site that says:

    xml.net will be online soon. Sign up now and we'll keep you posted on our progress.

    Timothy, how did you read this as the editor?

    I am interested in the topic: please fix the post so that we can read the article.
    1. Re:No Link? by Anonymous Coward · · Score: 4, Funny

      I am interested in the topic: please fix the post so that we can read the article.

      The fix will be uploaded in a few days but subscribers can click now and beat the rush!

  5. Plaint Text and XML by cpeterso · · Score: 5, Insightful


    XML sucks because it's being used wrongly. It is being used by people who view it as being an encapsulation of semantics and data, and it's not. XML is purely a way of structuring files, and as such, really doesn't add much to the overall picture. XML came from a document preparation tradition. First there was GML, a document preparation system, then SGML, a document preparation system, then HTML, a document preparation system, and now XML. All were designed as ways humans could structure documents. Now we've gotten to the point where XML has become so obscure and so complex to write, that it can no longer be written by people. If you talk to people in Sun about their libraries that generate XML, they say humans cannot read this. It's not designed for human consumption. Yet we're carrying around all the baggage that's in there, because it's designed for humans to read. So XML is a remarkably inefficient encoding system. It's a remarkably difficult to use encoding system, considering what it does. And yet it's become the lingua franca for talking between applications, and that strikes me as crazy.

    People think, "Once I've got my data in XML that's all I've got to do. I've now got self-describing data," but the reality is they don't. They're just assuming that the tags that are in there somehow give people all the information they need to be able to deal with the data. Now, for some things there are standards. For example, there are some standards like RSS and RDF, which give you very simple ways of describing web page content. But a random XML file, especially machine generated XML files, can be as obscure as binary data.

    Ant is a really good example, because in that case you're using XML as a user-specified input language, which is really inappropriate in that context. I'd much rather have a genuine grammar. I want to be able to type something simple and easy for me. I don't care if it's easy for the tool to parse, that's the tool's problem. I want it to be easy for me to write. And in cases like that, it's really the case of the programmer saying, "Oh look, here's an XML parser. I can just take XML files. That's easier." So one programmer in one context puts a burden on the other 100,000 programmers trying to use it.

    1. Re:Plaint Text and XML by battjt · · Score: 4, Insightful

      Once data is in XML I can manipulate it without having to write a parser. This is pretty handy in an enterprise setting where data is coming from all over and headed somewhere else. Efficiency of the overall business process is important, not the efficiency of my program. Joe

      --
      Joe Batt Solid Design
    2. Re:Plaint Text and XML by dr3vil · · Score: 0, Flamebait

      I'm not sure that the implication that XML should be human-readable is correct. XML is a way of wrapping human-readable content in such a way that it can be easily processed and transformed by machines. It can then also be processed easily to make it human readable, with computer-enhanced richness intact. I understand where you're coming from with respect to Ant, though. It seems to me that the missing step here is something to generate the XML. I've recently been charged with programming in a beast called BPEL. Take a look at that and you'll never complain about Ant again.

    3. Re:Plaint Text and XML by __past__ · · Score: 2, Informative
      Once data is in XML I can manipulate it without having to write a parser.
      Um, no. Or yes, but only in not too interesting ways.

      An XML processor (Note that the W3C XML Rec carefully avoids the term "parser". That is for a reason.) is more like a lexer than a parser in traditional terms. It tells you about the syntactic elements of an XML document, but nothing about their meaning or relation. In other words, XML is not a language, XML applications are. Yet languages is what people need.

      It turns out that you actually cannot do all that much with plain XML without knowledge of the vocabulary used. It is great that you can mix vocabularies, and in a sense embed DSLs in whatever it is that you really want to use (like XInclude, which is usefull in lots of cases, but still an XML language of its own). Actually, I yet have to see anyone manipulate generic XML docs, it is always about specific XML applications. XML is not as general a solutions as everybody (or at least most marketeers) seems to think.

      That these applications are easier to deal with than a WordPerfect document embedded in an ASN.1 stream is true, however. But it tells more about WordPerfect and ASN.1 than about the inherently stupid idea of a generic exchange format if understood as anything beyond syntax.

    4. Re:Plaint Text and XML by Ataru · · Score: 1

      XML is a way of wrapping human-readable content in such a way that it can be easily processed and transformed by machines.

      But it's rubbish at that! XML files are inherently hierarchical, but you can't skip stuff you don't need, you have to parse the whole thing. It's so frighteningly inefficient, I have absolutely no idea why it is championed so. But then I'm a game programmer so that sort of thing frightens me easily.

      So, given that XML is not particularly human read/writeable, and that it isn't efficiently machine processable either, what the heck is it for?

    5. Re:Plaint Text and XML by jo42 · · Score: 1

      Ah... Someone that groks that "XML" is just a text-based file format, and YAT (Yet Another Three-Letter-Acryonm), and not some magick thingy that makes the world a better place...

    6. Re:Plaint Text and XML by the+hermit · · Score: 2, Informative

      And those manipulations you do are just another form of parsing. There's really no difference in writing a grammar that parses data and manipulates it and using SAX or DOM to manipulate some XML data. In either case, you still have to know the semantics to do anything useful. Using SAX is a big pain in the neck to interpret/manipulate the data hierarchy. Using DOM wastes alot of memory making a tree out of your whole dataset.

      However, it's ten million times easier for the end user of your data to create that data using a language made for that data, in which case, they only have to learn the mini language, as opposed to forcing them to use XML syntax on top of your data format, in which case they have to worry about XML syntax and learn your data format as well.

      -the hermit

  6. XML is too hard for *rubbish* programmers by vbweenie · · Score: 4, Insightful

    It's also "too hard" in a variety of circumstances where the reason it's too hard is that it's the wrong thing to use.

    Good programmers can cope with XML just fine when it's just what they need to get the job done, and are smart enough to avoid it when it isn't.

    --
    Experience is a hard school, but fools will learn no other.
    1. Re:XML is too hard for *rubbish* programmers by JonnyRo88 · · Score: 1

      What then is the proper use for XML?

      I am working on a project where I have to link a TCL based program with a PHP program.

      I have been having a rediculously horrible time figuring out how to link the two using XML-RPC. I briefly tried SOAP but that wasnt much better.

      Is XML and XML-RPC any easier in python or C?

      --
      The Ro Factor - Jeep/Linux Weblog
    2. Re:XML is too hard for *rubbish* programmers by vbweenie · · Score: 1

      There are dozens of ways to link one program with another. If you can send and receive XML, you can send and receive text formatted in any other format you like - or "raw" binary data, if that's your bag. The only reason to use XML is if both sender and receiver have some nifty tools (like the MS SOAP toolkit, xmlrpclib, SOAPPy, SOAP::LITE or whatever) for sending and receiving messages that happen to use some XML vocabulary to encode things on the wire.

      If you have such tools, you should use them (unless you have other, better tools - or have a need for other, better tools that don't exist yet, in which case consider creating them yourself); and if you're using them right, you shouldn't be having to worry too much about the fact that they use XML because they should be encapsulating that fact right out of your way. The Python xmlrpclib libraries certainly do this, as does the MS SOAP toolkit.

      If you're having to build XML documents by hand at one end, and decode them by hand at the other, then arguably XML isn't doing anything special for you and you should ask yourself why it matters that you should use it.

      --
      Experience is a hard school, but fools will learn no other.
    3. Re:XML is too hard for *rubbish* programmers by JonnyRo88 · · Score: 1

      Neither end starts out as XML. The troubles arose when trying to pass arrays from within TCL over the XML-RPC layer. I found that the available XML-RPC layers for TCL were very picky.

      I am going to give python a shot. TCL is a really cool language, but I think I need to hit this problem from a different perspective.

      I also recently added a book about XML-RPC from Oreilly Press to my Safari Bookshelf, so I'm going to RTFM, as the online guides on the matter have proved a bit too difficult to use (especially when using two different XML-RPC implementations, one on each end). Thanks for your reply.

      --
      The Ro Factor - Jeep/Linux Weblog
    4. Re:XML is too hard for *rubbish* programmers by Anonymous Coward · · Score: 0

      Yeah, XML-RPC has problems with arrays and arrays-of-arrays - there are places where it can become ambiguous or lose information about your data structure. Use SOAP instead.

  7. Re:Plain Text and XML - Use DocUtils! by FFFish · · Score: 1

    So if you're unhappy with working directly wit XML -- lord knows I am: it obscures the content far too much -- use a formal structured human readable markup system like DocUtils or ASCIIDoc.

    They're both quite robust, well-suited to documenting APIs, writing technical manuals, etcetera. They can both pump out DocBook-XML from the plaintext, lightly-formatted input.

    The beauty of these formats is that they are simple and often intuitive.

    You emphasize text by wrapping it in *asterisks*, just like you used to do in the old days. You create a title by

    Underlining
    ===========

    * bullets
    1. numbered sequences
    - and all that jazz.

    I'm on the verge of completing a 50+ page hardware reference manual. The source files are plaintext, using ReST (DocUtils) markup. They are transformed straight into DocUtils XML, and my XSL/XSL-FO stylesheets digest that into PDF using FOP. It's a thing of beauty.

    More difficult than laying out a publication using Ventura Publisher or FrameMaker? Yes: it's certainly not WYSIWYG. More flexible, in terms of allowing any git to subsequently update the manual? Yes, far and away easier.

    Anyway, mark me down as happy with ReST structural markup, XSL/XSL-FO transformations, and FOP PDF creation!

    --

    --
    Don't like it? Respond with words, not karma.
  8. Re:Plain Text and XML by jwdg · · Score: 4, Informative
    Manipulating XML may be cheaper than you think. libxml2 is very fast (IME) - I've used it with PostgreSQL for doing XPath queries on database columns and it is fast enough to make an XPath search (which involves building a DOM, parsing the XPath query and then executing it, for each row) across 1200 rows sufficiently fast to be useful. (It was a fraction of a second IIRC - obviosuly dependent on the nature of our XML docs).

    Yeah, I was surprised too.

    I disagree about the human readable/writable bit. It is easily human readable/writable if it's properly structured (if it's complex because the information is complex, that's an inevitability. Make the data model simpler, if that's a problem to you). In terms of efficiency - sure, binary formats are more efficient, but they are much harder to debug when they go wrong.

    I agree that XML documents are not necessarily self-documenting. That isn't surprising. XML is about syntax, not semantics. You can use XSD to provide basic (integer vs char) semantics, but anything more complicated comes back to human understanding and agreed specification. If you understand the objects in your schema, XML can provide a good presentation of those objects.

  9. Object Mapping / Marshalling techniques by jamesmrankinjr · · Score: 2, Informative

    My team (myself and another guy) implemented a mapping framework in Java that I think is more useful than the other frameworks I've seen.

    1. Order of fields in mapping file specifies order of elements in generated XML.
    2. Formatting of String, Date, etc. classes determined by formatter string in the mapping file.
    3. Can use an XPath like path to specify the location in the XML, not just a key name. This lets you decouple the structure of the object and the structure of the XML.
    4. Likewise, object fields are specified with a "keypath". E.g. Mapping "some string" to foo.bar.baz would result in getFoo().getBar().setBaz("some string").
    5. Constant mappings that let you just set an XML node to whatever you want. Maybe you just always want attribute "larry" of tag "bob" to always be "junior". Simple thing, but very useful.

    So when reading the comments about the weaknesses of object-mapping tools, keep in mind that some of us have overcome them. :)

    Peace be with you,
    -jimbo

  10. XML often violates relational rules by Tablizer · · Score: 1

    I know some of you don't care and/or are tired of hearing this, but XML data tends to violate relational rules. I would like to see a souped-up comma-delimited standard for data sharing. XML is perhaps suited okay for documents, but NOT structured data (except in relatively rare circumstances). Dr. Codd knew what he was doing. Relational has a more ordered, consistent structure than XML.

    1. Re:XML often violates relational rules by vidarh · · Score: 2, Insightful

      More often than not the data I work on don't fit naturally in a relational structure. A lot of data is more naturally structured in tree structures or graph structures than in a matrix. One of the reasons I like XML is because it fits my data much better than a matrix.

    2. Re:XML often violates relational rules by Tablizer · · Score: 1

      More often than not the data I work on don't fit naturally in a relational structure. A lot of data is more naturally structured in tree structures or graph structures than in a matrix. One of the reasons I like XML is because it fits my data much better than a matrix.

      I am a bit skeptical of this. What are some real-world examples? Trees are often the improper design IMO. Besides, trees can also be represented relational if need be.

    3. Re:XML often violates relational rules by gregfortune · · Score: 1

      Besides, trees can also be represented relational if need be.

      And XML can represent the structured content when necessary. Because XML allows some flexibility, we may see programmers *use* it incorrectly, but it can certainly be used in a relational fashion for structured data. The "relatively rare circumstances" you mention in the parent post are likely a result of programmer quality rather than a reflection of XML.

    4. Re:XML often violates relational rules by Tablizer · · Score: 1

      And XML can represent the structured content when necessary. Because XML allows some flexibility, we may see programmers *use* it incorrectly, but it can certainly be used in a relational fashion for structured data. The "relatively rare circumstances" you mention in the parent post are likely a result of programmer quality rather than a reflection of XML.

      That is why we need a standard relational alternative IMO. It would make it harder to violate relational rules and still be called a "relational format".

  11. Perl6 has yacc-style parsing as part of language by Anonymous Coward · · Score: 0

    So you can make an application-specific grammar very easily. Not all data in the world is hierarchical or can be easily crammed into XML form. Maybe Larry is on to something here.

  12. What is the best toolkit for simple XML by JonnyRo88 · · Score: 1

    I have an application that does not have any access to a database or any database libraries on the server in which it will be run.

    It needs to store a small amount of data in a text file. Initially I thought I would use XML, but figuring out how to parse the data after it was created proved very difficult. I had some small luck with DOM inside tcldom, but it seemed like a lot more effort than it was worth.

    This file is a basic tree with branches of depth 2. All branches have the exact same structure.

    Is XML the way to go for such a project, what other toolkits have you used to store program data in a text file (small strings less than 64 chars)? I definately want it to be in some human readable form so it can be debuggable.

    I really wanted to keep the data in a form that someone else could use for a completely unrelated program (if the need ever arose).

    Thanks for any input. I was glad to see this topic come up because it got me thinking about the issue again.

    -Jonathan

    --
    The Ro Factor - Jeep/Linux Weblog
    1. Re:What is the best toolkit for simple XML by Col.+Klink+(retired) · · Score: 1
      There's another DOM processor for Tcl called tDOM. I prefer tDOM, and the mailing list is very helpful (despite the fact that it's hosted by Yahoo! egroups), but you can see the TclDOM vs tDOM wiki for more info.

      But also, if you don't mind Tcl, you can just store the data in Tcl lists. Tcl's syntax is simple enough that it makes this sort of thing pretty straightforward.

      --

      -- Don't Tase me, bro!

    2. Re:What is the best toolkit for simple XML by JonnyRo88 · · Score: 1

      Thanks for the information. I'll definately check it out.

      I really enjoy working in TCL because of the very clean syntax and straightforwardness of TCL.

      Still, it will take me a little while to get used to not having access to pointers.

      --
      The Ro Factor - Jeep/Linux Weblog
    3. Re:What is the best toolkit for simple XML by ultratimepass · · Score: 1

      Take a look at XPath. It's designed to eliminate the manual traversal of the DOM tree, and makes creating and parsing XML files very easy.

  13. good points by pyrrho · · Score: 1

    you make good points.

    I understand the idea that if you need an XML editor (or compiler!) to make it easy to write XML what's the point of having a human readable format. Would you suggest standard binary formats?

    I think, in fact, there are good binary encodings that also can encapsulate DOM shaped structures. It seems to me that the accessibility is still a good thing, I like XML as a universal interchange format that supports arbitrary nesting properties for the embedded blocks. All that could be done in a universal standards.

    But then we'd have to resurrect the byte-ordering wars, settled but not forgotten, by truce years ago.

    --

    -pyrrho

  14. Re:Plain Text and XML by Anonymous Coward · · Score: 0

    How cheap do you think I think it is? Actually I have no idea because I don't use XML. But it is obviously slower if you have to parse stuff, than if you have it in a nice binary format. So libxml2 is the fastest parser, big whoop, it's still too slow.
    I don't agree that binary formats are inherently harder to debug. It depends on the structure of the file.

  15. Flamebait??? by Anonymous Coward · · Score: 0

    I don't get it. Can someone explain?

  16. The value of XML by sh4na · · Score: 1

    Just because XML is a human-readable format and anyone can make one is I think the biggest problem of all in this ongoing xml-is-the-biggest-thing-since-sliced-bread saga.

    I've been working with XML for 2 years now, and I am constantly reminded that, just as it happens with html, vb, or any other "simple to use" technology out there, anyone can use it, but few know how to use it well. I've seen xml structures that would have you rolling on the floor laughing, so inneficient and dumb were they.

    It's just like databases, really. It's pretty easy to mess it up so badly it's unusable.

    XML is really the most insignificant part of the whole. One has to know at least xpath and xslt to use xml properly. Because the great advantage I see about the format is the ease of transforming data from one format to another, and you that by applying transformations to it.

    So instead of hardwiring the structure to the data (and banging you head on the wall when suddenly you need a slightly different structure for the same data), you just store everything in a format that will be easy to transform to suit your purposes. 80% of my work in xml is actually applying filters, transformations and the likes to my data.

    An example: I work for an insurance company which is putting every kind of information is has on the web for the clients and the agents to consult. The data is mostly the same for everybody: contracts, receipts, etc.

    Almost all applications deal with the same data, only in very different ways. Even in only one application, the same data can be manipulated in different ways. And of course, it is the web, so we need to cache stuff and minimize database access.

    Some applications are on the intranet, others on extranet, others in the internet. We're using webservices to simpify access to the data (since it mostly the same for everyone), so the webservices work for everyone, handing out data that is then transformed for specific needs.

    Since the basic format of the information is stable, we don't need to learn or implement new formats, different calls to webservices and the likes. We just take the information and transform it. Caching is straightforward for everyone (just text, after all), validation is easy (xsd).

    XML is not for everything, but if you're working with pure information and passing it around to a zillion different apps, it sure beats sliced-bread.

    --
    shana
    ......gone crazy, back soon, leave message
  17. XPath r0x0rs, can't wait for XQuery by r4lv3k · · Score: 1

    XPath is awesome for getting at what you really want. SAX and DOM are too low level for implementing anything other than an XPath or XSLT engine :) Even easier is putting System.Xml.Serialization attributes on your properties in C#. Blammo, instant configuration file for your classes. And I hear XQuery shall revolutionize the world as we know it. There are some early implementations already. r4lv3k

  18. Re:Plain Text and XML by jwdg · · Score: 1
    It was a rhetorical you.

    Yes, it is obviously slower. But that's a tradeoff that many people are willing to make. And I didn't say that libxml2 was the fastest parser - I'm not qualified to say that, as I've not benchmarked it properly.

    Bear in mind that many uses of XML are for data interchange, where speed is less important than compatibility. XML gives you more potential to add extra data into the format and still use a mix of old and new tools. Binary formats generally require that all programs using the format be upgraded if the format changes.

    The "structure of the file". Obviously, binary files have no evident structure to humans without special tools - so if you have a mixture of content (e.g. floating point, variable length text) you have to rely on remembering the order of fields and be able to translate their values.

    Honestly, I'm not saying there's not a place for binary formats (there is and I'd be happy to use them) but for many of the applications XML is used for, particularly data interchange, human readability is a big bonus. The XML I've been involved with shoudl be pretty readable to anyone with a knowledge of the domain.

  19. Attributes by Skeme · · Score: 2, Funny

    XML sucks because of attributes. I can have a and a thing and they are treated differently. How pointless that is.

    Plus any drooling idiot can come up with a way to represent a tree in a file. They did that 100 years ago with Lisp.