The XSL-FO Formatting Properties

The XSL-FO Formatting Properties

You use the XSL-FO formatting properties to customize the actions of the formatting objects that were listed in the preceding section, and you use formatting properties as element attributes in XSL-FO documents. For example, heres how I use formatting properties to set the font family, font size , and font weight of text in a block:

 <fo:block color="blue" font-family="Times"      font-size="36pt" font-weight="bold">      Hello from XSL-FO!  </fo:block> 

You can find the complete list of XSL-FO properties and their descriptions at www.w3.org/TR/xsl/slice7.html. Many of the XSL-FO properties are inherited from the specification for cascading stylesheets, version 2, CSS2, which you can find at www.w3.org/TR/REC-CSS2.

The following list includes some of the more common XSL-FO properties. Youll find the complete list of properties (and its a long one) in Appendix B. Heres the syntax used in this list, following the XSL-FO specification:

  • <> indicates units for values (see Table 11.1), or properties (such as <color>) that have already been defined.

  • indicates alternatives, only one of which may be used.

  • indicates options, one or more of which must be used, in any order.

  • [] indicates group statements, evaluated much like mathematical statements.

  • * means the preceding term occurs zero or more times.

  • + means the preceding term occurs one or more times.

  • ? means the preceding term is optional.

  • {} surrounds pairs of numbers giving the minimum and maximum number of times a term may occur (as in {1, 4}).

Many of the XSL-FO properties indicate a specific format for values that you may assign to them, such as <color> or <angle> , and youll find those formats and their meanings in Table 11.1.

Table11.1. Formats in the XSL-FO Specification

Format

Means

<absolute-size>

Absolute font sizes; may be xx-small, x-small, small, medium, large, x-large, xx-large.

<angle>

Angles; may be deg, grad, or rad.

< border-style >

A boxs border; may be none, dotted , dashed, solid, double, groove, ridge, inset, or outset.

< border-width >

Sets the width of a border; may be thin, medium, thick, or an explicit length.

<color>

Color; may be specified with a predefined color value or RGB triplet color value as youd use in HTML, such as FFFFFF for white.

<country-language>

Set to a <language> value (see <language> ).

<family- name >

The name of a font family, such as Arial, Times New Roman, or Courier.

<frequency>

Frequency values; units may be Hz or KHz.

<generic-family>

Generic names for fonts that you use as a last resort if the browser cant find a specific font. Examples are serif (browser should choose a serif font), sans-serif (browser should choose a sans-serif family), and monospace (browser should choose a monospace font).

<generic-voice>

Aural voices; may be male, female , or child.

<integer>

Standard integer values.

<keep>

A context-dependant property you set to Auto for no keep-together constraints or Always for strict keep-together constraints. See the XSL specification for more information.

<language>

