1 / 35

E 174 DataWindows, XML & XSL-FO in PowerBuilder 9.0

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

ouida
Download Presentation

E 174 DataWindows, XML & XSL-FO in PowerBuilder 9.0

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. E 174 DataWindows, XML & XSL-FOin PowerBuilder 9.0 • Angelo Scipione • Staff S/W Engineer • Sybase, Enterprise Solutions Div. • Scipione@sybase.com

  2. 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

  3. 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

  4. 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

  5. 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

  6. XML Modeled by DOM Tree <?xml version=“1.0” encoding=“UTF-8”?> <!DOCTYPE menu SYSTEM menu.dtd> <menu> <meal name=“breakfast”> <food> Scrambled Eggs </food> <food> Hash Browns </food> <drink> Orange Juice </drink> </meal> <meal name=“snack”> <food> Chips </food> </meal> </menu> menu meal meal name food food drink “breakfast” “Scrambled Eggs” “Hash Browns” “Orange Juice”

  7. Mapping DataWindow to DOM Tree

  8. 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

  9. DataWindow Data Templates • References are specific to a DataWindow’s 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

  10. Export Template - XML View (DW Painter)

  11. 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

  12. 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)

  13. 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

  14. Attributes Dialog

  15. 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

  16. 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

  17. DataWindow Properties View

  18. 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’ }”

  19. 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”

  20. 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”

  21. 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

  22. 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’ }”

  23. 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’ }”

  24. Methods to Export XML DataWindow Painter File…Save Rows As… menu item Save as type: XML

  25. Methods to Export XML SaveAs method integer dwcontrol.SaveAs ( string filename, saveastype saveastype, boolean colheading ) SaveAsType

  26. 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”

  27. 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”

  28. 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”

  29. 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

  30. 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’ }”

  31. 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 }}}}}} )

  32. 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

  33. 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”

  34. PDF from FOP

  35. 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 TechWave’s Technology Boardwalk

More Related