Inline-Level Formatting Objects

Besides block objects, you can also create inline objects. Inline objects are usually used to format part of text as that text follows the normal flow in the page. For example, you can make the first character in a paragraph larger, make the whole first line smaller, insert page numbers into text, and so on.

Here are the inline formatting objects:

  • fo: bidi-override

  • fo:character

  • fo: initial-property-set

  • fo:external-graphic

  • fo:instream-foreign-object

  • fo:inline

  • fo:inline-container

  • fo:leader

  • fo: page-number

  • fo:page-number-citation

I'll take a look at a few of the most common of these next .

Using fo:character

The fo:character object lets you handle the characters in a document individually, which is very useful if you want to write an XSL processor, but not necessarily that useful otherwise . You can use fo:character to replace characters with other characters. Here's an example; in this case, I'm matching an element named <MASKED> and replacing the characters in it with the character - :

 <xsl:template match="MASKED">      <fo:character character="-">         <xsl:value-of select="."/>     </fo:character> </xsl:template> 

You can use these properties with fo:character :

  • Common aural properties: azimuth , cue-after , cue-before , elevation , pause-after , pause-before , pitch , pitch-range , play-during , richness , speak , speak-header , speak-numeral , speak-punctuation , speech-rate , stress , voice-family , volume

  • Common border, padding, and background properties: background-attachment , background- color , background-image , background-repeat , background-position-horizontal , background-position-vertical , border-before-color , border-before-style , border-before-width , border-after-color , border-after-style , border-after-width , border-start-color , border-start-style , border-start-width , border-end-color , border-end-style , border-end-width , border-top-color , border-top-style , border-top-width , border-bottom-color , border-bottom-style , border-bottom-width , border-left-color , border-left-style , border-left-width , border-right-color , border-right-style , border-right-width , padding-before , padding-after , padding-start , padding-end , padding-top , padding-bottom , padding-left , padding-right

  • Common font properties: font-family , font-size , font-stretch , font-size-adjust , font-style , font-variant , font-weight

  • Common hyphenation properties: country , language , script , hyphenate , hyphenation-character , hyphenation-push-character-count , hyphenation- remain -character-count

  • Common margin properties, inline: space-end , space-start

  • alignment-adjust

  • baseline-identifier

  • baseline-shift

  • character

  • color

  • dominant-baseline

  • font-height-override-after

  • font-height-override-before

  • glyph-orientation-horizontal

  • glyph-orientation-vertical

  • id

  • keep-with-next

  • keep-with-previous

  • letter-spacing

  • line-height

  • line-height-shift-adjustment

  • relative-position

  • score-spaces

  • suppress-at-line-break

  • text-decoration

  • text-shadow

  • text-transform

  • treat-as-word-space

  • word-spacing

fo:initial-property-set

