Copyright © 2010 Silmaril Consultants
Rev: 2010-03-01T00:19:00+0000

Ask your database manufacturerC.17  How do I get XML into or out of my database?

Ask your database manufacturer: they all provide XML import and export modules to connect XML applications with databases.

In some trivial cases there will be a 1:1 match between field names in the database table and element type names in the XML Schema or DTD, but in most cases some programming will be required to establish the desired match. This can usually be stored as a procedure so that subsequent uses are simply commands or calls with the relevant parameters.

Alternatively, most database systems now provide an XML dump format that lets you export a table as-is, for example by surrounding the field values with tags called after the fieldnames.

In less trivial, but still simple, cases, you could export by writing a report routine that formats the output as an XML document by adding the relevant tags as literals before and after each data value; and you could import by writing an XSLT transformation that formatted the XML data as a load file in your database's preferred format.

Warning

Users from a database or computer science background should be aware that XML is not a database management system: it is a text markup system. While there are many similarities, some of the concepts of one are simply non-existent in the other: XML does not possess some database-like features in the same way that databases do not possess markup-like ones. It is a common error to believe that XML is a DBMS like Oracle or Access and therefore possesses the same facilities. It doesn't.

Database users should read the article ‘Requirements for XML Document Database Systems’ (Salminen and Tompa, November 2001) [thanks to Bart Lateur for identifying this.] Ronald Bourret also maintains a good resource on XML and Databases discussing native XML databases at http://www.rpbourret.com/xml/XMLAndDatabases.htm.

There is some information about the XQuery (XQL) Language in the note on Searching.