Last updated: Jan 21, 2008

Stylesheet Tutorial, Sample Files of
Formatting Objects and
Sample Stylesheets

How to Develop Stylesheets for XML to XSL-FO Transformation

The 80 page tutorial 2nd Edition developed by Antenna House for customers of XSL Formatter is made public adding the contents of indexes, functions for PDF creation, reference to appendix and much more substantial contents. This is not only useful for better understanding of XSL and XSLT but also this may be used as a practical sample of XML and XSLT stylesheet.

  1. This is the source file of the tutorial.
  2. The source file is an XML document based on "SimpleDoc.dtd".
  3. This is the XSLT Stylesheet to transform the source XML file to XSL (XSL-FO) formatting objects tree.
  4. You may download source files from here: ZIP file (about 270KB), revised July 26, 2005. Then you can format xml/Howtodevelop-en-2.xml and SimpleDoc/SD2FO-DOC.xsl using XSL Formatter by yourself.
  5. The PDF format is available. PDF file (about 648KB), revised July 26, 2005.

XSL Formatter Online Manual written in XSL-FO

These manuals contain operating instructions that explain how to use XSL Formatter and provides helpful information for first-time, as well as experienced, users. This is not only useful as a manual but also this may be used as a practical sample of XSL-FO document.

  1. XSL Formatter V4.2 Online Manual in FO format as a zip file (about 944KB), revised Jan 11, 2008. You can format and print using XSL Formatter by yourself.
  2. XSL Formatter V4.2 Online Manual in PDF format (about 3.3MB), revised Jan 11, 2008.

XSL Formatter V4.2 Online Manual is created using the specification of Extensible Stylesheet Language (XSL) Version 1.1.

Sample File of Formatting Objects (XSL- FO 1.1)

The following sample files show the new features in the Extensible Stylesheet Language (XSL) Version 1.1 W3C Candidate Recommendation. They are all available for formatting and printing by our XSL Formatter V4.2.

Download all sample FO files as one lump package, revised September 4, 2007.

Sample File of Formatting Objects (XSL- FO 1.0)

The following sample files show the typical functions of XSL (XSL-FO). They are all available for formatting and printing by our XSL Formatter. PDF files created by XSL Formatter are also available here. Though Acrobat Distiller is used in exceptional cases, it is identified in the explanation.

Download all sample FO files as one lump package, revised November 29, 2005.

Formatting World Languages by XSL Formatter

XSL Formatter can format world languages that are written using Unicode. Beside of western languages, major Asian languages such as Japanese, Simplified Chinese, Traditional Chinese, Korean and Thai are supported. Those languages which are written from right to left, such as Arabic, Hebrew, are also supported.

Unicode BIDI algorithm and bidi-override function of XSL (XSL-FO) specification is supported, document that consists of mixed writing mode phrases in a paragraph can be formatted right.

The formatted result of XSL Formatter can be converted to PDF by using both of Abobe Distiller and PDF Output engine. XSL Formatter supplies you the global multilingual formatting solution.

☞ See the tutorial "Formatting World Languages" and multilingual formatting examples.

Stylesheet for DITA to XSL-FO transformation

DITA (Darwin Information Typing Architecture) is an XML-based architecture for authoring, producing, and delivering technical information. The architecture and a related DTD was developed by IBM. DITA is organized around the principle of the topic as the highest level structure and is intended to support the reusability of content. It has been developed especially for managing a large set of documentation to be distributed in multiple channels.

DITA has grown well and its specification was defined by the OASIS DITA Technical Committee since 2004. DITA version 1.0 has been approved as an OASIS Standard on May 3rd, 2005.

Visit OASIS Darwin Information Typing Architecture (DITA) TC for more information.

Features of DITA

  • The topic as an organizing principle.
  • Reuse of whole topics, as well as reuse of partial topics through the use of content references.
  • Specialization of elements to provide.
  • Property-based processing that makes topics easier to find.
  • Making use of existing tagsets and tools.

Antenna House DITAtoFO Stylesheet

Antenna House provides a stylesheet that transforms DITA into XSL-FO so that you can format and print through the DITA Open Toolkit using XSL Formatter.

The DITA Open Toolkit is an implementation of the OASIS DITA Technical Committee's specification for Darwin Information Typing Architecture (DITA) DTDs and Schemas. The Toolkit transforms DITA content (maps and topics) into deliverable formats.

  • Download a stylesheet for the DITA Open Toolkit 1.4 ZIP file (about 31KB), released October 19, 2007. The specification of stylesheet conversion and how to use are also included in the ZIP file.

I18N Support Library

The Internationalization (I18N) Support Java library is the LGPL open-source license developed by Innodata Isogen, Inc. Antenna House made some modifications to the original library and opened this library under the LGPL license according to the LGPL rule.

Download I18N Support Library (about 5,694 KB).

The Innodata Isogen Internationalization (I18N) Support Library is a collection of Java classes that provide fundamental services to document processors for localizing and internationalizing the rendered form of XML documents.

The services provided include:

The core functions (I18nService) are processor independent and can be bound to any specific processor through a relatively thin binding layer, as demonstrated by the provided Saxoni18nService class. For example, the I18nService can be bound to Epic Editor through it's Java API, other Java-based XSLT processors, or Java-based user interfaces, or DOM-based XML processors.

Stylesheet for XHTML to XSL-FO transformation

One method to generate PDF dynamic from your web page is to generate XHTML page, then transforms the XHTML to XSL-FO by using XHTML to XSL-FO stylesheet, and XSL-FO to PDF by using XSL-FO processor.