You can format the first line of a fo:block object with fo:initial-property-set (it's much like the CSS first-line pseudo-element). Here's an example in which I'm setting the first line of a block in small caps:

 <fo:block>      <fo:initial-property-set font-variant="small-caps" />     Here is the actual text of the paragraph; the first line,     and only the first line, will be displayed in small caps. </fo:block> 

You can use these properties with fo:initial-property-set :

  • Common accessibility properties: source-document , role

  • Common aural properties: azimuth , cue-after , cue-before , elevation , pause-after , pause-before , pitch , pitch-range , play-during , richness , speak , speak-header , speak-numeral , speak-punctuation , speech-rate , stress , voice-family , volume

  • Common border, padding, and background properties: background-attachment , background-color , background-image , background-repeat , background-position-horizontal , background-position-vertical , border-before-color , border-before-style , border-before-width , border-after-color , border-after-style , border-after-width , border-start-color , border-start-style , border-start-width , border-end-color , border-end-style , border-end-width , border-top-color , border-top-style , border-top-width , border-bottom-color , border-bottom-style , border-bottom-width , border-left-color , border-left-style , border-left-width , border-right-color , border-right-style , border-right-width , padding-before , padding-after , padding-start , padding-end , padding-top , padding-bottom , padding-left , padding-right

  • Common font properties: font-family , font-size , font-stretch , font-size-adjust , font-style , font-variant , font-weight

  • color

  • id

  • letter-spacing

  • line-height

  • line-height-shift-adjustment

  • relative-position

  • score-spaces

  • text-decor ation

  • text-shadow

  • text-transform

  • word-spacing

Adding Graphics: fo:external-graphic

Another inline formatting object that is available is fo:external-graphic . You use this object to embed an image in a document ( unfortunately , fo:external-graphic is not supported by fop yet).

You can set the size of the image in the document with the content-height , content-width , and scaling properties; if you don't set these properties, the image is displayed in its original size. Here's an example, ch14_05.fo, displaying an image, ch14_06.jpg, and a caption:

Listing ch14_05.fo
 <?xml version="1.0" encoding="UTF-8"?> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">     <fo:layout-master-set>         <fo:simple-page-master margin-right="20mm"             margin-left="20mm" margin-bottom="10mm"             margin-top="10mm" page-width="300mm"             page-height="400mm" master-name="page">             <fo:region-body margin-right="0mm"                 margin-left="0mm" margin-bottom="10mm"                 margin-top="0mm"/>          <fo:region-after extent="10mm"/>         </fo:simple-page-master>     </fo:layout-master-set>     <fo:page-sequence master-reference="page">         <fo:flow flow-name="xsl-region-body">  <fo:block>   <fo:external-graphic src="file:ch14_06.jpg"/>   </fo:block>   <fo:block space-before="10pt" start-indent="10mm"   end-indent="0mm" font-size="24pt">   Embedding images!   </fo:block>  </fo:flow>     </fo:page-sequence> </fo:root> 

You can create the PDF file ch14_07.pdf from ch14_05.po like this:

 %fop ch14_05.fo ch14_07.pdf 

You can see the results in Figure 14-2.

Figure 14-2. Embedding images in a PDF document.

graphics/14fig02.gif

You can use these properties with fo:external-graphic :

  • Common accessibility properties: source-document , role

  • Common aural properties: azimuth , cue-after , cue-before , elevation , pause-after , pause-before , pitch , pitch-range , play-during , richness , speak , speak-header , speak-numeral , speak-punctuation , speech-rate , stress , voice-family , volume

  • Common border, padding, and background properties: background-attachment , background-color , background-image , background-repeat , background-position-horizontal , background-position-vertical , border-before-color , border-before-style , border-before-width , border-after-color , border-after-style , border-after-width , border-start-color , border-start-style , border-start-width , border-end-color , border-end-style , border-end-width , border-top-color , border-top-style , border-top-width , border-bottom-color , border-bottom-style , border-bottom-width , border-left-color , border-left-style , border-left-width , border-right-color , border-right-style , border-right-width , padding-before , padding-after , padding-start , padding-end , padding-top , padding-bottom , padding-left , padding-right

  • Common margin properties, inline: space-end , space-start

  • alignment-adjust

  • baseline-identifier

  • baseline-shift

  • block-progression-dimension

  • content-height

  • content-type

  • content-width

  • dominant-baseline

  • height

  • id

  • inline-progression-dimension

  • keep-with-next

  • keep-with-previous

  • line-height

  • line-height-shift-adjustment

  • relative-position

  • overflow

  • scaling

  • scaling-method

  • src

  • width

The Inline Formatting Object: fo:inline

You can use the fo:inline formatting object to format a part of your text with a background or surround it with a border. This object is fairly general, and it lets you format an inline area almost as though it were a block.

You can use these properties with fo:inline :

  • Common accessibility properties: source-document , role

  • Common aural properties: azimuth , cue-after , cue-before , elevation , pause-after , pause-before , pitch , pitch-range , play-during , richness , speak , speak-header , speak-numeral , speak-punctuation , speech-rate , stress , voice-family , volume

  • Common border, padding, and background properties: background-attachment , background-color , background-image , background-repeat , bac kground-position-horizontal , background-position-vertical , border-before-color , border-before-style , border-before-width , border-after-color , border-after-style , border-after-width , border-start-color , border-start-style , border-start-width , border-end-color , border-end-style , border-end-width , border-top-color , border-top-style , border-top-width , border-bottom-color , border-bottom-style , border-bottom-width , border-left-color , border-left-style , border-left-width , border-right-color , border-right-style , border-right-width , padding-before , padding-after , padding-start , padding-end , padding-top , padding-bottom , padding-left , padding-right

  • Common font properties: font-family , font-size , font-stretch , font-size-adjust , font-style , font-variant , font-weight

  • Common margin properties, inline: space-end , space-start

  • alignment-adjust

  • baseline-identifier

  • baseline-shift

  • color

  • dominant-baseline

  • id

  • keep-together

  • keep-with-next

  • keep-with-previous

  • line-height

  • line-height-shift-adjustment

  • relative-position

  • text-decoration

  • visibility

  • z-index



Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

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