Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML and COBOL.

Similar presentations


Presentation on theme: "XML and COBOL."— Presentation transcript:

1 XML and COBOL

2 XML XML = Extensible Markup Language
Used to expose the structure and content of a document Becoming a universal means of exchanging data Tag language <author> <firstname>Charles</firstname> <lastname>Dickens</lastname> </author>

3 XML Tags are user-defined Every start tag has a matching stop tag
<atag> …</atag> Sometimes the tags are combined into one start and stop tag <media type = “CD” /> Tags can’t overlap NO: <a> <b> </a> </b>

4 XML Tags can be nested <a> <b> </b> </a>
Documents are tree-structured <a> <b></b> <c> <d></d> </c> </a> a b c d

5 XML Text based documents Case sensitive
Must contain a single root element Start with an XML declaration and comments <?xml version =“1.0”?> <!– comment line - -> <a> </a>

6 XML XML is “Well Formed” if 1) Single root element
2) Start and end tags matching for all elements 3) Proper nesting 4) Attribute values in quotes

7 XML Parsers An XML parser is a program that can read an XML document and provide programmatic access to the document Two types of parsers: 1) DOM based – Document Object Model Constructs a tree that represents the document 2) SAX based – Simple API for XML Generates events when parts of the document are encountered. Can also be classified as “push” or “pull” parsers

8 XML Characters Consist of carriage returns, line feeds and Unicode characters XML is either “markup” or “text” Markup is enclosed in < and > Character text is the text between a start and end tag Child elements are considered markup

9 White Space Parsers consider whitespace inside text data to be significant and must pass it to an application An application can consider whitespace significant or insignificant. Normalization is the process in which whitespace is collapsed or removed

10 Entities &, <, >, ‘ (apostrophe), and “(double quote) are special characters and may not be used in character data directly To use these characters we code entity references which begin with an ampersand and end with a semicolon & < > &apos; " <mytag>David&apos;s Tag</mytag>

11 Unicode XML supports Unicode
Each Unicode character starts with an ampersand, followed by a sharp (#), an integer, and a semicolon د

12 Determining the Encoding Type
Sources used to determine the encoding of an XML document when XMLPARSE(XMLSS) is in effect: The type of data item that contains the XML document. (We will only consider alphanumeric.) The ENCODING phrase (if used) on the PARSE statement The CCSID specified in the CODEPAGE compiler option

13 Two ways to Specify the Encoding for XMLPARSE(XMLSS)
Put the document in an alphanumeric item (PIC X) 1) Specify the encoding on the PARSE statement: PARSE MYDOC WITH ENCODING 1208 … 2) Add a CODEPAGE compiler option

14 Markup Most items have distinct begin and end tags: <name>David</name> Empty elements begin and end with one tag: <img src = “img.gif” /> Tags can contain “attributes” as in the src attribute in the img tag above Attribute values must be quoted with single or double quotes Element and attribute names can be any length and may contain letters, digits, underscores, hyphens and periods. Must begin with letter or underscore.

15 Comments Comments in XML have the same format as HTML
Start with <!— End with --> <!– This is a comment -->

16 Processing Instructions
Example: <?xml:stylesheet type=“text/xsl” href=“usage.xsl”?> Delimited by <? and ?> Passed to the parser for additional information about the document Contain a “PI Target”: xml:stylesheet Contain a “PI Value”: type=“text/xsl” href=“usage.xsl” Allow a document author to embed application specific info in the document

17 CDATA Sections CDATA section can contain characters, reserved characters, and white space Not processed by the XML parser Sometimes used for scripting code or embedding XML inside a document Begin with <![CDATA[ End with ]]> < and > must be coded as entities

18 CDATA Example <![CDATA if (x > y) { x = x + y; } ]]>

19 XML Namespaces Different authors might create the same tag names with different meanings Namespaces provide a means for authors to prevent collisions on tag names <book:title>The Idiot</book:title> <movie:title>Avatar</movie:title>

20 XML Namespaces Each namespace is tied to a Uniform Resource Identifier (URI) Authors create their own namespace prefixes Namespaces are created in the root tag: <library xmlns:book = “urn:woolbright:bookinfo” xmlns:movie = “urn:woolbright:movieinfo”> URLs are sometimes used for URIs

21 Default Namespaces To avoid coding a prefix on every tag, code a default namespace: <library xmlns = “urn.woolbright:default” xmlns:book = “urn:woolbright:bookinfo” xmlns:movie = “urn:woolbright:movieinfo”>

