Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Learn to Use XML with DB2  : Page 4

If you need to store XML data in DB2, translate XML to relational data, or shred relational data into XML, the XML Extender for DB2 is an essential utility. But it's not always straightforward. Find out what it can do and what problems to expect.


advertisement
Filling in the Gaps
A range of other functions are available to round out DB2's support for XML. Some of these are operations required in almost any XML environment, while others form the "glue" to more easily use the major functions.

Validation
The XML Extender provides two functions for validating XML documents, depending on your choice of schema or DTD validation:

I've mentioned that DTDs are required for some DADs. Schemas are more versatile than DTDs in defining and validating XML documents, and DB2 allows both types to be performed explicitly using either the SVALIDATE(doc, schema) or DVALIDATE(doc, dtd) functions.



Shredding and storing routines, however, will only validate automatically using DTDs.

For explicit validation, the XML document can be provided as a CLOB or as a file system path described in a character string. The schema or DTD can be implied from the XML document, provided as a CLOB, or specified as a file path.

Perform Transformations Using XSL
Transformations demonstrate one of XML's powerful features—the ability to convert XML documents into other formats, by writing a formula. The same formula can be used under a range of environments, and DB2 is no exception.

The extender function XSLTransformToFile takes an XML document as a CLOB, an XSL stylesheet as a file or a CLOB, and stores the result of the transform as a file. You can either specify a full file name or just a location, and the system can generate a file name. DB2 Extender can perform validation before running the transform.

Read and Write Files
To pass XML between DB2 and other systems, there is again a choice:

  • You can write an application to pass CLOBs to and from the database.
  • DB2 Extender provides these functions, which have self-descriptive names: XMLVarcharFromFile, XMLCLOBFromFile, XMLFileFromVarchar, XMLFileFromCLOB
  • DB2 v8.1 also provides a range of functions to directly link to IBM's Websphere MQ messaging platform, and many of these functions integrate XML support.



Greg Nash is an integration engineer with a manufacturing company in Australia. He can be reached at GregNashDB2@bigpond.com.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date