Presentation is loading. Please wait.

Presentation is loading. Please wait.

Sheet 1XML Technology in E-Commerce 2001Lecture 7 XML Technology in E-Commerce Lecture 7 XSL Formatting Objects, Java Data Binding.

Similar presentations


Presentation on theme: "Sheet 1XML Technology in E-Commerce 2001Lecture 7 XML Technology in E-Commerce Lecture 7 XSL Formatting Objects, Java Data Binding."— Presentation transcript:

1 Sheet 1XML Technology in E-Commerce 2001Lecture 7 XML Technology in E-Commerce Lecture 7 XSL Formatting Objects, Java Data Binding

2 Sheet 2XML Technology in E-Commerce 2001Lecture 7 XSL Formatting Objects –Formatting Objects as a part of XSL suite; –Page Model; –Creating Templates; –Creating Blocks and Inline elements; Java Data Binding –Purpose of Data Binding: translation of XML documents to application objects; –Examples: Castor; Jato; Lecture Outline

3 Sheet 3XML Technology in E-Commerce 2001Lecture 7 XML XML Namespaces XPath XPointerXSLT XLink XML Schema XML Languages Parser DOMSAX Software Application Overview XSL FO Data Binding Facility

4 Sheet 4XML Technology in E-Commerce 2001Lecture 7 Rendering XML Transformation to a document suitable for presentation on a device like display, aural device, etc; The result tree has a formatting semantics expressed in terms of formatting objects; XML Document CSS Stylesheet Browser Transformation (XSLT) FO Document HTML WML PDF

5 Sheet 5XML Technology in E-Commerce 2001Lecture 7 Formatting Objects After an XSLT transformation the result tree can contain nodes that are formatting objects; Formatting objects correspond to typographic abstractions like page, paragraph, table; Finer control on the presentation is provided through the properties of the formatting objects; XSL FO provides XML vocabulary to specify the presentation in terms of formatting objects and properties;