22 Enterprise COBOL Contains two event-based parsers that allows you to read XML documents and process them with COBOL XML documents can be retrieved from an MQ message, CICS TD queue, or IMS message processing queue XML documents that are read from a file must be brought into storage as a single item. (Records can be combined using STRING or other techniques) If XMLPARSE(XMLSS) is in effect, you can parse an XML file by passing one record at a time

23 z/OS COBOL Features for Processing XML Input
XML PARSE – begins parsing the document and identifies the processing procedure in your document XML PARSE MYDOCUMENT PROCESSING PROCEDURE 100-PARSE ON EXCEPTION DISPLAY ‘XML DOCUMENT ERROR’ XML-CODE STOP RUN NOT ON EXCEPTION DISPLAY ‘PARSED DOCUMENT SUCCESSFULLY’ END-XML 23

24 z/OS COBOL Features for Processing XML Input
Processing XML involves passing control between the parser and the processing procedure you write to handle events Processing Procedure – receives and processes the events that are generated by the parser. This is a paragraph or section in your Cobol program

25 Parser/Procedure Interaction
Parser passes control to the procedure for each XML event Control returns to the parser at the end of the procedure This continues until either: 1) the parser detects an error in the document and signals an EXCEPTION event, or 2) the parser signals END-OF-INPUT event and the processing procedure returns to the parser with XML-CODE still set at 0 3) you terminate parsing deliberately by setting XML-CODE to -1 before returning to the parser

26 XML Parsers Compiler options control the parser type
CBL XMLPARSE(XMLSS) – chooses the z/OS XML System Services Parser. This provides enhanced features – namespace processing, validation with respect to a schema CBL XMLPARSE(COMPAT) – chooses the parser built into the COBOL library

27 Processing Procedure The parser reads the document and responds to events Gives control to the processing procedure when events occur The processing procedure responds to the event and turns control back to the parser for further parsing

28 Parse Syntax Here is the syntax for the XML PARSE statement

29 XML PARSE XML PARSE begins parsing, identifies the source document, and the processing procedure Specify the ENCODING option to describe the document’s encoding Specify the VALIDATING option to identify an XML schema against which the document will be validated

30 COBOL Features for Processing XML Input
Special Registers XML-CODE - to determine the status of XML parsing. PIC S9(9) BINARY XML-EVENT - to receive the name of the event. PIC X(30) XML-NTEXT – to receive XML document fragments that are returned as national character data (Unicode). Variable-length alphanumeric item XML-TEXT – to receive XML document fragments returned as aphanumeric data. Variable-length alphanumeric item

31 COBOL Features for Processing XML Input
Special Registers XML-NAMESPACE - to receive a namespace identifier event, or for an element name or attribute name that is in the namespace. Variable-length alphanumeric item XML-NNAMESPACE – national namespace. Variable-length alphanumeric item XML-NAMESPACE-PREFIX – to receive a namespace prefix. Variable-length alphanumeric item XML-NNAMESPACE-PREFIX – to receive a national namespace prefix. Variable-length alphanumeric item

32 Prior to Parsing In order to process an XML document, the entire document must be in memory Common sources of XML: WebSphere MQ message CICS Transient Queue CICS Communications area IMS message processing queue Reading a file of records

33 Reading XML Off A File The entire XML file must be placed in a COBOL data item You will need: A FILE-CONTROL entry to define the file An OPEN statement to open the file READ statements to read all the records into a data item in WORKING-STORAGE Optionally, a STRING command to string all the separate records together into one continuous stream, removing extraneous blanks, and to handle variable length records

34 Parsing with XMLPARSE(XMLSS)
XML PARSE document PROCESSING PROCEDURE event-handler-name ON EXCEPTION … NOT ON EXCEPTION … END-XML Parsing continues until 1) an END-DOCUMENT event occurs 2) the parser signals EXCEPTION and the procedure returns to the parser with the XML-CODE register still set to 0 which indicates that no further XML data will be provided to the parser 3) you terminate processing by moving -1 to XML-CODE

35 Parsing If XMLPARSE(XMLSS) is in effect, you can also use any of these optional phrases of the XML PARSE statement: ENCODING, to specify the CCSID of the document RETURNING NATIONAL to cause the parser to automatically convert UTF-8 or single byte characters to national characters for return to the processing procedure VALIDATING, to cause the parser to validate the document against an XML schema

