SDPL 20076: XSL Formatting1 6 XSL: Extensible Stylesheet Language n An advanced style language for XML documents: 1. Language for transforming XML documents:

  • Published on
    21-Jan-2016

  • View
    213

  • Download
    0

Transcript

<ul><li><p>6 XSL: Extensible Stylesheet LanguageAn advanced style language for XML documents:1. Language for transforming XML documents: XSLT2. XML vocabulary for specifying formatting: XSL 1.0, W3C Rec. 10/01; XSL 1.1 Rec. 12/06 written for implementers of XSL processors6.1 Introduction and Overview6.2 XSL Formatting by Example</p><p>6: XSL Formatting</p></li><li><p>What is it?An XSL style sheet specifies the presentation of a class of XML documentsby describing an XSLT transformation of the XML document into an XML document that uses the formatting vocabulary XSL FO: a markup language to describe formatting XSL builds on CSS2 and DSSSL DSSSL an ISO-standardised, but mainly unimplemented SGML style language</p><p>6: XSL Formatting</p></li><li><p>Example of XSL SyntaxFormatting paragraphs (as part of a complete style sheet)</p><p>6: XSL Formatting</p></li><li><p>6.1 Overview of XSL FormattingA style sheet processor accepts an XML document and an XSL style sheet, and produces a formatted presentationTwo steps:1. (XSLT) transformation: XML source tree -&gt; result tree2. (XSL FO) formattinginterprets the result tree to produce formatted presentation</p><p>6: XSL Formatting</p></li><li><p>Transformation &amp; FormattingXSLT script</p><p>6: XSL Formatting</p></li><li><p>Basis of formattingTransformation adds info to format the result treeFormatting semantics expressed using a formatting vocabulary, offormatting objects (FOs), nodes of the result treefor typographic abstractions like page-sequence, block, in-line text, page reference, XSL 1.0 defines 56 FO classes (XSL 1.1 adds 25) formatting properties control the presentation of formatting objects (indents, spacing, fonts, )248 formatting properties; many common with CSS2</p><p>6: XSL Formatting</p></li><li><p>FormattingFormatting-object tree interpreted to produce the representationEach FO specifies a part of pagination, layout and styling applied to its contentProperties control the formatting of a FOsome directly, e.g., colorsome through constraints, e.g., space-before.minimum and space-before.optimum -&gt; final rendering is not unique</p><p>6: XSL Formatting</p></li><li><p>Areas and Area TreeFormatting generates an area tree consisting of nested rectangular areasinline areas (e.g. glyph areas) within line areaslines within block areasblocks within regions of a pageRendering causes the area tree to appear on a mediumareas printed on a sequence of sheets (or displayed as a single scroll in a browser)</p><p>6: XSL Formatting</p></li><li><p>Generating the Area Tree (1/3)Formatting a gradual and complex processConceptual process of XSL formatting:(XSL FO) Element and attribute treetarget of transformation, source of formattingconsists of element, attribute, and text nodestransformed into a Formatting object tree (XSL FO Elem&amp;attr tree)consists of formatting objects with propertiesmore detailed: each character its own object</p><p>6: XSL Formatting</p></li><li><p>Generating the Area Tree (2/3)</p><p>6: XSL Formatting</p></li><li><p>Generating the Area Tree (3/3)Properties of the formatting object tree refined into traits (muotoilupiirre, piirre)e.g., by propagating inherited properties, and computing absolute values for relative propertiese.g., properties font-size="12pt", text-indent="2em" become traits font-size="12pt", text-indent="24pt"traits control generation of areas out of formatting objectssome traits only available as a result of formatting, e.g., page numbers </p><p>6: XSL Formatting</p></li><li><p>Benefits and Usage of XSLPowerful selection and manipulation ( XSLT)Extended pagination and layout capabilities area model a superset of the CSS2 box modele.g., different writing directions; footnotes, page number refs.Support of non-western writing directions&gt; distances in terms of before/after (for block-progression-direction), and start/end (for inline-progression-direction) "XSL most useful to produce tailored, paginated documents on a server, in response to individual customer requests (S. Deach, XSL 1.0 co-author, Adobe)</p><p>6: XSL Formatting</p></li><li><p>XSL Area ModelFormatting objects generate areaseach 0 or morepage breaks -&gt; additional block areasline breaks -&gt; additional line areasEach area tree node (except root) associated to a rectangular portion of the output mediumAn area has a content-rectangleportion for child areasoptionally surrounded by a border and padding</p><p>6: XSL Formatting</p></li><li><p>Content, Padding and BorderFor CSS-compatibility also margin-top, -right, -bottom and -left space-beforespace-afterstart- indentend-indentspace-startspace-endspace-start/end not supported by FOP</p><p>6: XSL Formatting</p></li><li><p>Two area typesblock-areasgenerated in block-progression-direction (before -&gt; after; normally top-to-bottom)paragraphs and titles normally rendered using fo:block, which creates block areasline-area a special case: no borders or paddinginline-areasgenerated in inline-progression-direction (start -&gt; end; normally left-to-right)characters rendered using fo:character, which generates glyph-area inline-areasno child areas, a single glyph image as content</p><p>6: XSL Formatting</p></li><li><p>Formatting objects and propertiesXSL 1.0 defines 56 formatting objects page-sequence, simple-page-master, block, inline, list-block, list-item, list-item-label, list-item-body, external-graphic, basic-link, float, footnote, table, table-row, table-column, ... and 248 properties master-reference, background-color, font-family, font-size, space-before, start-indent, end-indent, text-align, text-indent, many common with CSS2</p><p>6: XSL Formatting</p></li><li><p>Some central formatting objects 1/3fo:roottop node of the formatting object treea wrapper for all the rest fo:simple-page-mastermodel of the geometry of pagesregion-body (for page content)region-before (for header), region-after (for footer), region-start and region-end (for left and right sidebar)</p><p>6: XSL Formatting</p></li><li><p>Page RegionsA simple page can contain 1-5 regions, specified by child elements of the simple-page-master</p><p>6: XSL Formatting</p></li><li><p>Top-level formatting objectsSlightly simplified:fo:rootfo:layout-master-set(fo:simple-page-master | fo:page-sequence-master)+fo:page-sequence+fo:region- bodyfo:region- before?fo:region-end?fo:region-start?fo:region- after?fo:flow</p><p>6: XSL Formatting</p></li><li><p>Some central formatting objects 2/3fo:page-sequencespecifies the creation of page sequencespossibly different page-sequence (and page-sequence-master) for, say, each chapterfo:flowchild of a page-sequenceAttribute flow-name connects to a region with a matching region-name &gt; the contents is distributed to that region of pagesNB: There are no page-formatting objectspages created by the formatter</p><p>6: XSL Formatting</p></li><li><p>Content objects for pagesSlightly simplified:fo:static-content*Block-level object+fo:page-sequence+fo:flowBlock-level object+(repeated on every page)(distributed to pages)</p><p>6: XSL Formatting</p></li><li><p>Some block-level objectsfo:blockcommonly used for paragraphs, titles, may contain text, other blocks, orfo:inline (to change properties, e.g., font-style of inline text)fo:table for formatting tabular materialfo:list-block to format lists of fo:list-items of fo:list-item-label and fo:list-item-body</p><p>6: XSL Formatting</p></li><li><p>Hello world result tree as an XSL document</p><p> Hello World </p><p>6: XSL Formatting</p></li><li><p>Implementations?W3C XSL Rec rather recent (10/01, 12/07)What is the state of implementations?Some promising/interesting ones (2004):XEP by RenderX (XSL-FO to PS/PDF formatter), XSL Formatter by Antenna House$0 $5,000 (evaluation server versions; April 2004)Adobe Document ServerPassive TeXset of TeX macros to process XSL-FO by Sebastian RahtzApache FOP</p><p>6: XSL Formatting</p></li><li><p>Apache FOPFOP (Formatting Objects Processor) by J. Tauberfop: a man who pays too much attention to his appearancedonated to XML Apache project (http://xml.apache.org/fop/)open-source freewareJava-based XML/XSL-FO to PDF (or PS/SVG/TXT/...) processorNot complete, but implements a useful subset of XSL 1.0 </p><p>6: XSL Formatting</p></li><li><p>FOP 0.93 XSL-FO Compliancehttp://xml.apache.org/fop/compliance.html</p><p>16 of 18 core functions implemented</p><p>6: XSL Formatting</p></li><li><p>6.2 XSL-FO by ExampleFrom J. David Eisenberg: Using XSL Formatting Objects. XML.com, January 17, 2001, (acknowledging the loan of some graphics)XSL FO instance for a handbook of SpanishNB: XSL FO is not designed to be hand-authoredConsider this as a machine-generated result (of an XSLT transformation)Overall structure of fo:root: specification ofpage masters, followed bythe content of the pages</p><p>6: XSL Formatting</p></li><li><p>Example: Page dimensions and margins</p><p>plus similar simple-page-masters with master-name="rightPage" (identical)master-name="leftPage" (left and right margins switched)</p><p>6: XSL Formatting</p></li><li><p>Intended layout of pages</p><p>6: XSL Formatting</p></li><li><p>Page regionsA simple page can contain 1-5 regions, specified by child elements of the simple-page-masterLets refine the page masters with regions</p><p>6: XSL Formatting</p></li><li><p>Example: Region dimensions NB: body uses all space inside page margins -&gt; margins of region-body have to accommodate other regions! </p><p>6: XSL Formatting</p></li><li><p>Layout of Page Regions3 cm</p><p>6: XSL Formatting</p></li><li><p>Example: Page SequencesNext: masters for sequences of content pages, using the defined simple-page-mastersrepeatedly alternate masters for left and right pages: </p><p>6: XSL Formatting</p></li><li><p>Page SequencesOther attributes of conditional-page-master-reference to select the page master to be used:page-position="first" or "last", or "rest" (neither first or last), or "any"blank-or-not-blank="blank"/"not-blank"Next: Specifying the sequences of content pagesby naming masters to be used, and connecting content flows to regions</p><p>6: XSL Formatting</p></li><li><p>Example: Contents of the Cover Page Spanish Review Handbook Copyright 2001 J. David Eisenberg A Catcode Production </p><p>6: XSL Formatting</p></li><li><p>Example: Cover Page FormattedFormatting the first page-sequence gives ... </p><p>6: XSL Formatting</p></li><li><p>Example: Content PagesFinally, a page-sequence for content pageswith static-content for the header and footer, and a flow for contents of pages:</p><p> Spanish Review Handbook </p><p>6: XSL Formatting</p></li><li><p>Example: Content Pages ContinueContent for page footers: Pgina Finally, specify the content of the page body:</p><p>6: XSL Formatting</p></li><li><p>Example: Content Pages ContinueAssign a flow of blocks to region-body: Watch this space! Formatting and rendering this gives </p><p>6: XSL Formatting</p></li><li><p>Example: Content Pages Formatted</p><p>6: XSL Formatting</p></li><li><p>Using FOs in PractiseXSL FO instances should not be created manuallyInstead, use XSLT rules to create formatting objectsfo:root with layout masters for match="/"page-sequences with a flow for major parts (like chapters, or the entire document): </p><p>6: XSL Formatting</p></li><li><p>Mapping content elementscontent elements would be mapped to blocks, inlines, list-blocks, tables, as appropriateFor example, headers: </p><p>6: XSL Formatting</p></li><li><p>Examples of mapping content elementsFormatting in-line emphasis: </p><p>More in the exercises</p><p>6: XSL Formatting</p></li><li><p>SummaryIt is a standard!well, almost: a W3C Recommendationemerging implementations seem promisingcurrently used mainly for producing PDF browser support being expected XSL is a powerful (and complex) style language for XML documentsallows arbitrary transformations of input documentsallows fine-tuned specification of formatted representation</p><p>6: XSL Formatting</p></li></ul>

Recommended

View more >