grokking xml lab - csdainc.com xml.pdf · grokking xml what you need to get started: xml editing...

90
Grokking XML Lab David Andruchuk Sr. Architect Computer Systems Design Associates, Inc. November 14, 2008 What can i do…..i can do XML

Upload: others

Post on 12-Jul-2020

19 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML Lab

David Andruchuk

Sr. Architect

Computer Systems Design Associates, Inc.

November 14, 2008

What can i do…..i can do XML

Page 2: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Grok

To understand so thoroughly that the observer becomes a part of the observed—to merge,

blend, intermarry, lose identity in group experience. It means almost everything that we

mean by religion, philosophy, and science—and it means as little to us (because we are

from Earth) as color means to a blind man.

Page 3: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Table of Contents

• Introduction

Introduction to XML

• Programmatic Approach

Using IBM RAD & XML

Using Excel & XML

Using SQL for XML compose

Using RPG for XML decompose

Page 4: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

• XML has become a standard for cross-platform communications

• XML has or will impact your business if you continue to be in business

• XML has gained acceptance as a preferred data exchange technology in spite of the limitations because of the flexibility and human readable formatting

Page 5: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Introduction to XML

Page 6: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

What you need to get started:

XML Editing tool(s)

WDSC, Rational Application Developer (RAD) (IBM)

XMLSpy (Altova)

Stylus Studio (Progress Software Corporation)

Microsoft Office 2003 or higher

XML Reference(s)

WDSC Step by Step (MC Press)

XML for eServer i5 and iSeries (MC Press)

Qshell for iSeries (MC Press)

XSLT 2nd Edition (WROX)

W3Schools Online Web Tutorials (www.w3schools.org)

Page 7: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

What is XML?

– XML is short for Extensible Markup Language

Pros of XML?

– XML is flexible

– XML is self documenting

– XML can replace or extend legacy systems

Cons of XML?

– XML is verbose

– XML can significantly increases the size of your data

– XML works best with hierarchal data in a relational

data base

Page 8: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

There are three main components of XML

• XML Document

– Document containing data

• XML Document Type Definition (DTD)

– Document that defines the document structure of the

XML Document

• XML Schema Definition (XSD)

– Document that defines the document structure of the

XML Document in an XML-based alternative to DTD

Page 9: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Structure of XML documents

• An XML document has a tree-like structure that is

hierarchical

• The document must contain one and only one root

element

• An element is the parent of all the elements it contains

• The elements that are inside a parent element are called

its children

• Similarly, the elements that have the same parent

element are called siblings

Page 10: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Page 11: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Page 12: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Structure of DTD documents

Contains the list of tags which are allowed within the

XML document and their types and attributes

Defines how elements relate to one another within the

document's tree structure and specifies which attributes

may be used with which elements

Page 13: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Page 14: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Structure of XSD documents

• Contains the legal building blocks of an XML document

similar to DTD

• Defines how elements relate to one another within the

document's tree structure and specifies which attributes

may be used with which elements

• Schema supports all data types used in most

programming languages such as string, decimal, integer,

Boolean, date and time

• Supports complexType elements that allows you to

define an element type that can consist of sub-elements

Page 15: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Page 16: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Programmatic Approach

Page 17: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

RAD & XML

This product provides a comprehensive visual Extensible Markup

Language (XML) development environment. Tools help you create,

import, edit, validate, and generate XML, XSL, DTDs, and XML

schemas (XSD) files. Mapping tools help you establish relationships

between XML files and between XML files and relational database

tables.

