Table of contentsAppendices |
6.6 Inline-level Formatting ObjectsInline-level Formatting ObjectsIntroduction[top]IntroductionInline-level formatting objects are most commonly used to format a portion of text or for generating rules and leaders. There are many other uses. The following examples illustrate some of these uses of inline-level formatting objects.
Examples[top]ExamplesFirst Line of Paragraph in Small-caps[top]First Line of Paragraph in Small-capsInput sample: <doc> <p>This is the text of a paragraph that is going to be presented with the first line in small-caps.</p> </doc> XSL Stylesheet:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version='1.0'>
<xsl:template match="p">
<fo:block>
<fo:initial-property-set font-variant="small-caps"/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
</xsl:stylesheet>
Result instance: elements and attributes in the fo: namespace <fo:block> <fo:initial-property-set font-variant="small-caps"> </fo:initial-property-set>This is the text of a paragraph that is going to be presented with the first line in small-caps. </fo:block> Figure with a Photograph[top]Figure with a PhotographInput sample:
<doc>
<figure>
<photo image="TH0317A.jpg"/>
<caption>C'ieng Tamlung of C'ieng Mai</caption>
</figure>
</doc>
In this example the image (an fo:external-graphic) is placed as a centered block-level object. The caption is centered with 10mm indents. XSL Stylesheet:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version='1.0'>
<xsl:template match="figure">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="photo">
<fo:block text-align="center">
<fo:external-graphic src="{@image}"/>
</fo:block>
</xsl:template>
<xsl:template match="caption">
<fo:block space-before="3pt" text-align="center"
start-indent="10mm" end-indent="10mm">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
</xsl:stylesheet>
fo: element and attribute tree:
<fo:block>
<fo:block text-align="center">
<fo:external-graphic src="TH0317A.jpg"/>
</fo:block>
<fo:block space-before="3pt" text-align="center" start-indent="10mm"
end-indent="10mm">C'ieng Tamlung of C'ieng Mai</fo:block>
</fo:block>
Page numbering and page number reference[top]Page numbering and page number referenceInput sample:
<!DOCTYPE doc SYSTEM "pgref.dtd">
<doc>
<chapter id="x"><title>Chapter</title>
<p>Text</p>
</chapter>
<chapter><title>Chapter</title>
<p>For a description of X see <ref refid="x"/>.</p>
</chapter>
</doc>
In this example each page has a running footer containing the word "Page" followed by the page number. The "ref" element generates the word "page" followed by the page number of the page on which the referenced by the "refid" attribute was placed. XSL Stylesheet:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version='1.0'>
<xsl:template match="doc">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="page"
page-height="297mm" page-width="210mm"
margin-top="20mm" margin-bottom="10mm"
margin-left="25mm" margin-right="25mm">
<fo:region-body
margin-top="0mm" margin-bottom="15mm"
margin-left="0mm" margin-right="0mm"/>
<fo:region-after extent="10mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="page">
<fo:static-content flow-name="xsl-region-after">
<fo:block>
<xsl:text>Page </xsl:text>
<fo:page-number/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="chapter/title">
<fo:block id="{generate-id(.)}">
<xsl:number level="multiple" count="chapter" format="1. "/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="p">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="ref">
<xsl:text>page </xsl:text>
<fo:page-number-citation refid="{generate-id(id(@refid)/title)}"/>
</xsl:template>
</xsl:stylesheet>
Result Instance: elements and attributes in the fo: namespace
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="page"
page-height="297mm" page-width="210mm"
margin-top="20mm" margin-bottom="10mm"
margin-left="25mm" margin-right="25mm">
<fo:region-body margin-top="0mm" margin-bottom="15mm"
margin-left="0mm" margin-right="0mm"/>
<fo:region-after extent="10mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="page">
<fo:static-content flow-name="xsl-region-after">
<fo:block>Page <fo:page-number/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block id="N5">1. Chapter</fo:block>
<fo:block>Text</fo:block>
<fo:block id="N13">2. Chapter</fo:block>
<fo:block>For a description of X see page <fo:page-number-citation refid="N5"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Table of Contents with Leaders[top]Table of Contents with LeadersInput sample:
<doc>
<chapter><title>Chapter</title>
<p>Text</p>
<section><title>Section</title>
<p>Text</p>
</section>
<section><title>Section</title>
<p>Text</p>
</section>
</chapter>
<chapter><title>Chapter</title>
<p>Text</p>
<section><title>Section</title>
<p>Text</p>
</section>
<section><title>Section</title>
<p>Text</p>
</section>
</chapter>
</doc>
In this example the table of contents is formatted with a dot leader between the heading text and the page number. XSL Stylesheet:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version='1.0'>
<xsl:template match="doc">
<!-- create the table of contents -->
<xsl:apply-templates select="chapter/title" mode="toc"/>
<!-- do the document -->
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="chapter/title" mode="toc">
<fo:block text-align-last="justify">
<fo:simple-link internal-destination="{generate-id(.)}">
<xsl:number level="multiple" count="chapter" format="1. "/>
<xsl:apply-templates/>
</fo:simple-link>
<xsl:text> </xsl:text>
<fo:leader leader-length.minimum="12pt" leader-length.optimum="40pt"
leader-length.maximum="100%" leader-pattern="dots"/>
<xsl:text> </xsl:text>
<fo:page-number-citation ref-id="{generate-id(.)}"/>
</fo:block>
<xsl:apply-templates select="../section/title" mode="toc"/>
</xsl:template>
<xsl:template match="section/title" mode="toc">
<fo:block start-indent="10mm" text-align-last="justify">
<fo:simple-link internal-destination="{generate-id(.)}">
<xsl:number level="multiple" count="chapter|section" format="1.1 "/>
<xsl:apply-templates/>
</fo:simple-link>
<xsl:text> </xsl:text>
<fo:leader leader-length.minimum="12pt" leader-length.optimum="40pt"
leader-length.maximum="100%" leader-pattern="dots"/>
<xsl:text> </xsl:text>
<fo:page-number-citation ref-id="{generate-id(.)}"/>
</fo:block>
</xsl:template>
<xsl:template match="chapter/title">
<fo:block id="{generate-id(.)}">
<xsl:number level="multiple" count="chapter" format="1. "/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="section/title">
<fo:block id="{generate-id(.)}">
<xsl:number level="multiple" count="chapter|section" format="1.1 "/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="p">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
</xsl:stylesheet>
Result Instance: elements and attributes in the fo: namespace
<fo:block text-align-last="justify">
<fo:simple-link internal-destination="N4">1. Chapter
</fo:simple-link>
<fo:leader leader-length.minimum="12pt" leader-length.optimum="40pt"
leader-length.maximum="100%" leader-pattern="dots">
</fo:leader>
<fo:page-number-citation ref-id="N4">
</fo:page-number-citation>
</fo:block>
<fo:block start-indent="10mm" text-align-last="justify">
<fo:simple-link internal-destination="N11">1.1 Section
</fo:simple-link>
<fo:leader leader-length.minimum="12pt" leader-length.optimum="40pt"
leader-length.maximum="100%" leader-pattern="dots">
</fo:leader>
<fo:page-number-citation ref-id="N11">
</fo:page-number-citation>
</fo:block>
<fo:block start-indent="10mm" text-align-last="justify">
<fo:simple-link internal-destination="N19">1.2 Section
</fo:simple-link>
<fo:leader leader-length.minimum="12pt" leader-length.optimum="40pt"
leader-length.maximum="100%" leader-pattern="dots">
</fo:leader>
<fo:page-number-citation ref-id="N19">
</fo:page-number-citation>
</fo:block>
<fo:block text-align-last="justify">
<fo:simple-link internal-destination="N28">2. Chapter
</fo:simple-link>
<fo:leader leader-length.minimum="12pt" leader-length.optimum="40pt"
leader-length.maximum="100%" leader-pattern="dots">
</fo:leader>
<fo:page-number-citation ref-id="N28">
</fo:page-number-citation>
</fo:block>
<fo:block start-indent="10mm" text-align-last="justify">
<fo:simple-link internal-destination="N35">2.1 Section
</fo:simple-link>
<fo:leader leader-length.minimum="12pt" leader-length.optimum="40pt"
leader-length.maximum="100%" leader-pattern="dots">
</fo:leader>
<fo:page-number-citation ref-id="N35">
</fo:page-number-citation>
</fo:block>
<fo:block start-indent="10mm" text-align-last="justify">
<fo:simple-link internal-destination="N43">2.2 Section
</fo:simple-link>
<fo:leader leader-length.minimum="12pt" leader-length.optimum="40pt"
leader-length.maximum="100%" leader-pattern="dots">
</fo:leader>
<fo:page-number-citation ref-id="N43">
</fo:page-number-citation>
</fo:block>
<fo:block id="N4">1. Chapter
</fo:block>
<fo:block>Text
</fo:block>
<fo:block id="N11">1.1 Section
</fo:block>
<fo:block>Text
</fo:block>
<fo:block id="N19">1.2 Section
</fo:block>
<fo:block>Text
</fo:block>
<fo:block id="N28">2. Chapter
</fo:block>
<fo:block>Text
</fo:block>
<fo:block id="N35">2.1 Section
</fo:block>
<fo:block>Text
</fo:block>
<fo:block id="N43">2.2 Section
</fo:block>
<fo:block>Text
</fo:block>
fo:bidi-override[top]fo:bidi-overrideCommon Usage: The fo:bidi-override formatting object is used when the Unicode BIDI algorithm fails. It forces a string of text to be written in a specific direction. Areas: The fo:bidi-override formatting object generates one or more normal inline-areas. The fo:bidi-override returns these areas, any page-level-out-of-line areas, and any reference-level-out-of-line areas returned by the children of the fo:bidi-override. Trait Derivation: The direction traits are derived from the "writing-mode", "direction", and "unicode-bidi" properties as described in [refine-writing-mode] . Constraints: No area may have more than one normal child area returned by the same fo:bidi-override formatting object. The children of each normal area returned by an fo:bidi-override must satisfy the constraints specified in [area-inlinebuild] . Contents: (#PCDATA|%inline;|%block;)* In addition this formatting object may have a sequence of zero or more fo:markers as its initial children. An fo:bidi-override that is a descendant of an fo:leader or of an fo:inline child of an fo:footnote may not have block-level children, unless it has a nearer ancestor that is an fo:inline-container. The following properties apply to this formatting object:
fo:character[top]fo:characterCommon Usage: The fo:character flow object represents a character that is mapped to a glyph for presentation. It is an atomic unit to the formatter. When the result tree is interpreted as a tree of formatting objects, a character in the result tree is treated as if it were an empty element of type fo:character with a character attribute equal to the Unicode representation of the character. The semantics of an "auto" value for character properties, which is typically their initial value, are based on the Unicode code point. Overrides may be specified in an implementation-specific manner. NOTE: Unicode Tag Characters need not be supported. NOTE: Areas: The fo:character formatting object generates and returns one or more normal inline-area. NOTE: Constraints: The dimensions of the areas are determined by the font metrics for the glyph. When formatting an fo:character with a "treat-as-word-space" value of "true", the User Agent may use a different method for determining the inline-progression-dimension of the area. NOTE: Contents: EMPTY The following properties apply to this formatting object:
fo:initial-property-set[top]fo:initial-property-setCommon Usage: The fo:initial-property-set auxiliary formatting object specifies formatting properties for the first line of an fo:block. NOTE: Areas: The fo:initial-property-set formatting object does not generate or return any areas. It simply holds a set of traits that are applicable to the first line-area of the area that has a value of "true" for the is-first trait and that was generated by the parent fo:block of the fo:initial-property-set. Trait Derivation: The traits on the fo:initial-property-set are taken into account as traits constraining the first line as if the child inline formatting objects of the fo:block, or parts of them in the case of a line-break, that were used in formatting the first line were enclosed by an fo:wrapper, as a direct child of the fo:block, with those traits. Constraints: None. Contents: EMPTY The following properties apply to this formatting object:
fo:external-graphic[top]fo:external-graphicCommon Usage: The fo:external-graphic flow object is used for a graphic where the graphics data resides outside of the fo:element tree. Areas: The fo:external-graphic formatting object generates and returns one inline-level viewport-area and one reference-area containing the external graphic. The inline-level area uses the large-allocation-rectangle as defined in [area-geo] . NOTE: Constraints: The viewport's size is determined by the block-progression-dimension and inline-progression-dimension traits. For values of "auto", the content size of the graphic is used. The content size of a graphic is determined by taking the intrinsic size of the graphic and scaling as specified by the content-height, content-width, and scaling traits. If one of the content-height or content-width is not "auto", the same scale factor (as calculated from the specified non-auto value) is applied equally to both directions. Once scaled, the reference-area is aligned with respect to the viewport-area using the text-align and display-align traits. If it is too large for the viewport-area, the graphic is aligned as if it would fit and the overflow trait controls the clipping, scroll bars, etc. In the case when the graphics format does not specify an intrinsic size of the graphic the size is determined in an implementation-defined manner. NOTE: Contents: EMPTY The following properties apply to this formatting object:
fo:instream-foreign-object[top]fo:instream-foreign-objectCommon Usage: The fo:instream-foreign-object flow object is used for an inline graphic or other "generic" object where the object data resides as descendants of the fo:instream-foreign-object, typically as an XML element subtree in a non-XSL namespace. NOTE: Areas: The fo:instream-foreign-object formatting object generates and returns one inline viewport-area and one reference-area containing the instream-foreign-object. The inline-level area uses the large-allocation-rectangle as defined in [area-geo] . Constraints: The viewport's size is determined by the block-progression-dimension and inline-progression-dimension traits. For values of "auto", the content size of the instream foreign object is used. The content size of an instream-foreign-object is determined by taking the intrinsic size of the object and scaling as specified by the content-height, content-width, and scaling traits. If one of the content-height or content-width is not "auto", the same scale factor (as calculated from the specified non-auto value) is applied equally to both directions. Once scaled, the reference-area is aligned with respect to the viewport-area using the text-align and display-align traits. If it is too large for the viewport-area, the instream-foreign-object is aligned as if it would fit and the overflow trait controls the clipping, scroll bars, etc. In the case when the instream-foreign-object does not specify an intrinsic size of the object, the size is determined in an implementation defined manner. Contents: The fo:instream-foreign-object flow object has a child from a non-XSL namespace. The permitted structure of this child is that defined for that namespace. The fo:instream-foreign-object flow object may have additional attributes in the non-XSL namespace. These, as well as the xsl defined properties, are made available to the processor of the content of the flow object. Their semantics is defined by that namespace. The following properties apply to this formatting object:
fo:inline[top]fo:inlineCommon Usage: The fo:inline formatting object is commonly used for formatting a portion of text with a background or enclosing it in a border. Areas: The fo:inline formatting object generates one or more normal inline-areas. The fo:inline returns these areas, any page-level-out-of-line areas, and any reference-level-out-of-line areas returned by the children of the fo:inline. Constraints: No area may have more than one normal child area returned by the same fo:inline formatting object. The children of each normal area returned by an fo:inline must satisfy the constraints specified in [area-inlinebuild] . In addition the constraints imposed by the traits derived from the properties applicable to this formatting object must be satisfied. The geometric constraints are rigorously defined in [area_model] . Contents: (#PCDATA|%inline;|%block;)* In addition this formatting object may have a sequence of zero or more fo:markers as its initial children. An fo:inline that is a child of an fo:footnote may not have block-level children. An fo:inline that is a descendant of an fo:leader or of the fo:inline child of an fo:footnote may not have block-level children, unless it has a nearer ancestor that is an fo:inline-container. The following properties apply to this formatting object:
fo:inline-container[top]fo:inline-containerCommon Usage: The fo:inline-container flow object is used to generate an inline reference-area, typically containing text blocks with a different writing-mode. NOTE: Areas: The fo:inline-container formatting object generates one or more viewport/reference pairs. The viewport-areas generated by the fo:inline-container are normal inline-level areas that use the large-allocation-rectangle as defined in [area-geo] . The fo:inline-container returns these areas and any page-level-out-of-line areas returned by the children of the fo:inline-container. Trait Derivation: The areas generated by the fo:inline-container formatting object have a value of "true" for the is-reference-area. The size of the viewport-area and the reference-area has to be fixed in the inline-progression-direction. It must be specified unless the inline-progression-direction is parallel to the inline-progression-direction of the reference-area into which the areas generated by this flow object are placed. The values in the baseline-table of this object are calculated as follows:
Constraints: No area may have more than one normal child area returned by the same fo:inline-container formatting object. The children of each reference-area generated by an fo:inline-container formatting object must be normal block-areas returned by the children of the fo:inline-container, must be properly stacked, and must be properly ordered. Any reference-level-out-of-line areas returned by the children of the fo:inline-container are handled as described in [fo_float] . Contents: (%block;)+ In addition this formatting object may have a sequence of zero or more fo:markers as its initial children. The following properties apply to this formatting object:
fo:leader[top]fo:leaderCommon Usage: The fo:leader formatting object is often used:
Areas: The fo:leader formatting object generates and returns a single normal inline-area. Trait Derivation: If the value of the leader-pattern is "use-content" the block-progression-dimension of the content-rectangle is determined in the same manner as for line-areas; otherwise it is determined by the rule-thickness trait. Constraints: If the leader's minimum length is too long to place in the line-area, the leader will begin a new line. If it is too long to be placed in a line by itself, it will overflow the line and potentially overflow the reference-area in accordance with that container's overflow trait. The fo:leader formatting object can have any inline formatting objects and characters as its children, except that fo:leaders may not be nested. Its children are ignored unless the value of the leader-pattern trait is "use-content". NOTE: The inline-area generated by the fo:leader has a dimension in the inline-progression-direction which shall be at least the leader-length.minimum and at most the leader-length.maximum. For lines-areas that have been specified to be justified, the justified line-area must honor the leader-alignment trait of any inline-areas generated by fo:leaders. If the value of the leader-pattern trait is "dots" or "use-content", the following constraint applies: The inline-area generated by the fo:leader has as its children the areas returned by children of the fo:leader, or obtained by formatting the pattern specified in the leader-pattern trait, repeated an integral number of times. If the width of even a single repetition is larger than the dimension of the inline-area in the inline-progression-direction, the inline-area shall be filled with blank space. The space-start and space-end of the child areas is set to account for the constraints specified in the leader-pattern-width and leader-alignment traits. NOTE: NOTE: NOTE: Contents: (#PCDATA|%inline;)* The content must not contain an fo:leader, fo:inline-container, fo:block-container, fo:float, fo:footnote, or fo:marker either as a direct child or as a descendant. The following properties apply to this formatting object:
fo:page-number[top]fo:page-numberCommon Usage: The fo:page-number formatting object is used to obtain an inline-area whose content is the page-number for the page on which the inline-area is placed. Areas: The fo:page-number formatting object generates and returns a single normal inline-area. Constraints: The child areas of this inline-area are the same as the result of formatting a result-tree fragment consisting of fo:character flow objects; one for each character in the page-number string and with only the "character" property specified. The page-number string is obtained by converting the page-number for the page on which the inline-area is placed in accordance with the number to string conversion properties of the ancestor fo:page-sequence. NOTE: Contents: EMPTY The following properties apply to this formatting object:
fo:page-number-citation[top]fo:page-number-citationCommon Usage: The fo:page-number-citation is used to reference the page-number for the page containing the first normal area returned by the cited formatting object. NOTE: Areas: The fo:page-number-citation formatting object generates and returns a single normal inline-area. Constraints: The cited page-number is the number of the page containing, as a descendant, the first normal area returned by the formatting object with an id trait matching the ref-id trait of the fo:page-number-citation (the referenced formatting object). The cited page-number string is obtained by converting the cited page-number in accordance with the number to string conversion properties of the ancestor fo:page-sequence of the referenced formatting object. NOTE: The child areas of the generated inline-area are the same as the result of formatting a result-tree fragment consisting of fo:character flow objects; one for each character in the cited page-number string and with only the "character" property specified. Contents: EMPTY The following properties apply to this formatting object:
|