[go: up one dir, main page]

0% found this document useful (0 votes)
153 views35 pages

PB9 Data Window XML

This document discusses XML support in PowerBuilder 9.0, including: - Defining XML templates in the DataWindow painter to map DataWindow values to XML elements and attributes. - New DataWindow properties to control exporting and importing XML. - Enhanced methods for exporting DataWindow data to XML and importing XML data. - Generating XSL-FO from a DataWindow to render XML data as PDF.

Uploaded by

chediru0722
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
153 views35 pages

PB9 Data Window XML

This document discusses XML support in PowerBuilder 9.0, including: - Defining XML templates in the DataWindow painter to map DataWindow values to XML elements and attributes. - New DataWindow properties to control exporting and importing XML. - Enhanced methods for exporting DataWindow data to XML and importing XML data. - Generating XSL-FO from a DataWindow to render XML data as PDF.

Uploaded by

chediru0722
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 35

E 174 DataWindows, XML & XSL-FO in PowerBuilder 9.

0
> Angelo Scipione Staff S/W Engineer Sybase, Enterprise Solutions Div. Scipione@sybase.com

Agenda

> Review the basic concepts of XML

> Defining XML Templates in the DataWindow Painter


> New DataWindow Properties to control exporting & importing XML > Enhanced methods for exporting & importing XML > Generating XSL-FO

Review of XML
Extensible Markup Language

> Extends the ability to represent data


> Metadata language=tags & layout can be customized > Data can be hierarchically structured with nesting > Easily parsed across applications, platforms, enterprises, and Web for data interchange

> Spec at http://www.w3.org/TR/REC-xml

XML Document

> Well-Formed if structure follows XML syntax rules

> Contains one or more elements


Element is a tree containing start-tag, content, end-tag Start-tag is a name, enclosed by angle brackets, with optional attributes

> One root; all element tags properly nested

> Valid if structure conforms to a DTD or Schema


> DTD defines grammar for XML document
Subset can be internal or external

XML Parsing
DOM Parser

> DOM provides API access to XML tree model


> Useful if manipulating or re-traversing the document SAX Parser > Event-driven > Useful if extracting data once in single traversal Apache Xerces-C++ integrated in PowerBuilder 9.0 > More on this (PBDOM) presented in E 171

XML Modeled by DOM Tree


<?xml version=1.0 encoding=UTF-8?> <!DOCTYPE menu SYSTEM menu.dtd> menu <menu> <meal name=breakfast> <food> Scrambled Eggs </food> <food> meal meal Hash Browns </food> <drink> Orange Juice </drink> name food food </meal> <meal name=snack> <food> Scrambled Hash breakfast Chips Eggs Browns </food> </meal> </menu>

drink
Orange Juice

Mapping DataWindow to DOM Tree

DataWindow Data Templates

> Defines the mapping between values from a DataWindow and locations in an external document format, like XML
> References can be: > DataWindow control values (text)
Columns Computed Fields

Texts

> DataWindow Expressions (evaluated at runtime)


Columns

DataWindow Data Templates


> References are specific to a DataWindows namespace

> Persists as its child object in PBL, SRD


> Can save more than one for a DataWindow > Must be uniquely named > Template employed at runtime by name with the new UseTemplate DataWindow Property

> Used for data export and/or import

Export Template - XML View (DW Painter)

Other Items in an Export XML Template


> XML declaration

> Document Type declaration


> Root element (required) > Child elements (any level of nesting) > Attributes > Literal text

> Comments
> Processing instructions > CDATA sections

Export XML Template Divided in 2


Header Section

Optionally contains:
> XML declaration (dialog) > Document type declaration (dialog) > Comments (dialog) > Processing instructions (dialog) > Root element (required) > Child elements (non-iterative)

Export XML Template Divided in 2


Detail Section

Iterated for each row; can contain:


> Detail (row) Start element > Child or sibling elements to the Detail Start element > Content and Attribute values (dialog) > DataWindow control references (dialog or drag-drop)

> DataWindow Expressions (dialog)


> Literal text > Comments, PIs, and CDATA sections

Attributes Dialog

View Features
> Item-specific context menus, label-editing & dialogs

> Header/Detail marked by line across TreeView


> Drag-and-drop from Control List View and Column Specification View

> View-level menu


New New Default Open (dialog) Save, SaveAs (dialog)

Delete

Default Template

Contains:

> XML declaration


> Root element (defaults to DataWindow name) > Detail Start element (defaults to DW name + _row) > Child elements of the Detail Start element named for each DataWindow column with content reference

> Useful as starting point


> Same structure assumed at runtime if no UseTemplate specified on XML export or import

DataWindow Properties View

DataWindow Properties in PowerScript


Export.XML.UseTemplate

Controls logical structure of XML data exported by DW


PowerBuilder dot notation:
dw_control.Object.DataWindow.Export.XML.UseTemplate

Describe and Modify argument:


DataWindow.Export.XML.UseTemplate { = value }

DataWindow Properties in PowerScript