(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.

Page 18: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Opening an XML document with RAD XML document

Right click > open with > rationalsdp (eclipse on RAD 7.0)

Page 19: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Create workspace Enter C:\Grokking_XML\RAD_workspace and leave Use this as the default….unchecked!

Page 20: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Open a Perspective Window>Open Perspective>Other>Resource

Page 21: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Create new project In Navigator pane

Right Click>New>Project>Simple (General on RAD7.0)>Next

Page 22: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Create new project (continued) Enter Project Name Grokking_XML and click Finish

Page 23: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Import employee XML document to project Again in Navigator pane

Right click Grokking_XML project>Import>(General on RAD7.0) File

System>Next>Browse>Select XML file>Finish

Page 24: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Create generic schema (XSD) to enable XML Development Again in Navigator pane

Right click employee.XML document>New>Other>Show All Wizards.>XML>XML

Schema>Next> Check Always enable capabilities…>OK

Page 25: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Create generic schema (XSD) (continued) Enter or select the parent folder Grokking_XML>Leave file name NewXMLSchema.xsd>Finish

Page 26: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Our new generic schema in project The Navigator pane is redisplayed showing the new XSD

Page 27: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Create employee schema (XSD) With XML Development now enabled for our project, we can generate the Employee XSD from

our existing employee XML document.

In the Navigator pane

Right click the employee.xml document>Generate (NOT in RAD7.0) >XML Schema…

Page 28: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Create employee schema (XSD) (continued) Accept the File name as is and click Finish

Page 29: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Create employee schema (XSD) (continued) The XML Schema generated window is now displayed, click OK

Page 30: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Delete generic schema (XSD) The generic XML Schema generated to enable XML can now be deleted

In the Navigator pane

Right click the NewXMLSchema.xsd document>Delete>Click Yes…

Page 31: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Create employee document type definition (DTD) With the Employee XSD generated, we can generate the Employee DTD from our existing XSD

In the Navigator pane

Right click the employee.xsd document>Generate (NOT in RAD7.0) >DTD…

Page 32: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Create employee document type definition (DTD) (continued) Accept the File name as is and click Finish

Page 33: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Create employee document type definition (DTD) (continued) The DTD generated window is now displayed, click OK

Page 34: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Exit RAD Click File>Exit and if any resources need to be saved prior to exit, Click OK

Page 35: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

RAD & XML recap

What we accomplished:

Created a project to Grok XML

Imported our sample XML document

Generated an XSD & DTD from the XML document

What we could still accomplish:

Assign our XSD & DTD to our XML document for validation

Edit our XML, XSD & DTD documents in RAD to verify that the XSD & DTD

generated are accurate in regards to

Repeating elements are correctly defined

Validations required for elements/attributes

Required elements are defined

Save our document(s) to a mapped IFS folder on our System i

Page 36: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Excel & XML

New tools in Microsoft Office Excel 2003 make it easier to work with

Extensible Markup Language (XML). Learn how to use these tools to

create XML lists and XML maps. XML lists have the same look and feel

as regular Excel lists, but they take their data from XML files. XML maps

are sets of links between the cells in a worksheet and the elements in

an XML schema. You can import data into the map, modify the data,

and then save the changed data or export it for others to use.

Page 37: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Create an Excel document In our Grokking_XML\RAD_workspace\Grokking_XML folder

Right click>New>Microsoft Excel Worksheet

Page 38: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Create an Excel document (continued)

Now name it employee.xls

Page 39: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Create an Excel document (continued) Now double click to open it

Page 40: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Importing XML into Excel is easy There are two ways we can import our XML data into our spreadsheet: with or without an

existing Schema (XSD).

In this example, we will simply import the XML data and let Excel generate a schema template

for us.

Click Data>Import External Data>Import Data

Page 41: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Importing XML w/o a schema Now select the source of our import, our employee.xml document and click Open

Page 42: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Importing XML w/o a schema (continued) Click OK when the Error in XML window is display to instruct Excel to create a schema for us

and apply to our worksheet

Page 43: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Importing XML w/o a schema (continued) Except the defaults on the Import Data window and click OK

Page 44: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Importing XML w/o a schema (continued) We have now successfully imported an XML document into an Excel worksheet

Page 45: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Importing XML w/o a schema (continued) Notice the bold column names. This indicates that the schema mappings apply to the columns

so that an XML document could be generated from this worksheet. Let’s display the

underlying XML of this worksheet.

Click Data>XML>XML Source

Page 46: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Importing XML w/o a schema (continued) In the XML Source window displayed to the right of our worksheet, the Excel generated

Employees_Map schema(XSD) is displayed

Page 47: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Importing XML w/o a schema (continued) If you click the Tips for mapping XML link, a help panel is displayed defining more about the

workings of Excel & XML

Page 48: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Adding an XML Map using a schema (XSD) In this example, we will use an existing schema (XSD) as the template.

Click Data>XML>XML Source…

Page 49: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Adding an XML Map using a schema (XSD) (continued) Click XML Maps>Add…>employee.xsd>Open

Page 50: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Adding an XML Map using a schema (XSD) (continued) Click Employees>OK in the Multiple Roots windows since Employees, not Employee is our root

Page 51: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Adding an XML Map using a schema (XSD) (continued) Click OK in the XML Maps windows

Page 52: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Adding an XML Map using a schema (XSD) (continued) In XML Source window, right click the Employees root>Map element…>Click OK in Map XML

Element window

Page 53: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Our worksheet with the Employee Map Notice the markings on the Employee_Map showing that each element is now mapped to a

worksheet column and that the columns are now in bold and the XML containment box

Page 54: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Importing the Employee XML document Click Data>XML>Import>employee.xml>Import

Page 55: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Our worksheet with the Employee XML data Notice the markings on the worksheet that surrounds the column data. The blue box

designates the containment of the XML Source template.

Page 56: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Adding data to our worksheet Right click a row>Insert>Row>key data to the row to populate each column as you would in any

worksheet

Page 57: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Saving/Exporting our worksheet To save the worksheet as XML data you can either:

Click File>Save As…>Save as type: XML Data(*.xml)>name file>Save

Click Data>XML>Export…>name file>Export

Page 58: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Excel & XML recap

What we accomplished:

Imported our employee XML document and generated an XML Map

Applied an existing XSD schema as an XML Map to our worksheet

Imported our employee XML data

Added a row to our worksheet

Saved/Exported our XML data

What we could still accomplish:

Perform editing of column(s) in Excel to validate input

Save our document(s) to a mapped IFS folder on our System i

Page 59: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

SQL & XML composition

Using the System i SQL engine we can create an SQL Procedure that

will generate the Employee XML document used in our lab so that we can

understand the simplicity of XML composition without any special coding

requirements or tools on our existing System i.

Page 60: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding the SQL stored procedure

Page 61: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding the SQL stored procedure (continued)

Page 62: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding the SQL stored procedure (continued)

Page 63: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding the SQL stored procedure (continued)

Page 64: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding the SQL stored procedure (continued)

Page 65: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Creating the SQL stored procedure

Page 66: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Executing the SQL stored procedure

Page 67: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Some considerations for SQL Composition

SQL Stored Procedures contain two parts: a catalog entry and a program

object. These two items can exist separate of each other but only work

when both parts are there at run time and are not as easy to implement as

using a SAVOBJ & RSTOBJ.

Work around for this limitation:

- Run the SQL Create Procedure statement on each box they are to be

used on

to create the catalog entry and program object

Page 68: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

SQL & XML recap

What we accomplished:

Created a source member that contained our SQL source

Created the SQL procedure using RUNSQLSTM

Executed the SQL procedure to generate the employee XML data

What we could still accomplish:

Add variables to the SQL source for our procedure for flexibility

Add maintenance coding to DROP the procedure before create and the

Outfile table once complete

Page 69: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

RPG & XML decomposition

The ILE RPG Compiler as of the V5R4 release of i5/OS has new native

operations codes and built in functions that facilitate decomposition of an

XML document into data structures defined in the program using a

non-validating parser. For more information on the XML parser used by

ILE RPG, please refer to Chapter 11 in the WebSphere Development

Studio ILE RPG Programmer’s Guide, SC09-2507.

The advantage of using the new operation codes and built-in functions

added to RPG is that once the hierarchy of the XML document is

replicated using data structures in our RPG program code, the

decomposition of the XML data and population of data structure fields is

done automatically and efficiently without the developer having to

manipulate storage to get the XML data in to workable form. The

complexity has been removed from the XML decomposition process

and the developer now can just concentrate on business logic required

to implement the XML data. No pointers, API interfaces, buffer

manipulation, just straight forward RPG coding.

Page 70: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding a CMD interface

Page 71: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding a PNLGRP for the CMD interface

Page 72: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding a PNLGRP for the CMD interface (continued)

Page 73: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding a PNLGRP for the CMD interface (continued)

Page 74: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding a CLLE validation module

Page 75: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding a CLLE validation module (continued)

Page 76: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding a CLLE validation module (continued)

Page 77: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding a CLLE validation module (continued)

Page 78: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding the SQLRPGLE module for decomposition

Page 79: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding the SQLRPGLE module (continued)

Page 80: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding the SQLRPGLE module (continued)

Page 81: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding the SQLRPGLE module (continued)

Page 82: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding the SQLRPGLE module (continued)

Page 83: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding the SQLRPGLE module (continued)

Page 84: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding the SQLRPGLE module (continued)

Page 85: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding the SQLRPGLE module (continued)

Page 86: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Coding the SQLRPGLE module (continued)

Page 87: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Executing the XML decomposition

Page 88: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Some considerations for RPG Decomposition

Use of the Java Virtual Machine (JVM) on a System i requires some simple

tuning to optimize performance. Since we use the JVM to run our Transform

class it is important to note the memory pool that your JVM executes in be

set appropriately to improve performance.

XML-INTO operation cannot handle empty elements or attributes that

contain zero length numeric, date, time or timestamp fields during

decomposition.

Work around for this limitation:

- Use a stylesheet (XSL) as we did to remove the empty limitations

noted above

Page 89: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Some considerations for RPG Decomposition (continued)

The RPG compiler limits character variables to 65535 characters in length. Data

Structures, being considered character fields, are subject to this length limitation

as well. You must be aware when replicating the XML tree using data

structures, especially data structures that are dimensional, that the total size of

the data structure tree does not exceed this limit as well.

Work around for this limitation:

- break apart the data structures without nesting them in side each other and

use multiple XML-INTO operations to decompose specifying the specific

path of the XML document that matches the data structure names.

Page 90: Grokking XML Lab - csdainc.com XML.pdf · Grokking XML What you need to get started: XML Editing tool(s) WDSC, Rational Application Developer (RAD) (IBM) XMLSpy (Altova) Stylus Studio

Grokking XML

Questions?