36 Events For each event that occurs during parsing, the parser sets the associated event name in the XML-EVENT register and passes this to the processing procedure. Depending on the event, other registers can also be set Typically, XML-TEXT is set with the data that caused the event Some typical events: START-OF-DOCUMENT START-OF-ELEMENT ATTRIBUTE-NAME END-OF-ELEMENT CONTENT-CHARACTERS START-OF-CDATA-SECTION END-OF-DOCUMENT

37 Processing Flow

38 Parsing The parser checks XML documents for most aspects of well formedness. Documents can be parsed with or without validation Validation insures that the document adheres to the content and structure described in the schema. Validation can insure that there are no unexpected elements, no required elements are missing, and that element and attribute values are legal

39

40 Transforming XML Text to Cobol Data Items
For alphanumeric items decide if the XML data should be at the left or right end. For right justification define a field as JUSTIFIED RIGHT You might be able to move a numeric field that is decorated by moving it to a numeric-edited Cobol field. Then move it (de-edit) to a numeric field. Use intrinsic function NUMVAL to extract and decode simple numeric values Use intrinsic function NUMVAL-C to extract and decode XML data that represents monetary values

41 Exercise #1 Use the file BCST.SICCC01.PDSLIB(XMLDATA2)
The file structure is similar to the one below: <?xml version=”1.0” encoding=”ibm-1140” standalone=”yes”?> <batch> <trans> <name>Joe Smith</name> <amt>12.32</amt> <amt>5.42</amt> </trans> <trans <name>Tina Louise</name> <amt>8.99</amt> </batch

42 Exercise #1 Write an XML Cobol program that reads the file and copies it to memory. Print out a report that lists each customer name and a total for each customer. Print a grand total for the entire file Name Amount Joe Smith Tina Louise Grand Total

43 Parsing XML in Segments
Read a segment (record) from the file Pass the record to the parser using XML PARSE to start the parser Control flows between the parser and the processing procedure until the end of the record At record end, the parser returns control to the processing procedure after setting XML-EVENT to END-OF-INPUT and setting XML-CODE to 0.

44 Parsing XML in Segments
If the processing procedure reads the next record successfully, it sets XML-CODE to 1 to signal more input, and returns to the parser to continue parsing. This process continues until EOF when the processing procedure returns to the parser after leaving XML-CODE set to 0. CSU.PUBLIC.XML(XMLSEG) is a good example program to use

45 Exercise #2 Convert(XMLDATA2)
The file structure is similar to the one below: <?xml version=”1.0” encoding=”ibm-1140” standalone=”yes”?> <batch> <trans> <name>Joe Smith</name> <amt>12.32</amt> <amt>5.42</amt> </trans> <trans <name>Tina Louise</name> <amt>8.99</amt> </batch 45

46 Exercise #2 For this exercise, rework the code you wrote in Exercise #1 Use the same input file BCST.SICCC01.PDSLIB(XMLDATA2) Instead of reading all the XML into a single area of memory, read and process the XML file one record at a time 46

47 Exception Processing Document errors cause the parser to set an exception code in XML-CODE and to signal an XML exception event. The exception event can be handled by the ON EXCEPTION or NOT ON EXCEPTION clause of the PARSE statement

48 Exception Processing XML-CODE contains a four-byte field that is the concatenation of two two-byte fields: Return Code 2 Bytes Reason Code 2 Bytes XML-CODE 2 Bytes

49 Exception Processing Cobol definition of the return code and reason code fields: 1 XML-DECODE. 2 RTN COMP PIC 9(2). 2 RSN COMP-5 PIC 9(4). The two values combine to describe the error. Consult the IBM XML documentation for codes:

50 Printing the XML-CODE 1 XML-DECODE. 2 RTN COMP PIC 9(2).
2 RSN COMP-5 PIC 9(4). 1 HV PIC X(16) VALUE ' ABCDEF'. DISPLAY ' RC=' RTN ',REASON=X ''' HV(FUNCTION MOD(RSN / ) + 1:1) HV(FUNCTION MOD(RSN / ) + 1:1) HV(FUNCTION MOD(RSN / ) + 1:1) HV(FUNCTION MOD(RSN / ) + 1:1) ''''

51 Exception Processing Parsing does not continue after an exception is raised (for XMLPARSE(XMLSS)) When processing returns to the parser, control is passed to the statement in the ON EXCEPTION phrase If no exceptions occur during parsing, control is passed to the statement in the NOT ON EXCEPTION phrase (if it exists) or to the end of the XML PARSE statement

52 Exercise #3 Use program XMLONEXC unchanged to read file XMLDATA4 which is an XML file with “flaws” Repair the flaws in the XML by looking up the return and reason codes

53 Generating XML XML Generate statement is used to produce XML output
In the XML Generate statement, you identify the source and output data items Optionally, you can identify: A field to receive a count of XML characters that are generated A code page in which the generated XML document is to be encoded A namespace for the document A namespace prefix A statement to receive control if an exception occurs

54 XML GENERATE Use XML-CODE to determine the status of XML generation
COBOL programs that contain XML GENERATE must be link-edited with AMODE 31

55 Example XML GENERATE XML XML-OUTPUT FROM SOURCE-REC
COUNT IN XML-CHAR-COUNT ON EXCEPTION DISPLAY ‘XML GENERATION ERROR ‘ XML-CODE STOP RUN NOT ON EXCEPTION DISPLAY ‘SUCCESS GENERATING DOCUMENT’ END-XML

56 Example XML-OUTPUT must be defined to be large enough (usually 5 to 10 times as large as the source) Define the receiving field as alphanumeric or national group or elementary item Some Cobol items are not transformed Items that specifiy REDEFINES or are subordinated to a REDEFINES Items that specify a RENAMES

57 Source Items Elementary FILLER or unnamed items are not generated
Slack bytes inserted for SYNCHRONIZED data items are not generated No extra white space is inserted to make the generated XML more readable

58 Generate Example Generated XML (displayed after inserting spacing)
<A>aaa</A> <B> <C>ccc</C> <D>ddd</D> </B> <E>eee</E> </G> 01 doc pic x(512). 01 docSize pic 9(9) binary. 01 G. 05 A pic x(3) value “aaa”. 05 B. 10 C pic x(3) value “ccc”. 10 D pic x(3) value “ddd”. 05 E pic x(3) value “eee” XML GENERATE doc from G

59 Generate With Attributes
Generated XML (displayed after inserting spacing) <G A=“aaa” E=“eee”> <B C=“ccc” D=“ddd”> </B> </G> 01 doc pic x(512). 01 docSize pic 9(9) binary. 01 G. 05 A pic x(3) value “aaa”. 05 B. 10 C pic x(3) value “ccc”. 10 D pic x(3) value “ddd”. 05 E pic x(3) value “eee” XML GENERATE doc from G with attributes

60 Generate With Declaration
01 Greeting. 05 msg pic x(80) value ‘Hello’. XML GENERATE Doc from Greeting with Encoding 1208 with XML-declaration End-XML Generates: <? Xml version=“1.0” encoding=“UTF-8”?> <Greeting> <msg>Hello</msg> </Greeting>

61 Generate With Namespace
01 Greeting. 05 msg pic x(80) value ‘Hello’. 01 NS pic x(20) value ‘ XML GENERATE Doc from Greeting namespace is NS End-XML Generates: <pre:Greeting xmlns:pre=“ <pre:msg>Hello</pre:msg> </pre:Greeting>

62 Generate With Exception
01 Greeting. 05 msg pic x(80) value ‘Hello’. XML GENERATE Doc from Greeting ON EXCEPTION DISPLAY “ERROR CODE: “ XML-CODE NOT ON EXCEPTION DISPLAY “SUCCESSFUL PARSE” END-XML

63 Handling XML Generate Exceptions
If you code ON EXCEPTION, control is passed to the following sentence . XML-CODE contains the error code If you do not code ON EXCEPTION control is passed to the end of the XML GENERATE statement If you coded a COUNT IN field, that field contains the count of characters that were generated before an error occurred. Use reference modification to reference the data XML-OUTPUT(1:XML-CHAR-COUNT)

64 Exercise 4 Read file CSU.PUBLIC.DATA(XMLDAT1)
Generate XML that represents a batch of transactions

65 Exercise 5 Read file CSU.PUBLIC.DATA(XMLDAT2)
The data looks like this: <PHONEBOOK> <PERSON> <NAME>JOE SMITH</NAME> <AGE>30</AGE> <PHONE> </PHONE> </PERSON> <NAME>FRED FUNK</NAME> <AGE>49</AGE> <PHONE> </PHONE> </PHONEBOOK>

66 Exercise 5 I want the output to look like this:
<?xml version="1.0" encoding="IBM1047"?> <PHONEBOOK> <PHONEREC> <NAME>JOE SMITH</Name> <PHONE> </PHONE> </PHONEREC> <NAME>JILL IRELAND</NAME> <PHONE> </PHONE></PHONEREC> </PHONEBOOK>

67 Exercise 5 Use XMLHELLO and XMLSAMP1 and XMLONEXC (if needed) to guide the work

68 Parsing XML in Z/OS COBOL

69 XML in CICS

70 XML Schemas IBM uses the W3C XML Schema specification
W3C maintains excellent tutorials covering XML technologies Here is the XML Schema tutorial from which I am freely borrowing:

71 Schema Example <?xml version="1.0"?> <xs:schema xmlns:xs=" <xs:element name="note">   <xs:complexType>     <xs:sequence>       <xs:element name="to" type="xs:string"/>       <xs:element name="from" type="xs:string"/>       <xs:element name="heading" type="xs:string"/>       <xs:element name="body" type="xs:string"/>     </xs:sequence>   </xs:complexType> </xs:element> </xs:schema> ====================================================================== <?xml version="1.0"?> <note>   <to>Tove</to>   <from>Jani</from>   <heading>Reminder</heading>   <body>Don't forget me this weekend!</body> </note>

72 What do Schemas Do? An XML Schema:
defines elements that can appear in a document defines attributes that can appear in a document defines which elements are child elements defines the order of child elements defines the number of child elements defines whether an element is empty or can include text defines data types for elements and attributes defines default and fixed values for elements and attributes

73 XML Schemas are the Successors of DTDs
Here are some reasons: XML Schemas are extensible to future additions XML Schemas are richer and more powerful than DTDs XML Schemas are written in XML XML Schemas support data types XML Schemas support namespaces

74 Root Element <?xml version="1.0"?> <xs:schema> </xs:schema>

75 Simple Elements A simple element is an XML element that can contain only text. It cannot contain any other elements or attributes. The text can be of many different types. It can be one of the types included in the XML Schema definition (boolean, string, date, etc.), or it can be a custom type that you can define yourself. You can also add restrictions (facets) to a data type in order to limit its content, or you can require the data to match a specific pattern.

76 Simple Element Syntax The syntax for defining a simple element is:
<xs:element name="xxx" type="yyy"/>

77 Some Simple Data Types XML Schema has a lot of built-in data types, including: xs:string xs:decimal xs:integer xs:boolean xs:date xs:time

78 Simple Elements Here are some XML elements:
<lastname>Refsnes</lastname> <age>36</age> <dateborn> </dateborn> And here are the corresponding simple element definitions: <xs:element name="lastname" type="xs:string"/> <xs:element name="age" type="xs:integer"/> <xs:element name="dateborn" type="xs:date"/>

79 Default and Fixed Values for Simple Elements
Simple elements may have a default value OR a fixed value specified. A default value is automatically assigned to the element when no other value is specified. In the following example the default value is "red": <xs:element name="color" type="xs:string" default="red"/> A fixed value is also automatically assigned to the element, and you cannot specify another value. In the following example the fixed value is "red": <xs:element name="color" type="xs:string" fixed="red"/>

80 Attributes The syntax for defining an attribute is:
<xs:attribute name="xxx" type="yyy"/>

81 Attribute Example Here is an XML element with an attribute:
<lastname lang="EN">Smith</lastname> And here is the corresponding attribute definition: <xs:attribute name="lang" type="xs:string"/>

82 Optional and Required Attributes
Attributes are optional by default. To specify that the attribute is required, use the "use" attribute: <xs:attribute name="lang" type="xs:string" use="required"/>

83 Restrictions <xs:element name="age">   <xs:simpleType>     <xs:restriction base="xs:integer">       <xs:minInclusive value="0"/>       <xs:maxInclusive value="120"/>     </xs:restriction>   </xs:simpleType> </xs:element>

84 Complex Elements Contains other elements and/or attributes.
There are four kinds of complex elements: empty elements elements that contain only other elements elements that contain only text elements that contain both other elements and text

85 Empty Complex Element <product pid="1345"/>

86 Complex Element Containing Other Elements
<employee>   <firstname>John</firstname>   <lastname>Smith</lastname> </employee>

87 Complex Element Containing Only Text
<food type="dessert">Ice cream</food>

88 Complex Element with Elements and Text
<description> It happened on <date lang="norwegian"> </date> .... </description>

89 Complex Sequence <xs:element name="employee">   <xs:complexType>     <xs:sequence>       <xs:element name="firstname" type="xs:string"/>       <xs:element name="lastname" type="xs:string"/>     </xs:sequence>   </xs:complexType> </xs:element> ========================================= <employee>   <firstname>John</firstname>   <lastname>Smith</lastname> </employee>

90 Building a Complex Type
<xs:element name="employee" type="personinfo"/> <xs:element name="student" type="personinfo"/> <xs:element name="member" type="personinfo"/> <xs:complexType name="personinfo">   <xs:sequence>     <xs:element name="firstname" type="xs:string"/>     <xs:element name="lastname" type="xs:string"/>   </xs:sequence> </xs:complexType>

91 Empty Elements <product prodid="1345" />
================================ <xs:element name="product">   <xs:complexType>     <xs:complexContent>       <xs:restriction base="xs:integer">         <xs:attribute name="prodid" type="xs:positiveInteger"/>       </xs:restriction>     </xs:complexContent>   </xs:complexType> </xs:element> Does not introduce any element content.

92 Complex Elements with Only Elements
<xs:element name="person">   <xs:complexType>     <xs:sequence>       <xs:element name="firstname" type="xs:string"/>       <xs:element name="lastname" type="xs:string"/>     </xs:sequence>   </xs:complexType> </xs:element> Or <xs:element name="person" type="persontype"/> <xs:complexType name="persontype">   <xs:sequence>     <xs:element name="firstname" type="xs:string"/>     <xs:element name="lastname" type="xs:string"/>   </xs:sequence> </xs:complexType>

93 Complex Text Only <shoesize country="france">35</shoesize>
<xs:element name="shoesize">   <xs:complexType>     <xs:simpleContent>       <xs:extension base="xs:integer">         <xs:attribute name="country" type="xs:string" />       </xs:extension>     </xs:simpleContent>   </xs:complexType> </xs:element> ============================================ <shoesize country="france">35</shoesize>

94 Content with Mixed Type
<xs:element name="letter">   <xs:complexType mixed="true">     <xs:sequence>       <xs:element name="name" type="xs:string"/>       <xs:element name="orderid" type="xs:positiveInteger"/>       <xs:element name="shipdate" type="xs:date"/>     </xs:sequence>   </xs:complexType> </xs:element> ============================================================ <letter>   Dear Mr.<name>John Smith</name>.   Your order <orderid>1032</orderid>   will be shipped on <shipdate> </shipdate>. </letter> To enable character data to appear between the child-elements of "letter", the mixed attribute must be set to "true".

95 Seven Indicators Order indicators: All Choice Sequence
Occurrence indicators: maxOccurs minOccurs Group indicators: Group name attributeGroup name

96 Family XML <?xml version="1.0" encoding="ISO "?> <persons xmlns:xsi=" xsi:noNamespaceSchemaLocation="family.xsd"> <person>   <full_name>Hege Refsnes</full_name>   <child_name>Cecilie</child_name> </person> <person>   <full_name>Tove Refsnes</full_name>   <child_name>Hege</child_name>   <child_name>Stale</child_name>   <child_name>Jim</child_name>   <child_name>Borge</child_name> </person> <person>   <full_name>Stale Refsnes</full_name> </person> </persons>

97 Family Schema <?xml version="1.0" encoding="ISO "?> <xs:schema xmlns:xs=" elementFormDefault="qualified"> <xs:element name="persons">   <xs:complexType>     <xs:sequence>       <xs:element name="person" maxOccurs="unbounded">         <xs:complexType>           <xs:sequence>             <xs:element name="full_name" type="xs:string"/>             <xs:element name="child_name" type="xs:string"             minOccurs="0" maxOccurs="5"/>           </xs:sequence>         </xs:complexType>       </xs:element>     </xs:sequence>   </xs:complexType> </xs:element> </xs:schema>

98 Schema Must Be Compiled in z/OS
Go to a UNIX prompt with TSO OMVS Type: xsdosrg -v -o /u/HLQ/xml/item.osr /u/HLQ/xml/item.xsd

99 Modifying XML Parse XML PARSE myDocument VALIDATING WITH mySchema
PROCESSING PROCEDURE myProc ON EXCEPTION DISPLAY “DOCUMENT ERROR” NOT ON EXCEPTION DISPLAY “VALID DOCUMENT” END-XML

100 Schema Specification ENVIRONMENT DIVISION. CONFIGURATION SECTION.
SPECIAL-NAMES. XML-SCHEMA mySchema IS ‘DDSCHEMA’ JCL: //DDSCHEMA DD PATH=‘u/xml/item.osr’

101 Exercise 6 Try writing a schema for XMLDATA2 in CSU.PUBLIC.DATA
Modify XMLHELLO to parse the document with your schema Modify the data to have bad values and run your program against the schema


Download ppt "XML and COBOL."

Similar presentations


Ads by Google