DEV15: XML in OpenEdge Past, Present and Future - PowerPoint PPT Presentation

1 / 60
About This Presentation
Title:

DEV15: XML in OpenEdge Past, Present and Future

Description:

Item ID='1' Mozart's Requiem /Item Item ID='2' Big Hits /Item /Music (Text) Big Hits ... WRITE-CHARACTERS('Mozart's Requiem'). hSaxW:END-ELEMENT('Item' ... – PowerPoint PPT presentation

Number of Views:1059
Avg rating:3.0/5.0
Slides: 61
Provided by: PSC64
Category:

less

Transcript and Presenter's Notes

Title: DEV15: XML in OpenEdge Past, Present and Future


1
DEV-15 XML in OpenEdgePast, Present and Future
Robin Brown
Principal Software Engineer
2
Why XML is Important
Extensible Markup Language (XML) embodies the
potential to alleviate many of the
interoperability problems associated with the
sharing of documents and data.
XML.Gov home page, http//xml.gov/index.asp
3
Why XML is Important
  • Why XML?
  • Industry standard format for data exchange
  • Use Cases
  • Sending structured data over the Internet
  • Back bone of Web Services/SOAP
  • Sharing data with 3rd party applications
  • Crystal Reports
  • Persistent storage between 4GL sessions
  • Context Management

4
OpenEdge Support for XML
9.1A
X-Document Load/Save
Were making XML easier to use
1999 2000 2001 2002 2003
2004 2005 2006
5
Agenda
  • DOM and SAX Review
  • SAX-WRITER Object
  • XML Schema Validation
  • ProDataSet and Temp-Table to/from XML
  • Whats Next

6
XML DOM vs. SAX
  • Document Object Model (DOM)
  • W3C standard
  • DOM Tree in Memory
  • Application logic - Tree traversal tree
    building
  • Simple API for XML (SAX)
  • De facto standard
  • Stream forward only
  • Application logic Callbacks

7
DOM X-DocumentLOAD( )
lt?xml version1.0?gt ltMusicgt ltItem
ID"1"gtMozart's Requiemlt/Itemgt ltItem
ID"2"gtBig Hitslt/Itemgt lt/Musicgt
CREATE X-DOCUMENT hDoc. hDocLOAD("file",
Music.xml", FALSE).
(Element) Music
(Element) Item ID2
(Element) Item ID1
(Text) Mozarts Requiem
(Text) Big Hits
8
DOM Parsing the Tree and Extracting
CREATE X-DOCUMENT hDoc. CREATE X-NODEREF
hRoot. CREATE X-NODEREF hChild. CREATE X-NODEREF
hText. hDocLOAD("file", Music.xml",
FALSE). hDocGET-DOCUMENT-ELEMENT(hRoot). /
ltMusicgt / REPEAT i 1 TO hRootNUM-CHILDREN
hRootGET-CHILD(hChild, i). / ltItemgt /
IF hChildNUM-CHILDREN lt 1 THEN NEXT.
cID hChildGET-ATTRIBUTE(ID).
hChildGET-CHILD(hText, 1). / Item Text /
CValue hTextNODE-VALUE. END.
1
2
6
7
3
4
8
5
9
9
DOM Building the Tree and Saving
CREATE X-DOCUMENT hDoc. CREATE X-NODEREF
hRoot. CREATE X-NODEREF hChild. CREATE X-NODEREF
hText. hDocCREATE-NODE(hRoot,"Music","ELEMENT")
. hDocAPPEND-CHILD(hRoot). hDocCREATE-NODE(hChi
ld, "Item", "ELEMENT"). hRootAPPEND-CHILD(hChild)
. hChildSET-ATTRIBUTE("ID", "1"). hDocCREATE-N
ODE(hText, "", "TEXT"). hChildAPPEND-CHILD(hText)
. hTextNODE-VALUE "Mozart's Requiem". hDocSAV
E("file","Music2.xml").
1
2
3
4
5
6
7
8
9
10
SAX-ReaderPARSE( )
lt?xml version1.0?gt ltMusicgt ltItem ID"1"gt
Mozart's Requiem lt/Itemgt lt/Musicgt
1
2
3
/ Handler.p / PROC StartElement
END. PROC Characters END. PROC
EndElement END.
4
5
1
2
CREATE SAX-READER hSax. hSaxSET-INPUT-SOURCE("FIL
E", "Music.xml"). RUN Handler.p
Persistent SET h. hSaxHANDLER
h. hSaxPARSE().
3
4
5
11
DOM vs. SAX
12
Agenda
  • DOM and SAX Review
  • SAX-WRITER Object
  • XML Schema Validation
  • ProDataSet and Temp-Table to/from XML
  • Whats Next

13
SAX-Writer Functionality
  • Coding easier than DOM
  • Fewer objects
  • SAX-Writer object

Syntax
CREATE SAX-WRITER handle IN WIDGET-POOL
pool-nameNO-ERROR.
Example
DEFINE VARIABLE hSAXWriter AS HANDLE
NO-UNDO. CREATE SAX-WRITER hSAXWriter NO-ERROR.
14
SAX-Writer Object
Methods (partial list)
  • START-DOCUMENT
  • START-ELEMENT
  • SET-OUTPUT-DESTINATION
  • WRITE-CHARACTERS
  • DECLARE-NAMESPACE
  • END-DOCUMENT
  • END-ELEMENT
  • INSERT-ATTRIBUTE
  • WRITE-DATA-ELEMENT

Attributes
  • ENCODING
  • FRAGMENT
  • STRICT
  • WRITE-STATUS (Read-Only)
  • FORMATTED
  • STANDALONE
  • VERSION

15
SET-OUTPUT-DESTINATION ( )
Defines the target for XML document
Syntax
handleSET-OUTPUT-DESTINATION (mode,filestream
memptrlongchar).
Example
CREATE SAX-WRITER hSAXWriter. ret
hSAXWriterSET-OUTPUT-DESTINATION
(FILE,C\OpenEdge\WRK\swMusic.xml).
16
Invoke Methods in Typical Order
CREATE SAX-WRITER SET-OUTPUT-DESTINATION
START-DOCUMENT START-ELEMENT
START-ELEMENT INSERT-ATTRIBUTE
WRITE-DATA-ELEMENT END-ELEMENT
WRITE-CHARACTERS END-ELEMENT END-DOCUMENT
17
SAXWRITER Example
CREATE SAX-WRITER hSaxW. hSaxWSET-OUTPUT-DESTINA
TION("file", "swMusic.xml"). hSaxWSTART-DOCUMENT
(). hSaxWSTART-ELEMENT("Music"). hSaxWSTART-EL
EMENT("Item"). hSaxWINSERT-ATTRIBUTE("ID",
"1"). hSaxWWRITE-CHARACTERS("Mozart's
Requiem"). hSaxWEND-ELEMENT("Item"). hSaxWEND-E
LEMENT("Music"). hSaxWEND-DOCUMENT().
1
2
3
4
5
6
7
8
9
18
STRICT Attribute
  • Forces XML to be well-formed

/ STRICT TRUE. / START-DOCUMENT
START-ELEMENT START-ELEMENT
WRITE-DATA-ELEMENT END-ELEMENT
WRITE-CHARACTERS END-DOCUMENT
END-DOCUMENT FAILS!
19
Agenda
  • DOM and SAX Review
  • SAX-WRITER Object
  • XML Schema Validation
  • ProDataSet and Temp-Table to/from XML
  • Whats Next

20
XML Schema Validation
  • Verify that data adheres to an agreed upon format
  • Validation occurs at runtime
  • X-Document Object
  • LOAD( )
  • Sax-Reader Object
  • PARSE( )
  • PARSE-FIRST( )
  • PARSE-NEXT( )

21
Schema Validation
  • Pre-10.1A - DTD
  • Document Type Definition
  • Older technology
  • XML Document MUST contain or specify DTD
  • 10.1A - XSD
  • XML Schema Definition
  • Emerging standard (W3C)
  • XSD can be external to XML
  • Both DTD and XSD supported in 10.1A

22
New Method / Attributes
Applies to X-Document and Sax-Reader objects
  • Method
  • ADD-SCHEMA-LOCATION
  • Attributes
  • SCHEMA-LOCATION
  • NONAMESPACE-SCHEMA-LOCATION

23
DOM Example
CREATE X-DOCUMENT hDoc. hDocADD-SCHEMA-LOCATION
("urnmusic", "Music.xsd"). hDocLOAD("file",
"Music.xml", TRUE / validate /).
24
SAX Example
CREATE SAX-READER hSax. hSaxSET-INPUT-SOURCE
(file, Music.xml). hSaxSCHEMA-LOCATION
urnmusic Music.xsd. hSaxVALIDATION-ENABLED
TRUE. / validate / hSaxPARSE( ).
25
Agenda
  • DOM and SAX Review
  • SAX-WRITER Object
  • XML Schema Validation
  • ProDataSet and Temp-Table to/from XML
  • Whats Next

26
ProDataSet Functionality Continues to Mature
  • OpenEdge 10.1A simplifies and adds options for
    working with ProDataSets

27
New Methods Added
  • WRITE-XML
  • WRITE-XMLSCHEMA
  • READ-XML
  • READ-XMLSCHEMA

ttItem
  • Methods apply to
  • ProDataSet
  • Temp-Table
  • Temp-Table Buffer

.xsd
.xsd
.xml
.xml
28
WRITE-XML ( )
Syntax
WRITE-XML (target-type, file stream memptr
handle longchar , formatted , encoding
, schema-location, , write-schema ,
min-schema, write-before-image)
.xml
.xml
ttItem
(write-before-image for ProDataSets only)
29
Temp-table Example
TEMP-TABLE ttItemWRITE-XML ("FILE",
/target-type/ "ttItemXML.xml", / file name
/ TRUE, / formatted / ?,
/ encoding / ?, /
schema location / ?, / write
schema / ?). / min XML Schema /
Format the output
30
Data ONLY - Temp-Table ttItem
31
ProDataSet Example XML with Schema
DATASET dsOrderWRITE-XML ("FILE",
"DSWriteXMLAndSchema.xml",
TRUE, / formatted / ?,
/ encoding / ?, / schema
location / TRUE, / write
schema / TRUE, / min XML
Schema / ?). /
writebeforeimage /
Write XML Schema with the data
32
ProDataSet Example writeschemaTRUE
XML Schema
XML data
33
ProDataSet Example writeschemaTRUE
XML data
34
ProDataSet Example XML with Before-Tables
DATASET mydsWRITE-XML("FILE", / target-type /
custOrdBefore.xml",
/file/ TRUE, /
formatted / ?, /
encoding / ?, /
schema location / ?,
/ write schema / ?,
/ min XML schema /
TRUE)./ write beforeimage /
Write the Before Table data
35
ProDataSet writebeforeImage TRUE
After table data
Record marked as modified
Record marked as created
36
ProDataSet writebeforeImage TRUE
Before-image of modified record
37
WRITE-XMLSCHEMA ( )
  • Write XML Schema Definition (XSD)
  • For Temp-Tables contains
  • Table definition, including indexes
  • For ProDataSets contains
  • Table definitions, including indexes
  • Data relation definitions

ttItem
.xsd
.xsd
38
Using with Temp-Tables and ProDataSets
Syntax
WRITE-XMLSCHEMA (target-type, file stream
memptr handle longchar , formatted ,
encoding , min-xmlschema )
  • min-xmlschema
  • if TRUE only write standard XML Schema structures
  • if FALSE, add XML Schema extensions from
    prodata namespace
  • Allows round-trip of Progress definition

39
Progress XML Schema Extensions
MIN-SCHEMA TRUE

MIN-SCHEMA FALSE
40
Temp-table Example
TEMP-TABLE ttItemWRITE-XMLSCHEMA ("FILE",
/target-type/ "ttItem.xsd", / file name
/ TRUE, / formatted / ?,
/ encoding / FALSE). / min XML
Schema /
Write XML Schema Extensions
41
Progress XML Schema Extensions
prodata namespace
field-level attributes
non-unique index definition
42
XML Read Methods
  • READ-XML
  • READ-XMLSCHEMA

.xsd
ttItem
.xml
.xsd
.xml
43
READ-XML Method
  • Populates ProDataSet or Temp-Table with
  • XML data, XML Schema, or Both

Syntax
READ-XML (source-type, file memptr handle
longchar , read-mode , schema-location
, override-default-mapping ,
field-type-mapping , verify-schema-mode )
44
Reading XML Into A ProDataSet
READ-XML( )
  • Reads XML containing Before-Image information
  • Progress datasetChanges
  • Microsoft Diffgram
  • ProDataSet events DO NOT fire
  • Change tracking is turned OFF

45
Using READ-XMLSCHEMA( )
  • Create a Progress definition from XML Schema
  • Verify XML Schema against Progress definition

Syntax
READ-XMLSCHEMA (source-type, file
memptr handle longchar ,
override-default-mapping , field-type-mapping
, verify-schema-mode )
46
New XML Attributes
Gives you Control over XML format
  • Available on static definitions
  • DEFINE DATASET, TEMP-TABLE, BUFFER

47
XML-NODE-TYPE Attribute
BUFFER ttItemBUFFER-FIELD(1)XML-NODE-TYPE
Attribute.
48
NESTED Attribute ProDataSet Data-Relation
DATASET CustOrderGET-RELATION(custOrd)NESTED
TRUE.
Order Records NESTED within Customer 1
49
ProDataSet and Temp-Table To/From XML
The right features for the right job!
  • Easier than DOM and SAX
  • Productivity increase
  • Faster than DOM and SAX
  • Performance increase
  • Relational structure maps well to XML
  • XML data (.xml)
  • XML Schema (.xsd)

50
ProDataSet and Temp-Table To/From XML
The right features for the right job!
  • Easier than SAX and DOM
  • Productivity increase
  • Faster than SAX and DOM
  • Performance increase
  • Relational structure maps well to XML
  • XML data (.xml)
  • XML Schema (.xsd)

51
Demo
52
Agenda
  • DOM and SAX Review
  • SAX-WRITER Object
  • XML Schema Validation
  • ProDataSet and Temp-Table to/from XML
  • Whats Next

53
Under Development
  • This talk includes information about potential
    future products and/or product enhancements.
  • What I am going to say reflects our current
    thinking, but the information contained herein is
    preliminary and subject to change. Any future
    products we ultimately deliver may be materially
    different from what is described here.

54
XML Futures
  • SAX-ATTRIBUTES
  • XSLT
  • XPath / XQuery
  • Support for XML 1.1 / 2.0

55
In Summary
  • XML is Key Component in SOA Architectures
  • OpenEdge provides the ABL to work with XML
  • Were continuing to make working with XML easier

56
For More Information...
  • Relevant Exchange Sessions
  • DEV-9 Using the ProDataSet in OpenEdge 10
  • SOA-12 Integrate over the Web with OpenEdge Web
    Services
  • Other Resources
  • PSDN
  • http//www.xml.com

57
Education / Documentation References
  • Course
  • XML Essentials
  • 4GL Development with XML
  • What's New in OpenEdge 10.1 SOA Support
  • Documentation
  • OpenEdge Development Progress 4GL Reference
  • OpenEdge Development Programming Interfaces

58
Questions?
59
Thank you foryour time
60
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com