External links. XSL-FO 1.1 Specification on W3C; XSL-FO 1.0 Specification on W3C; What is XSL-FO? on XML.com; FO examples and techniques - Reference site set up by Dave Pawson; XSL-FO Tutorial and Samples; XSL Formatting. This is an XML declaration. XSL FO (XSLFO) belongs to XML family, so this is obligatory. Root element. The obligatory namespace attribute declares the XSL Formatting Objects namespace. Layout master set. This element contains.
Apache™ FOP: XSL-FO Input¶ Basic Help for Using XML, XSLT, and XSL-FO. Overview¶ Apache™ FOP uses XSL-FO as input. It is the responsibility of the user to make sure that the XSL-FO submitted to FOP is correct. The. FO Designer for the Java [TM] platform. As XML is becoming a standard way for representing and exchanging information, the need to convert this information to a user friendly PDF file also increases. DeveloperWorks; Technical topics; XML; Technical library; HTML to Formatting Objects (FO) conversion guide. Use these XSLT templates to speed your conversions of HTML elements to FO and thence to PDF.
HTML to Formatting Objects (FO) conversion guide. Dec 2. 01. 2 - The author updated the article and the accompanying stylesheet to work with FOP Version 1. He changed the < fo: page- sequence> element and the implementation of the HTML < nobr> element (see the < nobr> Text with no line breaks section). The stylesheet also uses the standard < fo: bookmark- tree> , < fo: bookmark> and < fo: bookmark- title> elements to generate bookmarks in the PDF file (see Generating bookmarks under < h. Headings). See the Downloads section to get the latest version of the stylesheet.
XSL information at W3C : this page is the starting point to all the official W3C documents about XSL.
1 Introduction and Overview. This specification defines the Extensible Stylesheet Language (XSL). XSL is a language for expressing stylesheets. Given a class of arbitrarily structured XML or documents or data files, designers. Once an XML file is open, it must first be 'transformed' before it can be formatted to PDF, PostScript, AFP, SVG, XPS, XHTML or PPML output. 'Transforming' refers to the assignment of. How to Develop Stylesheets for XML to XSL-FO Transformation. The 80 page XSL-FO tutorial 2nd Edition developed by Antenna House for customers of AH Formatter is made public adding the contents of indexes, functions for PDF. In computing, the term Extensible Stylesheet Language (XSL) is used to refer to a family of languages used to transform and render XML documents. Historically, the XSL Working Group in W3C produced a draft specification under.
Jun 2. 01. 1 - The author requested two updates to the second code listing of. An unordered list section. He added an fo: block element around the content of two fo: list- item- body elements which changed A Love Supreme to < fo: block> A Love Supreme< /fo: block>. The Joshua Tree to < fo: block> The. Joshua Tree< /fo: block>.
We all design our HTML pages to look good on the screen, but printing those Web pages is usually an afterthought. To create printable versions of Web pages, the best approach is to use XSLT and XSL- FO to generate a PDF file. You can do the job with an open- source XSLT processor, the XSL Formatting Objects (XSL- FO) vocabulary, and a formatting- object engine. If you already know how to work with XSL- FO and XSLT, this guide provides a valuable resource: It goes through the most common HTML tags and defines how to convert each of them into formatting objects. If you need background on using XSL- FO, try the developer. Works tutorials on the subject, easily found through Resources.) This guide includes dozens of examples that illustrate how to write XSLT style sheets to do the conversion from HTML element to the corresponding formatting object, the basic building block of documents rendered with XSL- FO. A quick note about the XSLT templates in this guide; almost all of them contain this text: < xsl: apply- templates select="*|text()"/> This element tells the XSLT processor to get all of the text and child elements of the current element and transform them as well.
This recursive technique ensures that all of the HTML elements are processed, regardless of how they are nested within each other. For more information about XSLT and XSL- FO techniques, see Resources at the end of this guide. Context by example. For a little context for this reference material, you can view an HTML document (download x- xslfo.
You can also see the XSLT style sheet, xhtml- to- xslfo. To use the style sheet with the HTML file, use this command: > fop - xml everything.
The command tells the FOP rendering engine to transform the XHTML file everything. PDF file named everything. Here's a screen capture of the PDF file. If you like, you can view the file everything.
This generates a PDF file on letter- size paper. To generate a A4- sized PDF file, add - param page- size a. Back to top. Missing HTML elements. For a variety of reasons (most of which are reasonable), this guide doesn't cover some HTML elements. The primary reason they're left out is that they don't make sense inside a PDF file, which is the most common result of formatting- object conversion.
Some of the omitted HTML elements have been deprecated by the W3. C, which is also a good reason to leave them out. Some of the elements may make sense to you in a PDF context. Tell me what you think; if you make a good case for adding other HTML elements to this guide, I'll consider it (you can use the feedback form at the end of this guide to make suggestions). Back to top. Guide to converting HTML elements. This guide shows you how to convert most of the HTML elements into XSL formatting objects. If you're viewing this online, you can click any of the links below to go directly to the discussion of a particular element.
For each HTML element, you'll find a brief description of the element, the corresponding formatting object, and an XSLT template for converting HTML into XSL- FO. Like the HTML elements they process, some of the formatting objects and templates are very straightforward, and some are quite involved.
As always happens with example code, I've had to make some choices that are specific to the case at hand. All of the examples here assume that ultimately you'll be using the formatting objects as an intermediary to achieve a conversion to PDF. A few of the values I've chosen are arbitrary, but most of the choices I've made are guided by the layout defined for the PDF file that is the ultimate result of all this conversion. That layout is the same one I used in the two tutorials I've completed for developer. Works. Of course, in adapting the examples to your own needs, you would substitute the values that will yield the look you're aiming for; you needn't follow the look of our PDF file. Keep in mind that alphabetical order, while great for reference, is not ideal for reading straight through. For example, although most of the HTML tags for building tables do fall together under T, they're interrupted in alpha order by the title element.
Back to top< a name=".."> Named anchor points. This guide looks at transforming three different kinds of anchor elements: named anchor points, discussed in this entry, and named anchor references and anchor references, both of which are discussed in the next two entries of the alphabetical guide. The third entry includes an XSLT template sample that demonstrates the conversion of all three types of anchor elements. A named anchor looks like < a name="xyz" />. This is usually transformed to an < fo: block> element with an id. Here's the typical result: This seems simple enough, but there can be problems, depending upon the organization of your document. For example, in the tutorial's example, the style calls for rendering the HTML < h.
A page break in that position causes problems for named anchors that look like this: < a name="xslt"/>. A page break will be inserted here - ->. Using XSLT style sheets< /h. If the < h. 1> starts on a new page, creating a link to the named anchor takes the user to the end of the previous page, which is not what was intended. To handle this situation, have the processor look at the element after the named anchor in the HTML document. If the following element is an < h.
XSLT template for the < h. Here's the XSLT logic that handles a named anchor even in the case of a heading preceded by a page break. Specifying the following- sibling axis ensures that the style sheet processor checks the element that follows the named anchor. If the name of the first element after this one is not h. Notice also that the < fo: block> element sets the line- height, font- size, and space- after properties to zero; you don't want to waste any vertical space rendering the invisible anchor point. Back to top< a href="#.."> Named anchor references. To transform an anchor tag that references another destination in the same document, convert it into an < fo: basic- link> element.
For references to the same document, use the internal- destination attribute. For example, say you have an anchor element that looks like this: For more information, see < a href="#chapter. Chapter 1< /a>. You need to transform the anchor element into this XSL- FO markup: For more information, see. If an HTML anchor element has an href attribute, check to see if it begins with a hash mark (#). If it does, use the href attribute as the internal- destination of an < fo: basic- link>. To use the value, you have to remove the hash mark: Use the XSLT substring() function.
The final thing you do to handle an internal link is add an < fo: page- number- citation> to the referenced section. An XSLT template to do this conversion might look like this: < xsl: template match="a">. The previous entry covered named anchors ..
Handle external links here .. The < fo: page- number- citation> element means the rendered link looks something like this: For more information, see Chapter 1 on page 7.
Back to top< a href=".."> Anchor references. The final type of link discussed in this guide is a reference to a URI. To render these in the tutorial's example PDF file, use the external- destination attribute of < fo: basic- link>.
For example, say you have an anchor element that looks like this: < a href="http: //www. Works/">. IBM's developer. Works Web site. < /a> You would convert that element into the following markup: < fo: basic- link color="blue". Works/">. IBM's developer. Works Web site. < /fo: basic- link> Here's the complete XSLT template for all three types of anchor elements: < xsl: template match="a">.
Back to top< address> An address. This seldom- used HTML element defines an address, although the components of a typical address (phone number, e- mail address, street address, city, and so on) aren't identified inside the < address> element. The < address> element is typically used like this: < address>. Mrs. Mary Backstayge. First Avenue. Skunk Haven, MA 0. Notice that the example uses < br> elements inside the < address> to indicate line breaks. Here's the equivalent XSL- FO markup: < fo: block> Mrs.
Mary Backstayge< fo: block> < /fo: block>. First Avenue< fo: block> < /fo: block>. Skunk Haven, MA 0.
The XSLT template for < address> is very simple; you just convert the < address> element to an < fo: block> element and then process the text and any other elements inside it. Here's the template: < xsl: template match="address">. Back to top< b> Boldfaced text. Transforming a bold element is very easy; simply transform it into an < fo: inline> element with an attribute of font- weight="bold".