Stylesheets for XHTML

Followings are the list of stylesheets for XHTML document to XSL-FO transformation includes in the download file.

xhtml2fo.xsl
Default XHTML stylesheet. The other styleheets are made by importing this stylesheet and changing their styles.
xhtml2fo-justified.xsl
Default setting is text-align="justify". In addition, the space between blocks has a range from minimum to maximum and makes the text in the bottom justified after page breaks and column brakes.
xhtml2fo-multicolumn.xsl
An example of a layout in two columns. h1 and h2 become the headline spanning all columns.
Chocolate.xsl, Midnight.xsl, Modernist.xsl, Oldstyle.xsl, Steely.xsl, Swiss.xsl, Traditional.xsl, Ultramarine.xsl
XSL-FO version of the following CSS stylesheet:
W3C Core Styles <http: /www.w3.org/StyleSheets/Core>
Traditional-ja.xsl
It's made by transforming Traditional in W3C Core Styles into Japanese tb-rl writing mode.
W3C-REC.xsl
This is an XSL-FO version of W3C-REC.css (W3C Recommendation stylesheet).

Download all stylesheet files.

Sample XHTML files

Sampler.html
Some samples of table and list are added to original Sampler.html.
ruby-test.html
Sample of ruby. Mixture of writing mode in vertical and horizontal. Horizontal in vertical test. (Ruby is a part of XHTML1.1 Recommendation. It is supported with xhtml2fo.xsl.)
style-test.html
Example of specifying CSS-based styles to the element of XHTML using the style attribute. Specifying the writing mode 'rl-tb' and 'lr-tb', table style and absolute position.

Download all sample xhtml files.

Parameters

Various styles can be customized by changing the following parameters and the settings using the attribute-set.

<!-- page size -->

<xsl:param name="page-width">auto</xsl:param>
<xsl:param name="page-height">auto</xsl:param>
<xsl:param name="page-margin-top">1in</xsl:param>
<xsl:param name="page-margin-bottom">1in</xsl:param>
<xsl:param name="page-margin-left">1in</xsl:param>
<xsl:param name="page-margin-right">1in</xsl:param>

Example of specifying the size and the margin of the page. When page-width and page-height is aut-setting, it follows the setting of XSL Formatter.

<!-- page header and footer -->

<xsl:param name="page-header-margin">0.5in</xsl:param>
<xsl:param name="page-footer-margin">0.5in</xsl:param>
<xsl:param name="title-print-in-header">true</xsl:param>
<xsl:param name="page-number-print-in-footer">true</xsl:param>

Example of specifying the margin of page header, the margin of page footer, whether to place the contents of XHTML title to the page header, and whether to place page numbers to page footer.

The value of true/false is set as strings, not as Boolean type supposing that you may specify it from UI.

<!-- multi column -->

<xsl:param name="column-count">1</xsl:param>
<xsl:param name="column-gap">12pt</xsl:param>

Example of setting columns. Specify the column number and the space between columns.

<!-- writing-mode: lr-tb | rl-tb | tb-rl -->

<xsl:param name="writing-mode">lr-tb</xsl:param>

Example of setting writing-mode. When the writing mode 'vertical (tb-rl)' is specified, the text in the body is written in vertical mode, the text in the page header is written in horizontal mode and placed at the top of the page (region-start), the text in the page footer is written in horizontal mode and placed at the bottom of the page (region-end).

<!-- text-align: justify | start -->

<xsl:param name="text-align">start</xsl:param>

Example of specifying the default text-align setting. When 'justify' is specified, the end of the line is justified.

<!-- hyphenate: true | false -->

<xsl:param name="hyphenate">false</xsl:param>

Example of specifying whether to hyphenate or not.

Main functions

  • Transforming the width, height and border attributes of the XHTML elements into XSL-FO properties. It support the attributes defined in HTML4(xhtml1) strict.dtd.
  • Interpret CSS-based style attributes specified to XHTML elements and transform them into XSL-FO properties.
  • Generating fo:block-container or fo:inline-container if necessary when writing-mode, width, height and absolute position are specified to the style attributes of div/span elements. Sample xhtml files:
    • style-test.html
    • ruby-test.html
  • Supports ruby. It is possible to write rubies on both alongside of the line. Sample xhtml files:
    • ruby-test.html
  • Deletes the line-feed placing right after the pre tag. Otherwise, line-feed characters are retained and unnecessary white space is created according to the XSL-FO Specification.

XHTML, written in XML, is a reformulated version of HTML. For details please refer to W3C HTML Home Page.

If you wish to convert HTML to XHTML, HTML Tidy is a very strong and useful tool for the purpose.

Stylesheet for XBRL to XSL-FO transformation and sample XBRL file

XBRL (eXtensible Business Reporting Language) is a specification for describing XML-based business documents and it aims to exchange the data of financial statements and accounts.

APRA (Australian Prudential Regulation Authority) integrated XBRL into their management business. Also, JFMIP (The Joint Financial Management Improvement Program) recommends for all the Federal Government Agencies of the US to use XBRL.

Visit XBRL Japan or XBRL USA for more information.

We provide a stylesheet that transforms XBRL for a statement of account to FO here.

A balance sheet and a statement of profits and losses are created by downloading the above 2 files and formatting with XSL Formatter.


Copyright © 1996-2008 Antenna House, Inc. All rights reserved.
Antenna House is a trademark of Antenna House, Inc.