XML Technology in ECommerce - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

XML Technology in ECommerce

Description:

... a document suitable for presentation on a device like display, aural device, etc; ... for specifying formatting suitable for print media and aural devices ; ... – PowerPoint PPT presentation

Number of Views:63
Avg rating:3.0/5.0
Slides: 26
Provided by: kur50
Category:

less

Transcript and Presenter's Notes

Title: XML Technology in ECommerce


1
XML Technology in E-Commerce
Lecture 7 XSL Formatting Objects, Java Data
Binding
2
Lecture Outline
  • 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

3
Overview
Software Application
Data Binding Facility
DOM
SAX
Parser
XML Languages
XLink
XPointer
XSLT
XSL FO
XPath
XML Schema
XML Namespaces
XML
4
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

CSS Stylesheet
Browser
FO Document
PDF
XML Document
Transformation (XSLT)
HTML
WML
5
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
DemoConverting 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
Page Model
Region-before
  • Simplified page and its regions used in
    structures that contain formatting objects

Region-body
Region-start
Region-end
Region-after
Page
8
Setting Up Page Templates
  • ltforoot xmlnsfo "http//www.w3.org/1999/XSL/Fo
    rmat"gt
  • ltfolayout-master-setgt
  • ltfosimple-page-master master-name
    "layout1"
  • page-height "4in"gt
  • .
  • lt/forootgt
  • 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
Setting Up Page Regions
ltfosimple-page-master master-name "layout1"
page-height "4in"gt
ltforegion-body margin-top "1in"
margin-bottom "1in" margin-left "1.5in"
margin-right "1.5in"/gt
ltforegion-before extent "1in" margin-top
"0.2in" margin-bottom "0.2in"
margin-left "0.2in" margin-right
"0.2in"/gt lt/fosimple-page-mastergt
10
Describing the Page Content
ltfopage-sequence master-name "run"gt
ltfostatic-content flow-name "xsl-region-before"
gt ltfoblock font-size "10pt"
line-height "12pt" font-family
"sans-serif"gt page
ltfopage-number/gt lt/foblockgt
lt/fostatic-contentgt . static-cont
ent element causes page numbers to be included in
each page header
11
Creating Paragraphs and Inline elements
ltfoflow flow-name "xsl-region-body"gt
ltfoblock font-size "36pt" font-family
"sans-serif" font-weight "bold"
space-after.optimum "24pt" color "blue"
text-align "center"gtWelcome!
lt/foblockgt .. ltfoblock
font-size "12pt" font-family
"sans-serif" line-height "14pt"
space-after.optimum "12pt"gtDeitel amp
Associates, Inc. is a member of the
ltfoinline-sequence font-weight
"bold"gtWorld Wide Weblt/foinline-sequ
encegt Consortium. lt/foblockgt
block elements create paragraphs
inline element defines different formatting for a
portion of text in a paragraph
12
DemoXSLT 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
Summary on Formatting Objects
  • 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

Read Deitel 13 Assignment Deitel Ex 13.3
14
Lecture Outline
  • 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

15
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

General Schema for XML Processing
Software Application
DOM
SAX
XML Parser
XML Document
16
Data Access
  • Example (simple address)
  • ltaddressgt
  • ltstreetgtBaker Street 221blt/streetgt
  • ltcitygtLondonlt/citygt
  • lt/addressgt
  • Having the address element, obtaining the street
    through DOM is
  • Node straddress.getFirstChild()
  • String streetstr.getFirstChild().getNodeValue()
  • But if we have the XML converted to an
    application object address, the previous could
    be
  • String streetaddress.getStreet()

17
The Idea behind the Data Binding
  • The application logic doesnt 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

Software Application
Application Objects
Mapping Rules
Interpreter
DOM
SAX
XML Parser
XML Document
18
Data Binding
Compile
Schema (DTD or XML Schema)
Classes
Instance of
Conforms to
Unmarshal
XML Document
Objects
Marshal
Functionality of Data Binding Facility
19
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
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
Class Descriptors
  • Mapping information is represented from the Java
    objects 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
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
Jato Transformations
Jato Script
XML Doc
Objects
Jato Script
XML Helper
Jato Interpreter
XML Generator
Object Helper
XML
XML to Java
Java to XML
24
XML to Java Example
ltsystem-propertiesgt ltproperty
name"awt.toolkit" value"sun.awt.windows.WToolkit
" /gt lt/system-propertiesgt We want to create an
object instance of java.util.Properties
class ltJatojava-defs xmlnsJato'http//www.krum
el.com/jato' gt ltJatoimportgtjava.util.lt/Jatoim
portgt ltJatotranslate elt'system-properti
es'gt ltJatoobject class'Properties'
publish'propsgt ltJatoon-elt
name'property' action'Jatoinvoke
method'setProperty'gt
ltJatoparam type'string' path'_at_name'/gt
ltJatoparam type'string'
path'_at_value'/gt lt/Jatoon-eltgt
lt/Jatoobjectgt lt/Jatotranslategt lt/Ja
tojava-defsgt
25
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
Write a Comment
User Comments (0)
About PowerShow.com