
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 <xsl> Q Each <xsl> element contains one or more rule elements 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: <xsl> <rule> <target-element type=“tagname”/> action </rule> <rule> (…) </rule> </xsl> 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 <br> must be written as <br/> within a XSL style sheet action Q XSLT elements used as a basis for a simple stylesheet are: Q <xsl:stylesheet>, <xsl:template match …>, <xsl:apply- templates>, <xsl:for-each select ...>, and <xsl:sort select …> 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 <strong> 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 <strong> 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.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages23 Page
-
File Size-