Guidelines for using XSL object formats (i)

Source: Internet
Author: User
Tags format object manual end italic font range xsl xslt
Object


The World Wide Web Consortium's canonical book plans an extensible Style language (XSL) into two parts:

XSLT is used to transform XML files
An XML function library in which the XSL Object Format (XSL FO) is used to describe the format statement in detail.
XSLT is very easy to learn and use. It takes only a little time for developers to convert XML documents into HTML documents that they can see in their own browsers. This is why developers like to use XSLT.
The XSL object format is an XML based extension function library that defines page content information such as pages, layouts, and fonts in detail. The XSL-fo extension language is very complex and verbose, but it is only through XSL fo that the XSLT can be quickly converted to a document source file.
In addition to fully introducing XSL FO, this article will provide enough information and examples to illustrate how to use XSL fo. We will learn to make a Spanish comment manual and print it out through XSL fo. We will use the Apache Software Foundation FOP tool software to convert the fo file into a PDF file.

Class
To convert an XSL FO file into an XML document, you need basic XML processing instructions and the FO root element first:
<?xml version= "1.0" encoding= "Utf-8"?>
<fo:root>
The structure of the document is:
The main layout design consists of the following
0 various pages that may appear in a document
0 format sequence of these pages
Pages and their content
Page planning
After the start <fo:root> label of the FO document, we must describe the type of page the document has. The document has three different pages in the chart below. Categorize as cover pages, left and right pages by blank area. Cover and left pages have more white space on the left. Each page has a header and footer.

Let's start by locating the page length, width, and blank space. In the article units are used in centimeters, you can also use any CSS units, elephant (pixel), millimeters, inches and so on. These specifications are named Simple-page-master and are specified with the Master-name statement. Take a look at the code example. Note that blank areas of the page cannot have any content that needs to be printed.

Content Area
There are sporadic lines in all print charts. That is the content area of the page (officially referred to as the page reference area), where you can see that the content area is divided into five areas.


Description
We must first understand some terms. When we set the margins of the page, we use words such as top, bottom, left, and right. Because everyone thinks that the edge of the paper is the left, top, bottom, and right side of the paper. When we talk about the content area, we use different words, because not all languages can describe the left to right or the top of the bottom.
FO thinks a page is made up of two elements: block elements (for example, a paragraph in an article) it starts with a new line. Inline elements (for example, bold and italic font). Fo's block-progress-direction determines the position of the paragraph on the page. Before-edge indicates that before the paragraph, After-edge is indicated after the paragraph.
Inline-progress-direction determines the position of each character in a line of words. Start-edge indicates that the position precedes the line, and the End-edge indicates that the position is after one line of words.
For Hebrew, it looks like this: the position of the text in the beginning and the end corresponds to the English habit. (The Arabic language is similar to the wording)

Japanese writing is sometimes written as follows, and the following is a picture in the XSL Specification manual:

The biggest advantage of this new function library is that it uses a language that is not constrained. If you want the title of the page to appear in the position corresponding to the normal text, you can set the text-align= "End" as follows
An interesting title

The headline is generally at the top, so that the reader's attention can be drawn

If the document is eventually translated into Arabic or Japanese, you can still determine that the title still appears in the corresponding position in the text. There is no need to adjust the document's left and right and up and down.

Specify the size of the range
Cover pages do not require headers and footers, so we only need to specify region-body information in bold as shown below.
<fo:simple-page-master master-name= "Cover"

page-height= "12cm"
Page-width= "12cm"
margin-top= "0.5cm"
Margin-bottom= "0.5cm"
margin-left= "1cm"
margin-right= "0.5cm" >
<fo:region-body
margin-top= "3cm"/>

</fo:simple-page-master>

The left and right pages have headers and footers, so we need to specify the range of Region-before and Region-after.
Important: You have to specify a range for Region-body, which is equivalent to specifying the range of Region-before and Region-after (FOP does not now support Region-start and Region-end). If you do this as follows:
<fo:region-before extent= "1cm"/>
<fo:region-after extent= "1cm"/>

<fo:region-body
margin-top= "0.20cm"
margin-bottom= "0.20cm"/>



The result will be:



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.