A language specifier that conforms to the RFC1766 specification (which you can find at www.w3.org/TR/xsl/sliceD.html#RFC1766).

<length>

Length; may start with a + or -, followed by a number, which may include a decimal point, followed by a unit identifier, which may be em (font size of the relevant font), ex (the x-height of the font), px (pixels as specified relative to the viewing device), pt (points, 1/72nds of an inch), in (inches), cm (centimeters), mm (millimeters), or pc (picas, 1/6th of an inch).

<length-bp-ip-direction>

Specifies the distance that separates adjacent cell borders in the row-stacking-direction. See www.w3.org/TR/xsl/slice7.html for more details.

<length-conditional>

A compound value specifying the width and any conditionality of the border for the before-edge. See www.w3.org/TR/xsl/slice7.html#pr-section for more details.

<length-range>

Specifies a length range, as defined in the XSL specification.

<margin-width>

Can be a <length> , <percentage>, or auto. How the auto value works is dependant on context; see www.w3.org/TR/REC-CSS2/visudet.html#Computing_widths_and_margins for more information.

<number>

A number; may include a sign and a decimal point.

<padding-width>

Set to a <length> value.

<percentage>

A number, which may include a sign, followed by a percentage sign (%).

<relative-size>

A font size relative to the parent element, may be either Larger or Smaller.

<shape>

Currently may only specify a rectangle, as in rect(<top> <right> <bottom> <left>) .

<space>

Specifies the minimum, optimum, and maximum values for a space. See www.w3.org/TR/xsl/slice4.html#spacecond for more information.

<specific-voice>

Specifies a specific voice. See www.w3.org/TR/REC-CSS2/aural.html#propdef-voice-family for more information.

<time>

Time units, specified as a number followed immediately by ms (for milliseconds ) or s (for seconds).

<uri-specification>

Uniform Resource Indicator (URI); the Web address of a page element, such as an image.

Also, note that XSL-FO properties, like CSS2 properties, may be set to the value inherit, which means the value of the property should be inherited from its parent element.

The following list includes the more common XSL-FO properties. For the complete list, refer to Appendix B.

  • absolute-position. Specifies whether an items position is absolute. Set to auto absolute fixed inherit.

  • background. A shorthand property for setting the individual background properties (background-color, background-image, background-repeat , background-attachment and background-position) all at once. Set to [< background-color > <background-image> <background-repeat> <background-attachment> <background-position> ]] inherit.

  • background-attachment. Specifies whether the background scrolls . Set to scroll fixed inherit.

  • background-color. Specifies the background color of an element. Set to <color> transparent inherit.

  • background-image. Specifies the background image of an element. Set to <uri-specification> none inherit.

  • background-repeat. Specifies whether the background image is tiled, and if so, how. Set to repeat repeat-x repeat-y no-repeat inherit.

  • border. A shorthand property for setting the same width, color, and style for all four borders (top, bottom, left, and right) of a box. Set to [ <border-width> <border-style> <color> ] inherit.

  • border-after-color. Specifies the color of the border on the after-edge of region. Set to <color> inherit.

  • border-after-style. Specifies the border style for the after edge. Set to <border-style> inherit.

  • border-after-width. Specifies the border width for the after edge. Set to <border-width> <length-conditional> inherit.

  • border-before-color. Specifies the color of the border on a before edge. Set to <color> inherit.

  • border-before-style. Specifies the border style for a before edge. Set to <border-style> inherit.

  • border-before-width. Specifies the border width for a before edge. Set to <border-width> <length-conditional> inherit.

  • border-bottom. A shorthand property for setting the width, style, and color of the bottom border of a block area or inline area. Set to [ <border-top-width> <border-style> <color> ] inherit.

  • border-bottom-color. Specifies the border color for a bottom edge. Set to <color> inherit.

  • border-bottom-style. Specifies the border style for a bottom edge. Set to <border-style> inherit.

  • border-bottom-width. Specifies the border width for a bottom edge. Set to <border-width> inherit.

  • border-collapse. Specifies a tables border model. Set to collapse separate inherit.

  • border-color . Specifies the color of all four borders at once. Set to <color>{1,4} transparent inherit.

  • border-end-color. Specifies the color of the border on an end edge. Set to <color> inherit.

  • border-end-style. Specifies the border style for an end edge. Set to <border-style> inherit.

  • border-end-width. Specifies the border width for an end edge. Set to <border-width> <length-conditional> inherit.

  • border-left. A shorthand property for setting the width, style, and color of the left border all at once. Set to [ <border-top-width> <border-style> <color> ] inherit.

  • border-left-color. Specifies the border color for a left edge. Set to <color> inherit.

  • border-left-style. Specifies the border style for a left edge. Set to <border-style> inherit.

  • border-left-width. Specifies the border width for a left edge. Set to <border-width> inherit.

  • border-right. A shorthand property for setting the width, style, and color of a right border all at once. Set to [ <border-top-width> <border-style> <color> ] inherit.

  • border-right-color. Specifies the border color for a right edge. Set to <color> inherit.

  • border-right-style. Specifies the border style for a right edge. Set to <border-style> inherit.

  • border-right-width. Specifies the border width for a right edge. Set to <border-width> inherit.

  • border-spacing . Specifies the distance that separates adjacent cell borders. Set to <length> <length>? inherit.

  • border-start-color. Specifies the color of the border on a start edge. Set to <color>.

  • border-start-style. Specifies the border style for the starting edge. Set to <border-style> inherit.

  • border-start-width. Specifies the border width for the starting edge. Set to <border-width> <length-conditional> inherit.

  • border-style. Sets the style of the four borders. Set to <border-style>{1,4} inherit.

  • border-top. A shorthand property for setting the width, style, and color of the top border of a block area or inline area all at once. Set to [ <border-top-width> <border-style> <color> ] inherit.

  • border-top-color. Specifies the color of the border on a top edge. Set to <color> inherit.

  • border-top-style. Specifies the line style of a boxs border (solid, double, dashed, and so on).

  • border-top-width. Sets the width of the top border. Set to <border-width> inherit.

  • border-width. A shorthand property for setting border-top-width , border-rightwidth , borderbottomwidth , and borderleftwidth all at once. Set to <border-width>{1,4} inherit.

  • bottom. Specifies how far a boxs bottom content edge is offset above the bottom of the boxs containing block. Set to <length> <percentage> auto inherit.

  • character. Specifies the Unicode character to be inserted. Set to <character>.

  • color. Specifies the foreground color of an elements text. Set to <color> inherit.

  • column-count. Specifies the number of columns in a region. Set to <number> inherit.

  • column-number. Sets the column number for table cells . Set to <number>.

  • column-width. Specifies the width of an object such as an external graphic. Set to auto scale-to-fit <length> <percentage> inherit.

  • float. Specifies whether a box should float to the left, right, or not at all. Set to before start end left right none inherit.

  • flow-name. Sets a flows name. Set to <name>.

  • font. A shorthand property for setting font-style, font-variant, font-weight , font-size , line-height , and font-family all at once. Set to [ [ <font-style> <font-variant> <font-weight> ]? <font-size> [ / <line-height>]? <font-family> ] caption icon menu message-box small-caption status-bar inherit.

  • font-family. Specifies a list of font family names and/or generic family names in order of preference. Set to [[ <family-name> <generic-family> ],]* [<family-name> <generic-family>] inherit.

  • font-size. Sets the font size. Set to <absolute-size> <relative-size> <length> <percentage> inherit.

  • font-style. Sets the fonts style. Set to normal italic oblique backslant inherit.

  • font-variant. Selects bicameral fonts. Set to normal small-caps inherit

  • font-weight. Sets the font weight. Set to normal bold bolder lighter 100 200 300 400 500 600 700 800 900 inherit.

  • format. An XSLT format. Set to <string>.

  • grouping-separator. An XSLT format grouping separator. Set to <character>.

  • grouping-size. The XSLT format grouping size. Set to <number>.

  • height. Specifies the content height of boxes generated by block-level and replaced elements. Set to <length> <percentage> auto inherit.

  • initial- page-number . Sets the initial page number. Set to auto auto-odd auto-even <number> inherit.

  • left. Specifies how far a boxs left content edge is offset to the right of the left edge of a containing block. Set to: <length> <percentage> auto inherit.

  • linefeed -treatment. Specifies the treatment of linefeeds. Set to ignore preserve treat-as-space treat-as-zero-width-space inherit.

  • line-height. Specifies the minimal height of each generated inline box. Set to normal <length> <number> <percentage> <space> inherit.

  • margin. A shorthand property for setting margin-top, margin-right, margin-bottom, and margin-left all at once. Set to <margin-width>{1,4} inherit.

  • margin-bottom. Sets the bottom margin of a box. Set to <margin-width> inherit.

  • margin-left. Sets the left margin of a box. Set to <margin-width> inherit.

  • margin-right. Sets the right margin of a box. Set to <margin-width> inherit.

  • margin-top. Sets the top margin of a box. Set to <margin-width> inherit.

  • master-name. Sets or selects a master. Set to <name>.

  • number-columns- spanned . Sets the number of columns spanned by a table cell. Set to <number>.

  • number-rows-spanned. Sets the number of rows spanned by a table cell. Set to <number>.

  • page-break-after. Same as the CSS2 property of the same name. Set to auto always avoid left right inherit.

  • page-break-before. Same as the CSS2 property of the same name. Set to auto always avoid left right inherit.

  • page-height. Sets the page height. Set to auto indefinite <length> inherit.

  • page-width. Sets the page width. Set to auto indefinite <length> inherit.

  • position. Specifies the positioning scheme to be used. Set to static relative absolute fixed inherit.

  • relative-position. Same as the CSS2 property of the same name. Set to static relative inherit.

  • right. Specifies how far a content edge is offset to the left of the right edge of the containing block. Set to <length> <percentage> auto inherit.

  • score-spaces. Specifies whether the text-decoration property shall be applied to spaces. Set to true false inherit.

  • space-treatment. Specifies the treatment of space and other whitespace characters except for linefeeds. Set to ignore preserve ignore-if-before-linefeed ignore-if-after-linefeed ignore-if- surrounding -linefeed inherit.

  • span. Specifies whether a block-level object should be placed in the current column or should span all columns of a multi-column region. Set to none all inherit.

  • src. Specifies the URI reference that is to be used to locate an external resource. Set to <uri-specification> inherit.

  • start-indent. Specifies the distance from the start edge of the content rectangle of the containing reference area to the start edge of the content rectangle of that block area. Set to <length> inherit.

  • starts-row. Specifies whether this cell starts a row. Set to true false.

  • text-align. Specifies how inline content of a block is aligned. Set to start center end justify inside outside left right <string> inherit.

  • text-decoration. Specifies decorations that are added to the text of an element. Set to none [ [ underline no-underline] [ overline no-overline ] [ line-through no-line-through ] [ blink no-blink ] ] inherit.

  • text-indent. Specifies the indentation of the first line of text in a block. Set to <length> <percentage> inherit.

  • text-shadow. Specifies a comma-separated list of shadow effects to be applied to the text of the element. Set to none [<color> <length> <length> <length>? ,]* [<color> <length> <length> <length>?] inherit.

  • top. Specifies how far a content edge is offset below the top edge of the containing block. Set to <length> <percentage> auto inherit.

  • vertical-align . Specifies vertical positioning. Set to baseline middle sub super text-top text-bottom <percentage> <length> top bottom inherit.

  • visibility. Specifies whether the boxes generated by an element are rendered or not. Set to visible hidden collapse inherit.

  • white-space . Specifies how whitespace inside the element is handled. Set to normal pre nowrap inherit.

  • white-space-collapse. Specifies the treatment of consecutive whitespace. Set to false true inherit.

  • width. Specifies the content width of boxes generated by block level and replaced elements. Set to <length> <percentage> auto inherit.

  • wrap-option. Specifies how line-wrapping of the formatting object is to be handled. Set to no-wrap wrap inherit.

Not all properties apply to all XSL-FO objects. Ill list which properties apply to the objects Im using explicitly in this and the next chapter. Note also that no XSL-FO processor implements all these properties yet.

Now that you have had an overview of the structure of XSL-FO, its time to put it to work. I do that by working through an example in detail now.



Inside XSLT
Inside Xslt
ISBN: B0031W8M4K
EAN: N/A
Year: 2005
Pages: 196

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net