Extreme Java G22.3033-007
Session 3 - Sub-Topic 5 XML Information Rendering
Dr. Jean-Claude Franchitti
New York University Computer Science Department Courant Institute of Mathematical Sciences
1
Agenda
Q Extensible Stylesheet Language Transformation (XSL-T)
Q Extensible Stylesheet Language Formatting Object (XSL-FO)
Q XML and Document/Content Management
Q XML/XSL and JSP/JavaBeans Rendering Technology
Q Internationalization Issues
Q Web Content Accessibility Guidelines (WCAG)
2
1 XML-Based Rendering Development
Q XML Software Development Methodology
Q Language + Stepwise Process + Tools
Q Rational Unified Process (RUP) v.s. “XML Unified Process”
Q XML Application Development Infrastructure
Q Metadata Management (e.g., XMI)
Q XSLT, XPath XSL-FO APIs (JAXP, JAXB, JDOM, SAX, DOM)
Q XML Tools (e.g., XML Editors, Apache’s FOP, Antenna House’s XSL Formatter, HTML/CSS1/2/3, XHTML, XForms, WCAG
Q XML Applications Involved in the Rendering Phase:
Q Application(s) of XML
Q XML-based applications/services (markup language mediators)
Q MOM, POP, Other Services (e.g., persistence) 3 Q Application Infrastructure Frameworks
XML Data Rendering Patterns
Q Manipulating and Rendering XML Structures Using Java
Q XSL-T
Q Transform
Q Sort
Q Output
Q XSL-T + -FO
Q Format
Q Output
Q Querying will be covered separately
4
2 What is XSL?
Q XSL is a language for expressing stylesheets. It consists of two parts:
Q A language for transforming XML documents
Q A XML vocabulary for specifying formatting semantics
Q See http://www.w3.org/Style/XSL for the XSLT 1.0/XPath 1.0 Recs, the XSL-FO 1.0 candidate rec, and working drafts of XSLT 1.1/2.0 and XPath 2.0
Q A XSL stylesheet specifies the presentation of a class of XML documents. It describes how an instance of the class is transformed into an XML document that uses the formatting vocabulary
5
eXtensible Style Language (XSL)
Q DSSSL & DSSSL-O
Q CSS 1, 2, 3 …
Q http://www.w3.org/Style/CSS/
Q XSLT
Q XPath
Q XSL-FO
Q XSLT Processors
Q Stylus Studio XSL development environment
Q IBM XSL Editor
Q Saxon and Xalan XSLT processors
Q XSL-FO Processors
Q Antenna House 6 Q fop
3 XSL Processing
Q http://www.w3.org/Style/XSL/
Q Processing Alternatives:
Q HTML + CSS -> Presentation
Q XML + CSS -> Presentation
Q XML + XSLT -> XSL-FO -> Presentation
Q XML + XSLT -> XML/HTML + CSS -> Presentation
Q Client or Server Processing ?
Q See Session 2 handout on IE5’s implementation of the XSL Spec.
Q Examples
Q See Session 2 Sub-Topic 1 Presentation: Beginning XML
Q See Session 2 handouts on XSL Tree Transformation Language
Q See Session 2 handout on Cascading Stylesheets 7 Q See Session 2 handout on Styling Documents Using XSL
A Language for “Mapping XML” (LMX)
Q LMX is a sample textbook application
Q LMX can convert a document in one DTD into another DTD and vice versa
Q LMX uses rules to describe bi-directional “MOM” conversions between two sets of documents
Q Rules have a “from-pattern” and a “to-pattern”b to respectively match the source document, and construct the target document
Q Some restrictions exist w.r.t. the LMX patterns in order to simplify the program as much as possible
Q LMX can also be used to convert a XML document to HTML (“POP” application)
8
4 How Does the LMX Processor Work?
Q LMX makes heavy use of the DOM 1.0 API
Q LMX uses XML4J internally to:
Q Parse a rule file
Q Parse a source document
Q Generate a target document
Q See chapter 4.3 in the XML and Java textbook for a detailed description of the LMX implementation
9
LMX v.s. the eXtensible Stylesheet Language (XSL)
Q LMX and XSL both provide a syntax to encode “Style Sheets”
Q Each XML document can be associated with a style sheet that describes how elements should be organized and formatted for presentation
Q XSL style sheets provide custom appearances that give a web site a unified look and feel
10
5 How Does XSL Work?
Q A XSL style sheet is an XML document
Q XSL elements in a XSL style sheet correspond to a series of XSL “transformation” rules (i.e., XML tree transformation and/or formatting rules)
Q XSL rules describe how particular XML tags are to be converted to “flow objects” as the document is read
11
Part I
Extensible Stylesheet Language Transformation (XSLT)
12
6 XSL Transformations
Q Assume root element of style sheet is
Q Each
Q Each rule has a target and an action
Q Target is a regular expression defining to which XML elements the rule applies
Q Action is the list of flow objects generated when the rule is applied:
Q Actions output a series of HTML tags in combination with the content of the element
Q Actions may output XML tags obtained via transformation of original XML data
Q Actions may output non-markup text, or run simple scripts or programs
Q Actions may use JavaScript to provide more complex, and dynamic behaviors 13
XSL Transformations (continued)
Q Conceptual Representation of XSL Transformations:
14
7 XSL-T and Templates
Q XSLT rules are also called “Templates”
Q There may not be rules to match every element
Q Elements can be reordered on the output.
Q XSL style sheet must be well-formed
Q e.g., a HTML empty tag specified as
must be written as
within a XSL style sheet action
Q XSLT elements used as a basis for a simple stylesheet are:
Q
15
XSLT Elements and Functions
Q Creating Elements and Attributes
Q xsl:element, xsl:attribute
Q Iteration and Sorting (e.g., xsl:sort)
Q Conditional Processing
Q xsl:apply-templates select=“ … “, xsl:if, xsl:choose
Q Copying Nodes (e.g., xsl:copy)
Q Combining Stylesheets
Q xsl:import, xsl:include
Q Defining Variables & Parameters (e.g., xsl:variable)
Q Scripting with XPath functions 16
8 Parsers with XSLT Support
Q SAX 2.0 or DOM Level 2 1.0 Support Required
Q Apache’s Xalan XSLT parser
Q org.apache.xalan.processor/templates/transformer
Q org.apache.xpath
Q Saxon XSLT parser
Q JAXP 1.1 (javax.xml.transform)
Q TraXP
Q Supported by Xalan 2.0, and Saxon 6.1
Q Sun’s XSLTC
Q Converts stylesheet’s to class files (“translets”) 17
Part II
Extensible Stylesheet Language Formatting Object (XSL-FO)
18
9 XSL Formatting
Q XSL flow objects are markup text
Q Markup language output flow objects can be HTML, DSSSL, VRML, etc.
Q We will focus on HTML output flow objects (simpler, more widely understood, better supported by current tools, and do not require an extra level of translation)
19
XSL Formatting Characteristics
Q XSL formatting is simpler than DSSSL (Document Style Semantics and Specification Language, pronounced “dissal”, ISO std 10179:1996)
Q XSL formatting is more powerful than CSS (Cascading Style Sheets)
Q XSL’s basic formatting syntax is understandable by anybody acquainted with DSSSL or CSS
20
10 Part III
XML and Document/Content Management
21
What is a XSL Processor?
Q A XML document and its associated style sheet are combined by an XSL processor to produce a HTML document
Q The XSL Processor applies the style sheet to the XML document and outputs static HTML
Q The process can be automated with CGI scripts, Java servlets, or ActiveX controls to convert XML to HTML on the fly
Q A XSL processor is a standalone program or is part of a larger XML browser
22
11 How Does a XSL Processor Work?
Q The XSL processor consults the style sheet to find the rule that matches the element
Q The XSL processor takes whatever action is associated to the rule:
Q outputs element’s content plus assorted markup
Q performs more complicated operations (sorting XML data before outputting it, running a Javascript program on the XML data, adding missing content to XML data, etc.)
23
How Does a XSL Processor Work? (continued)
Q XSL processor formats each element upon receipt
Q XSL processor may process elements recursively
Q XSL processor receives input from XML processor and outputs formatted data based on the nature of the elements it receives
Q E.g., XSL processor receives element
Q XSL processor may output same content as bold text
Q If processor is an audio renderer, it may pump up the volume a notch...2
24
12 How Does a XSL Processor Work?
Q The XSL processor consults the style sheet to find the rule that matches the element
Q The XSL processor takes whatever action is associated to the rule:
Q outputs element’s content plus assorted markup
Q performs more complicated operations (sorting XML data before outputting it, running a Javascript program on the XML data, adding missing content to XML data, etc.)
25
How Does a XSL Processor Work? (continued)
Q XSL processor formats each element upon receipt
Q XSL processor may process elements recursively
Q XSL processor receives input from XML processor and outputs formatted data based on the nature of the elements it receives
Q E.g., XSL processor receives element
Q XSL processor may output same content as bold text
Q If processor is an audio renderer, it may pump up the volume a notch...
26
13 Mainstream XSL Processors
Q See Microsoft’s XML and XSL Samples and Demos at http://msdn.microsoft.com/xml
Q See IBM’s LotusXSL, Apache’s xalan, and fop. Look at Appendix E of the class textbook for relevant information on XSL
Q A comprehensive list of XSL formatters, and XSLT engines/editors/utilities is available at http//www.xmlsoftware.com
Q Includes links to latest product pages
Q Includes Version numbers, Licensing information, and Platform details 27
DOM 1.0 XSL Processing Support
Q The DOM Level 1 specification does not support XSL stylesheets
Q Microsoft’s initial version of MSXML DOM included a DOM Level 1 extension that added support for XSL stylesheets
Q The function transformNode(…) was used to apply an XSL stylesheet to an existing XML document
Q Similar extensions were emulated early on by other XSL processors (LotusXSL, xalan, fop, etc.)
Q DOM Level 2 1.0 formalizes rendering support
28
14 Mainstream XSL Processors
Q See Microsoft’s XML and XSL Samples and Demos at http://msdn.microsoft.com/xml
Q See IBM’s LotusXSL, Apache’s xalan, and fop. Look at Appendix E of the class textbook for relevant information on XSL
Q A comprehensive list of XSL formatters, and XSLT engines/editors/utilities is available at http//www.xmlsoftware.com
Q Includes links to latest product pages
Q Includes Version numbers, Licensing information, and Platform details
29
Xalan
Q Xalan-J version 2.1.0 is the latest
Q Provides XSL-T processing for transforming XML documents into HTML, text, or other XML document types
Q Built on top of SAX 2.0, DOM Level 2 1.0, JAXP 1.1
Q Implements the TraX subset of JAXP 1.1
30
15 FOP
Q Latest version is 0.19
Q xml.apache.org/fop, www.jtauber.com
Q Print formatter driven by XSL-FO objects
Q Formatted output is in PDF format for now
Q Can be embedded in a Java application by instantiating org.apache.fop.apps.Driver
31
Frameworks
Q Cocoon 2
Q Xang
Q Batik
32
16 Part IV
XML Application Services and XML Rendering Technology
33
Towards XML Application Service
Q Processing
Q DOM Extensions
Q Binding Extensions
Q Component Frameworks (reusable component models)
Q Model-Based Automation (MDA)
Q Rendering
Q DOM 2.1.0, SAX 2.0, JAXP 1.1 & TraX, XSL-FO 1.0
Q Component Frameworks
Q Querying
Q XQuery 1.0, XSLT 1.1/2.0, XPath 1.0/2.0
Q Security (signatures encryption/decryption, etc.)
34 Q Etc.
17 Rendering Software Development
Q Languages (XSL)
Q Process (“XUP”)
Q Frameworks (POP/MOM) - See XMLJ2EE
Q Cocoon 2.0
Q Xang
Q Batik
Q Etc.
Q XSL Infrastructure
Q XSL-T Processors: Saxon 6.1, Xalan-J 2.1.0
Q XSL-FO Processors: fop 0.19 35
W3C’s New “Architecture” Slant
Q New W3C UI Domain Structure
Q Document Formats
Q Amaya
Q Graphics
Q Internationalization
Q Math
Q Style
Q Interoperation
Q Device independence
Q SMIL and voice browsers
Q Architecture 36
18 Part V
XML Internationalization Issues
37
W3C Internationalization
Q Internationalization Activity Statement
Q http://www.w3.org/International/Activity.html
Q I18N and L10N features incorporated in (X)HTML, CSS, XML, RDF, SMIL, DOM, MathML, SVG, XPath, XSL(T), and XML Schema, HTTP 1.0
Q W3C’s Jigsaw, Amaya
Q Problem is to document encodings being used
Q W3C Character Model
Q Character Model for the World Wide Web
Q Normalization to Unicode Standard and ISO/IEC 10646
Q Ruby Annotation
Q Unicode in XML and other Markup Languages38
19 Part VI
Web Content Accessibility Guidelines (WCAG 1.0)
39
Current State of XML Standards
Q WCAG 1.0 (5/5/99) - W3C Recommendation
Q WCAG 2.0 (3/28/01) - W3C Working Draft
Q Support wide range of languages
Q Easier to use by authoring tools developers
Q Easier to check conformance
Q Techniques for WCAG 1.0 (3/20/00)
40
20 Guidelines Summary
Q Provide Alternatives to Auditory and Visual content
Q Avoid sole reliance on colors
Q Use markup and style sheets
Q Clarify natural language usage
Q Create tables that transform well
Q Make Sure that Pages that Feature New Technologies Transform Well
Q Ensure User Control of Time-Sensitive Content Changes 41
Guidelines Summary (continued)
Q Ensure Direct Accessibility of Embedded UIs
Q Design for Device Independence
Q Use Interim Solutions
Q Use W3C Technologies and Guidelines
Q Provide Context and Orientation Information
Q Provide Clear Navigation Mechanisms
Q Provide Clear and Simple Documents
42
21 Part VII
Conclusions
43
Summary
Q XSL style sheets describe how individual elements are displayed in HTML
Q A XSL processor like LotusXSL converts an XML document and its associated style sheet into an HTML document that can be read by current web browsers
Q Style instructions are stored in rule elements
44
22 Summary (continued)
Q Each rule has a pattern and an action
Q The pattern define the elements to which the rule applies
Q The action specifies the flow objects that the XSL processor outputs when the rule fires
Q When multiple rules apply to one element, only the most specific rule is applied
Q Flow objects usually include the content of the element, along with some combination of HTML markup
45
Summary (continued)
Q XML Application Services support a stepwise approach towards the development of XML-based system architectures
Q W3C Internationalization is moving towards normalization based on a web character model
Q I18N/L10N support needs to keep being added into XSL, and CSS3. XML Query, XML Protocols, XForms, and newer XML technologies
Q Content Accessibility Guidelines are targeted to Web and Authoring Tools developers to ensure that Web content is accessible to people with
disabilities 46
23