6 Sheet 6XML Technology in E-Commerce 2001Lecture 7 Demo Converting FO Tree to PDF Demo - Deitel 13.3, fig. 13.2, page 356; Tools: –Java 2; –Apache FOP tool ( http://xml.apache.org/fop/) ; Demo files: –welcome.fo; –welcome.pdf;

7 Sheet 7XML Technology in E-Commerce 2001Lecture 7 Region-before Region-after Region-start Region-end Region-body Page Model Simplified page and its regions used in structures that contain formatting objects Page

8 Sheet 8XML Technology in E-Commerce 2001Lecture 7 Setting Up Page Templates <fo:simple-page-master master-name = "layout1" page-height = "4in"> ……………………………………………………. layout-master-set : defines page templates that can be used for page generation; simple-page-master : used for the generation of pages. The pages come from the page-sequence element;

9 Sheet 9XML Technology in E-Commerce 2001Lecture 7 Setting Up Page Regions <fo:simple-page-master master-name = "layout1" page-height = "4in"> <fo:region-body margin-top = "1in" margin-bottom = "1in" margin-left = "1.5in" margin-right = "1.5in"/> <fo:region-before extent = "1in" margin-top = "0.2in" margin-bottom = "0.2in" margin-left = "0.2in" margin-right = "0.2in"/>

10 Sheet 10XML Technology in E-Commerce 2001Lecture 7 Describing the Page Content <fo:block font-size = "10pt" line-height = "12pt" font-family = "sans-serif"> page ………………………………………. static-content element causes page numbers to be included in each page header;

11 Sheet 11XML Technology in E-Commerce 2001Lecture 7 Creating Paragraphs and Inline elements <fo:block font-size = "36pt" font-family = "sans-serif" font-weight = "bold" space-after.optimum = "24pt" color = "blue" text-align = "center">Welcome! …………………………………………………….. <fo:block font-size = "12pt" font-family = "sans-serif" line-height = "14pt" space-after.optimum = "12pt">Deitel & Associates, Inc. is a member of the World Wide Web Consortium. block elements create paragraphs inline element defines different formatting for a portion of text in a paragraph

12 Sheet 12XML Technology in E-Commerce 2001Lecture 7 Demo XSLT Transformation to FO Document Demo - Deitel 13.3, fig. 13.5, page 361; Tools: –Java 2; –XML Spy with XSLT processor; –Apache FOP tool ( http://xml.apache.org/fop/) ; Demo files: –letter.xml; –letter.xsl;

13 Sheet 13XML Technology in E-Commerce 2001Lecture 7 Summary on Formatting Objects Read: Deitel 13 Assignment: Deitel Ex 13.3 Part of XSL Suite; XML application that provides vocabulary for specifying formatting suitable for print media and aural devices ; Apache FOP tool allows easy generation of PDF files from XML documents;

14 Sheet 14XML Technology in E-Commerce 2001Lecture 7 XSL Formatting Objects –Formatting Objects as a part of XSL suite; –Page Model; –Creating Templates; –Creating Blocks and Inline elements; Java Data Binding –Purpose of Data Binding: translation of XML documents to application objects; –Examples: Castor; Jato; Lecture Outline

15 Sheet 15XML Technology in E-Commerce 2001Lecture 7 XML Processing XML Parser DOMSAX Software Application XML Document General Schema for XML Processing: Software application recognizes the markups in the XML doc; The application is bound to a low-level APIs (SAX, DOM); Dependence on the document format. Navigation through the document structure is rigidly encoded in the application;

16 Sheet 16XML Technology in E-Commerce 2001Lecture 7 Data Access Example (simple address): Baker Street 221b London Having the address element, obtaining the street through DOM is: Node str=address.getFirstChild(); String street=str.getFirstChild().getNodeValue(); But if we have the XML converted to an application object address, the previous could be: String street=address.getStreet();

17 Sheet 17XML Technology in E-Commerce 2001Lecture 7 The Idea behind the Data Binding XML Parser DOMSAX Software Application XML Document Interpreter Mapping Rules Application Objects The application logic doesn’t contain code for XML data access; Conversion from XML to application objects is done by an Interpreter on the base of Mapping Rules. This process is called unmarshalling; The process of serialization of a set of objects to XML document is called marshalling;

18 Sheet 18XML Technology in E-Commerce 2001Lecture 7 Data Binding Schema (DTD or XML Schema) XML Document Classes Objects Compile Unmarshal Marshal Instance of Conforms to Functionality of Data Binding Facility

19 Sheet 19XML Technology in E-Commerce 2001Lecture 7 Data Binding Every data binding implementation has to provide answer to two questions: –How to convert a schema to a hierarchy of classes; –What are the rules for mapping from and to XML and how they are represented; Two data binding implementations: –Castor (http://castor.exolab.org/); –Jato (www.krumel.com/jato);

20 Sheet 20XML Technology in E-Commerce 2001Lecture 7 Castor Java-based data binding framework that supports marshalling and unmarshalling; Generates source of the classes on the base of XML Schema; Can use already existing application classes; Uses class and field descriptors to represent the mapping information; Based on Java Beans component model;

21 Sheet 21XML Technology in E-Commerce 2001Lecture 7 Class Descriptors Mapping information is represented from the Java object’s point of view; Description is made on the base of Java Beans name conventions; Description takes the form of an XML document; Descriptors specify the mapping of classes and fields to XML elements and attributes; Example files for a simple order - order.xml, MyOrder.java, Item.java, mapping.xml;

22 Sheet 22XML Technology in E-Commerce 2001Lecture 7 Jato Library for transforming XML to Java and Java to XML; JavaBeans naming convention support; The correspondence between XML elements and attributes and Java objects is specified in Jato transformation XML document; Transformation document is written in Jato script;

23 Sheet 23XML Technology in E-Commerce 2001Lecture 7 Jato Transformations Jato ScriptXML Doc Jato Interpreter Object Helper Jato ScriptXML Helper XML Generator XML Objects XML to JavaJava to XML

24 Sheet 24XML Technology in E-Commerce 2001Lecture 7 XML to Java Example We want to create an object instance of java.util.Properties class: java.util.*

25 Sheet 25XML Technology in E-Commerce 2001Lecture 7 Summary on Data Binding Frameworks for translating XML to a set of application objects and objects to XML document; Usually uses Java language and JavaBeans naming conventions; Correspondence between XML and objects is specified in a separate descriptor document by using declarative syntax; Generation of classes on the base of DTD/XML Schema;


Download ppt "Sheet 1XML Technology in E-Commerce 2001Lecture 7 XML Technology in E-Commerce Lecture 7 XSL Formatting Objects, Java Data Binding."

Similar presentations


Ads by Google