MAINFRAME > Tips & Techniques > Application Development

Storing, Processing and Parsing XML

Native XML support strengthens DB2 and COBOL development

Native XML support strengthens DB2 and COBOL development

Storing and processing XML documents in DB2* using the native XML data type may greatly improve access performance. In the past, people didn’t store XML in DB2 because it was very slow to store the data and even slower when reading documents. The new capability to store and index, added in DB2 9, negates that argument.

Another powerful feature in DB2 9 is the capability to return XML documents in a relational table. This feature allows you to combine and process your legacy relational data along with your XML data in the same SQL statement, which takes advantage of the DB2 optimizer and greatly reduces the complexity in program code.

Validating XML on INSERT

The strength of XML is its capability to quickly have a document adapt to new business requirements. This strength can also be seen as a weakness due to the lack of necessary controls to ensure the data elements and data types are enforced as they are with relational data. The data quality of the XML document can become a problem during development if you don’t validate the contents. You may find you’ve mistyped the element name or put character data in a numeric field. It’s important to validate the XML document during the development stage of the application. DB2 9 for z/OS* provides XML validation management through the XML schema repository (XSR).

Once you define the XML schema definition (XSD) with the XML validation rules, you can register it to the DB2 XML Schema Repository (XSR). Then it can be used during INSERT and UPDATE processing to validate the XML document.

The XML schema registration can be handled manually through one of these methods:

  • Call the following DB2 stored procedures: Sysproc.xsr_register, sysproc.xsr_addschemadoc, sysproc.xsr_complete
  • Invoke the following JDBC method that performs all of the stored-procedure steps:
  • Invoke the following commands from command-line processor: –register xmlschema, -add xmlschema document, -complete xmlschema

Troy L. Coleman is an IBM-certified Certified database administrator, specializing in DB2 9 for z/OS and Linux, UNIX and Windows. Troy can be reached at

comments powered by Disqus



2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

A Beginner's Guide to the REXX Programming Language on z/OS

Reading and Writing Files in the REXX programming language on z/OS.


Application Management is Important to the Entire Process


Application Testing: Giving Users What They Need

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
Mainframe News Sign Up Today! Past News Letters