Problem solve Get help with specific problems with your technologies, process and projects.

XML Flexibility

I'm reading an example developed in XML. There is incomplete information extracted from a DB and stored within an XML file. After receiving the missing data in the DB, the XML file must be updated with this data. In this case the author said that XML is not flexible for such updates. My question is: what does he mean by flexible? No indication is given in the example about flexibility.

The author has a point but if anything, the problem is that XML is too flexible rather than not flexible enough. XML allows you to represent arbitrarily complex hierarchical structures in which the relational database concept of "record" does not exist. As a consequence, addressing any particular point in the data is more complex than it is in a DB where you typically have a unique key to work with. The first stage in any update operation is locating the update point. With a DB this is a simple seek operation, with XML, it's not so simple in the general case.

There are two common addressing mechanisms available in XML. The first, which dates from the SGML days, is the concept of an ID. An ID is an attribute that can be associated with an element. A validating XML parser will ensure that these IDs are unique in any one XML document. Consequently they can be used to uniquely address specific points in an XML document.

Secondly, there is the more powerful addressing mechanism provided by XPath. You can think of XPath as a sort of mini-query language that can be used to identify points or ranges in an XML document.

Note that the simple ID mechanism is built-in to XML whereas XPath is a separate specification and requires software support over and above XML 1.0 software support.

So, in summary, the author is right that data update in XML is not as simple as it is in DB-land. Having said that, the combination of XML/XPath allows the creation of update of update architectures that are more powerful than simple DB updates. Unfortunately, the extra power comes at the cost of increased complexity.

Various efforts are afoot to address the XML update problem. For example http://www.xmldb.org/xupdate/.

One interesting tool in this space is XMLDiff (http://www.logilab.org/xmldiff/) which analyses two XML documents and then generates the instructions (in xupdate form) required to turn the first document into the second.

You might also we interested in this freely available visual tool for XPath (http://www.logilab.org/xpathvis/).

Dig Deeper on Topics Archive

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.