11XML for Java Developers G22.3033-002Session 7 - Main ThemeXML Information Rendering (Part I)Dr. Jean-Claude FranchittiNew York UniversityComputer Science DepartmentCourant Institute of Mathematical Sciences2Agenda Summary of Previous Session Extensible Stylesheet Language Transformation (XSL-T) Extensible Stylesheet Language Formatting Object (XSL-FO) XML and Document/Content Management Introduction to XML Application Servers Working with XSLT-T and XSL-FO Processors Assignment 4a+4b (due in two week)23Summary of Previous Session Summary of Previous Session Document Object Model (DOM) Advanced XML Parser Technology JDOM: Java-Centric API for XML JAXP: Java API for XML Processing Parsers comparison Latest W3C APIs and Standards for Processing XML XML Infoset, DOM Level 3, Canonical XML XML Signatures, XBase, XInclude XML Schema Adjuncts Java-Based XML Data Processing Frameworks Assignment #34XML-Based Rendering Development XML Software Development Methodology Language + Stepwise Process + Tools Rational Unified Process (RUP) vs. “XML Unified Process” XML Application Development Infrastructure Metadata Management (e.g., XMI) XSLT, XPath XSL-FO APIs (JAXP, JAXB, JDOM, SAX, DOM) XML Tools (e.g., XML Editors, Apache’s FOP, Antenna House’s XSL Formatter, HTML/CSS1/2/3, XHTML, XForms, WCAG XML App. Components Involved in the Rendering Phase: Application(s) of XML XML-based applications/services (markup language mediators) MOM, POP, Other Services (e.g., persistence) Application Infrastructure Frameworks35Part IIntroduction to XSL 6EXtensible Stylesheet (XSL) Language Family Family of recommendations to define XML document transformation and presentation as “style sheets” Three parts: A language for transforming XML documents XSL Transformations (XSLT) Expression language used by XSLT to access or refer to parts of an XML document XML Path Language (XPath) (also used for XML Linking) A XML vocabulary for specifying formatting semantics XSL Formatting Objects (XSL-FO) See http://www.w3.org/Style/XSL for the XSLT 1.0, XPath 1.0, and XSL-FO 1.0 recommendations and working drafts of XSLT 2.0 and XPath 2.047How Does XSL Work? An XSL style sheet is an XML document XSLT elements in an XSL style sheet correspond to a series of XSL “transformation” rules (i.e., XML tree transformation and/or formatting rules) XSLT rules describe how particular XML tags are to be converted to “flow objects” as the document is read XPath (e.g., para[@type="warning"][5]) http://www.w3.org/2002/11/xquery-xpath-applets/xpathApplet.html8XSL Example XML Document<scene> <FX>General Road Building noises.</FX> <speech speaker="Prosser"> Come off it Mr Dent, you can't win you know. There's no point in lying down in the path of progress. </speech> <speech speaker="Arthur"> I've gone off the idea of progress. It's overrated </speech> </scene>59XSL Example(continued) Sample stylesheet<xsl:template match="FX"><fo:block font-weight="bold"> <xsl:apply-templates/> </fo:block> </xsl:template> <xsl:template match="speech[@speaker='Arthur']"> <fo:block background-color="blue"><xsl:value-of select="@speaker"/>: <xsl:apply-templates/> </fo:block> </xsl:template>10XML Data Rendering Patterns Manipulating and Rendering XML Structures Using Java XSLT Transform Sort Output XSLT + XSL-FO Format Output Querying will be covered separately611XSL Related Technologies DSSSL & DSSSL-O CSS 1, 2, 3 … http://www.w3.org/Style/CSS/ XSLT XPath XSL-FO XSLT Processors Stylus Studio XSL development environment IBM XSL Editor Saxon and Xalan XSLT processors XSL-FO Processors Antenna House fop12XSL Processing See http://www.w3.org/Style/XSL/ Processing Alternatives: HTML + CSS -> Presentation XML + CSS -> Presentation XML + XSLT -> XSL-FO -> Presentation XML + XSLT -> XML/HTML + CSS -> Presentation Client or Server Processing ? See Session 2 handout on IE5’s implementation of the XSL Spec. Examples See Session 2 Sub-Topic 1 Presentation: Beginning XML See Session 2 handouts on XSL Tree Transformation Language See Session 2 handout on Cascading Stylesheets See Session 2 handout on Styling Documents Using XSL713A Language for “Mapping XML” (LMX) LMX is a sample textbook application XML and Java texbook (1stedition) LMX can convert a document in one DTD into another DTD and vice versa LMX uses rules to describe bi-directional “MOM” conversions between two sets of documents Rules have a “from-pattern” and a “to-pattern”b to respectively match the source document, and construct the target document Some restrictions exist w.r.t. the LMX patterns in order to simplify the program as much as possible LMX can also be used to convert a XML document to HTML (“POP” application)14How Does the LMX Processor Work? LMX makes heavy use of the DOM 1.0 API LMX uses XML4J internally to: Parse a rule file Parse a source document Generate a target document See chapter 4.3 in the XML and Java textbook (1stEdition) for a detailed description of the LMX implementation815LMX v.s. the eXtensible Stylesheet Language (XSL) LMX and XSL both provide a syntax to encode “Style Sheets” Each XML document can be associated with a style sheet that describes how elements should be organized and formatted for presentation XSL style sheets provide custom appearances that give a web site a unified look and feel16Part IIExtensible Stylesheet Language Transformation(XSLT)917XSLThttp://www.dpawson.co.uk/xsl/sect1/sect1.html An XSLT stylesheet specifies the presentation of a class of XML documents Describes how an instance of the class is transformed into an XML document that uses a formatting vocabulary (e.g., XHTML, XSL-FO) XSLT Terminology See http://www.dpawson.co.uk/xsl/xslvocab.html Ref. card: http://www.mulberrytech.com/quickref/ “@”: abbreviation for attribute “..”: abbreviation for parent::node() “*”: identifies all of the element children of the context node (@* means all attributes) “.”: abbreviation for self::node()18XSL Transformations Assume root element of style sheet is <xsl> Each <xsl> element contains one or more rule elements Each rule has a target and an action Target is a regular
View Full Document