IBM Systems Magazine, Mainframe Edition - May/June 2010 - 51

with SAX is much smaller than it is with the DOM parser. The DOM parser requires the entire document to be read into memory before any processing can begin. Because of the event-driven nature of SAX, it’s a faster method to process XML documents. However, some types of SAX validations require the entire document be processed before you can validate it. For example, the DTD IDREF attribute requires an element in the document to use the given string as a DTD ID attribute. To validate this in SAX, you’d have to keep track of every ID attribute and every IDREF attribute, to see if any matches are made. A missing IDREF for a given ID will only be found after the entire document has been processed. This could cause a lot of wasted processing since the entire document has to be thrown out if the matching DTD ID is missing. The DOM method is best suited for applications where the document is accessed repeatedly or out-ofsequence order. If the application is strictly sequential and one-pass, then SAX model will be faster and use less memory.

z/OS XML parser not only improves the performance of parsing XML document, but also adds the following enhancements:

display ‘XML document error ‘ XML-CODE NOT ON EXCEPTION display ‘XML document success-

hÁÁEnhanced name-space processing
(special registers XML-NAMESPACE, XMLNNAMESPACE, XML-NAMESPACE-PREFIX, and XML-NNAMESPACE-PREFIX)

fully parsed’ END-XML.

You may notice the XML PARSE statement doesn’t provide support for reference to an XML document type (DTD or Schema). This means you’ll have to validate the XML document within your code. A list of XML PARSE “events” along with a description of the different events can be found in Enterprise COBOL for z/OS Language Reference version 4 release 1. The Enterprise COBOL for z/OS Programming Guide version 4 release 1 (http://bit.ly/cobolguide) has a nice sample program to help understand how the parser works. I wrote a program similar to the sample program in the programming guide, except I changed it to process employee data for the HR department. As you look at the sample program, notice the COBOL compiler option “cbl codepage (1047).” I didn’t notice this when I wrote the program, and had some problems with the bracket character used in the CDATA statement. The bracket wasn’t being translated correctly during execution of the program and the parser was flagged it as a serious error. Once I put the codepage (1047) compiler option, the parse completed successfully. The output available online (www.ibmsystemsmag. com/mainframe/cobolXMLparsers) will help you better understand the different parser events and what you can do when you get control from the parser.

hÁÁT he

R E T U R N I NG NAT IONA L

phrase of the XML PARSE statement, for selecting automatic conversion of document fragments to Unicode UTF-16

hÁÁThe ENCODING phrase of the XML
PARSE statement, for specifying the encoding of the input document

hÁÁDirect parsing of XML documents
encoded in UTF-8

hÁÁParsing of XML documents, a buffer
of XML at a time

hÁÁO ff loading
(zAAPs)

of XML parsing to

System z* Application Assist Processors

I’ll outline ways of processing XML documents stored in files and in DB2. However, many ways exist to pass an XML document to an application. The most common techniques used are through WebSphere* MQ messages; a CICS transient queue or communication area; IMS message processing queue; or by reading the document from a file. No matter how you get the XML document,

Enterprise COBOL for z/OS version 3 provided a built-in XML parser. This parser was limited and COBOL could use it. The main features include:

the processing is the same. By default, the XML PARSE command is used to invoke the z/OS XML System Services parser. The following sample XML PARSE statement processes the XML document stored in host variable “xml-document.” On each XML event, control will be passed to paragraph “xml-handler.” If an error exception is encountered, then a message will be displayed along with the XML-CODE that caused the error; otherwise, a success message will be displayed.
XML PARSE xml-document PROCESSING PROCEDURE xml-handler ON EXCEPTION

hÁÁProcessing XML documents in the
principal run-time environments, such as CICS*, IMS* and MQSeries*.

hÁÁValidating
standards.

XML documents to

ensure they conform to established XML

hÁÁPopulating COBOL data structures
with the content of XML documents.

Since the majority of data available on z/OS isn’t stored in XML format, you need some methods to retrieve the data and format it into an XML document. Enterprise COBOL for z/OS has a built-in function called XML GENERATE. I won’t

hÁÁEnterprise COBOL for z/OS version
4.1 now takes advantage of the more robust z/OS XML System Ser vices parser, which is available through the compiler option XMLPARSE(XMLSS). The

ibmsystemsmag.com/mainframe

MAY/JUNE 2010

51


http://bit.ly/cobolguide http://www.ibmsystemsmag.com/mainframe/cobolXMLparsers http://www.ibmsystemsmag.com/mainframe/cobolXMLparsers http://www.ibmsystemsmag.com/mainframe

IBM Systems Magazine, Mainframe Edition - May/June 2010

Table of Contents for the Digital Edition of IBM Systems Magazine, Mainframe Edition - May/June 2010

IBM Systems Magazine, Mainframe Edition - May/June 2010
Editor's Desk: Planned to a 'T"
Dashboard: Beef Up Your Passwords
Data Display: Cost of Security Breaches
IT Today: IBM Partnership Offers Cost-Effective BI Solutions
Trends: IBM's Eagle Studies Provide a Clear View of True Technology Costs Both Internal and External Communications
Insider: Six Computing Strategies for a Recovering Economy
Case Study: The Office of the CIO with the State of Nebraska Improved Data-Handling Issues with Smarter and Faster Data-Storage Tools
Harnes the Information Expansion: Discover the Hidden Value in your Business Data with System z
Green with Envy: Syracuse University's New Data Center is One to Covet
Focus on Storage: Tivoli Storage-Management Solutions Reduce Costs and Improve Efficiency
Developer: A Guide to Processing XML Documents Stored in Files and DB2
Solutions
Advertisers' Index
Stop Run: IBM's Plant-A-Tree Initiative Grows in Italy
Reference Point
IBM Systems Magazine, Mainframe Edition - May/June 2010 - IBM Systems Magazine, Mainframe Edition - May/June 2010
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Cover2
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 1
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 2
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 3
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 4
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 5
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 6
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 7
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 8
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 9
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Editor's Desk: Planned to a 'T"
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 11
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Dashboard: Beef Up Your Passwords
IBM Systems Magazine, Mainframe Edition - May/June 2010 - B1
IBM Systems Magazine, Mainframe Edition - May/June 2010 - B2
IBM Systems Magazine, Mainframe Edition - May/June 2010 - B3
IBM Systems Magazine, Mainframe Edition - May/June 2010 - B4
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 13
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Data Display: Cost of Security Breaches
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 15
IBM Systems Magazine, Mainframe Edition - May/June 2010 - IT Today: IBM Partnership Offers Cost-Effective BI Solutions
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 17
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 18
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 19
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 20
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 21
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Trends: IBM's Eagle Studies Provide a Clear View of True Technology Costs Both Internal and External Communications
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 23
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 24
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 25
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Insider: Six Computing Strategies for a Recovering Economy
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 27
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 28
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 29
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Case Study: The Office of the CIO with the State of Nebraska Improved Data-Handling Issues with Smarter and Faster Data-Storage Tools
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 31
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 32
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 33
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 34
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 35
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Harnes the Information Expansion: Discover the Hidden Value in your Business Data with System z
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 37
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 38
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 39
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 40
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 41
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Green with Envy: Syracuse University's New Data Center is One to Covet
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 43
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 44
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 45
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Focus on Storage: Tivoli Storage-Management Solutions Reduce Costs and Improve Efficiency
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 47
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 48
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 49
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Developer: A Guide to Processing XML Documents Stored in Files and DB2
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 51
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 52
IBM Systems Magazine, Mainframe Edition - May/June 2010 - 53
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Solutions
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Advertisers' Index
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Stop Run: IBM's Plant-A-Tree Initiative Grows in Italy
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Cover3
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Cover4
IBM Systems Magazine, Mainframe Edition - May/June 2010 - Reference Point
IBM Systems Magazine, Mainframe Edition - May/June 2010 - RF2
IBM Systems Magazine, Mainframe Edition - May/June 2010 - I1
IBM Systems Magazine, Mainframe Edition - May/June 2010 - I2
IBM Systems Magazine, Mainframe Edition - May/June 2010 - I3
IBM Systems Magazine, Mainframe Edition - May/June 2010 - I4
IBM Systems Magazine, Mainframe Edition - May/June 2010 - I5
IBM Systems Magazine, Mainframe Edition - May/June 2010 - I6
IBM Systems Magazine, Mainframe Edition - May/June 2010 - I7
IBM Systems Magazine, Mainframe Edition - May/June 2010 - I8
IBM Systems Magazine, Mainframe Edition - May/June 2010 - I9
IBM Systems Magazine, Mainframe Edition - May/June 2010 - I10
IBM Systems Magazine, Mainframe Edition - May/June 2010 - I11
IBM Systems Magazine, Mainframe Edition - May/June 2010 - I12
http://www.ibmsystemsmagmainframedigital.com/mspcomm/ibmsystemsmag/ibmsystems_mainframe_20201112
http://www.ibmsystemsmagmainframedigital.com/mspcomm/ibmsystemsmag/ibmsystems_mainframe_20200910
http://www.ibmsystemsmagmainframedigital.com/mspcomm/ibmsystemsmag/ibmsystems_mainframe_20200708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20200506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20200304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20200102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/2020mfse
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20191112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20190910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20190708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20190506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20190304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/relevantz_20190102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/2019mfse
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20190102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20181112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20180910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20180708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20180506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20180304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20180102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/2018mfse
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20171112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20170910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20170910_v2
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20170708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20170506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20170304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_sesupp
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20170102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_linuxsupp
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20161112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/MainframeSecurity
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20160910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20160708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20160506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20160304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20160102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20151112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20150910_se
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20150910
http://www.ibmsystemsmagmainframedigital.com/MFSkills
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20150708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20150506_supp
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20150506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20150304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20150102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20141112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20140910_v2
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20140910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20140708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_gt_201405
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/BigData
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20140506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20140304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20140102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20131112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20130910_v2
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20130910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20130708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20130506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20130304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20130102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20121112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/buyersguide2013
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20120910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20120708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20120506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20120304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20120102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/ibmsystems_mainframe_2012bg
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20111112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20110910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20110708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20110506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20110304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20110102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20101112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20100910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20100910_bg
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20100708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20100506
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20100304
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20100102
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20091112
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20090910
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20090708
http://www.ibmsystemsmagmainframedigital.com/nxtbooks/ibmsystemsmag/mainframe_20090506
https://www.nxtbook.com/nxtbooks/ibmsystemsmag/mainframe_20090304
https://www.nxtbookmedia.com