Export.XML.TemplateCount

Returns number of Templates saved for DataWindow


PowerBuilder dot notation:
dw_control.Object.DataWindow.Export.XML.TemplateCount

Describe argument:
DataWindow.Export.XML.TemplateCount

DataWindow Properties in PowerScript


Export.XML.Template[1..n].Name

Returns name of Template by array index (storage order)


PowerBuilder dot notation:
dw_control.Object.DataWindow.Export.XML.Template[1..n].Name

Describe argument:
DataWindow.Export.XML.Template[ + n + ].Name

Runtime Template Enumeration Example


String ls_template_count, ls_template_name Long l_template_count, i l_template_count = & Long(dw_1.Object.DataWindow.Export.XML.TemplateCount)

For i = 1 to l_template_count ls_template_name = & dw_1.Object.DataWindow.Export.XML.Template[i].Name ddlb_1.AddItem(ls_template_name) Next

DataWindow Properties in PowerScript


Export.XML.MetaDataType

Controls type of metadata to accompany exported XML


PowerBuilder dot notation:
dw_control.Object.DataWindow.Export.XML.MetaDataType

Describe and Modify argument:


DataWindow.Export.XML.MetaDataType { = value }
PowerBuilder Enumerated Value XMLNone! XMLSchema! XMLDTD! Numeric value Meaning 0 1 2 Metadata not generated XML Schema generated for XML document DTD generated for XML document

DataWindow Properties in PowerScript


Export.XML.SaveMetaData

Controls location of generated metadata


PowerBuilder dot notation:
dw_control.Object.DataWindow.Export.XML.SaveMetaData

Describe and Modify argument:


DataWindow.Export.XML.SaveMetaData { = value }
PowerBuilder Enumerated Value Numeric value Meaning MetaDataInternal! MetaDataExternal! 0 1 Metadata saved inside XML document Metadata saved in an external file (.xsd or .dtd) with reference from the XML document

Methods to Export XML


DataWindow Painter

FileSave Rows As menu item


Save as type: XML

Methods to Export XML


SaveAs method

integer dwcontrol.SaveAs ( string filename,


saveastype saveastype, boolean colheading ) SaveAsType
PowerBuilder Enumerated Value Numeric Value Meaning

XML!

15

XML

DataWindow Properties in PowerScript


Data.XML

String containing DataWindow data exported in XML


PowerBuilder dot notation:
dw_control.Object.DataWindow.Data.XML

Describe argument:
DataWindow.Data.XML

DataWindow Properties in PowerScript


Data.XMLSchema

String containing XML Schema generated from Template


PowerBuilder dot notation:
dw_control.Object.DataWindow.Data.XMLSchema

Describe argument:
DataWindow.Data.XMLSchema

DataWindow Properties in PowerScript


Data.XMLDTD

String containing DTD generated from Template


PowerBuilder dot notation:
dw_control.Object.DataWindow.Data.XMLDTD

Describe argument:
DataWindow.Data.XMLDTD

Importing XML Data into DataWindow

> Analogous to XML export

> Piggybacks off of Export XML Template to interpret the logical structure and DataWindow mapping of XML document to import > Uses SAX parser for performance
> DataWindow Import methods enhanced

DataWindow Properties in PowerScript


Import.XML.UseTemplate

Controls logical structure of XML data imported by DW


PowerBuilder dot notation:
dw_control.Object.DataWindow.Import.XML.UseTemplate

Describe and Modify argument:


DataWindow.Import.XML.UseTemplate { = value }

Methods to Import XML


long dwcontrol.ImportFile ( { saveastype importtype, }

string filename {, long startrow {, long endrow {, long startcolumn {, long endcolumn {, long dwstartcolumn }}}}} )
long dwcontrol.ImportString ( { saveastype importtype, } string string {, long startrow {, long endrow {, long startcolumn {, long endcolumn {, long dwstartcolumn }}}}} ) long dwcontrol.ImportClipboard ( { saveastype importtype {, long startrow {, long endrow {, long startcolumn {, long endcolumn {, long dwstartcolumn }}}}}} )

XSL-FO Generator

XSL Formatting Objects > Second part of XSL W3C Recommendation covering presentation of XML > Spec at http://www.w3.org/TR/xsl/slice6.html#fo-section > XSL-FO processors can render to PDF > Apache XML FOP Project

> http://xml.apache.org/fop

DataWindow Properties in PowerScript


Data.XSLFO

String containing DataWindow data & presentation in XSL Formatting Objects


PowerBuilder dot notation:
dw_control.Object.DataWindow.Data.XSLFO

Describe argument:
DataWindow.Data.XSLFO

PDF from FOP

Sybase Developer Network (SDN)


Additional Resources for Developers/DBAs
> Single point of access to developer software, services, and up-to-date technical information:
> White papers and documentation > Collaboration with other developers and Sybase engineers > Code samples and beta programs > Technical recordings

> Free software


> Join today: www.sybase.com/developer or visit SDN at TechWaves Technology Boardwalk

You might also like