The challenge for the stylesheet writer is to recognize when it is necessary to add marks or add embedding levels in the flow.
Be careful when formatting generated content, such as table of contents entries.
The sample files in Example 11-3 and Example 11-4 illustrate the importance of adding marks.
Example 11-3 formats two tables of contents, the first without protection and the second protecting the boilerplate of the entries from the arbitrary text directions of the characters in the titles. Example 11-3 Adding marksLine 01 <!ENTITY LRM "‎"> 02 <!ENTITY RLM "‏"> 03 ... 04 <block space-after=".5cm"> 05 This is a table of contents without using marks: 06 </block> 07 <xsl:for-each select="/doc/section"> 08 <block text-align-last="justify"> 09 <xsl:value-of select="position()"/>. 10 <xsl:value-of select="title"/> 11 (<xsl:value-of select="count(subsection)"/>) 12 <leader leader-pattern="dots"/> 13 <page-number-citation ref-id="{generate-id(.)}"/> 14 </block> 15 </xsl:for-each> 16 17 <block space-before="1.5cm" space-after=".5cm"> 18 This is a table of contents using marks: 19 </block> 20 <xsl:for-each select="/doc/section"> 21 <block text-align-last="justify"> 22 <xsl:value-of select="position()"/>. &LRM; 23 <xsl:apply-templates select="title"/> 24 &LRM; (<xsl:value-of select="count(subsection)"/>) 25 <leader leader-pattern="dots"/> 26 <page-number-citation ref-id="{generate-id(.)}"/> 27 </block> 28 </xsl:for-each> Example 11-4 includes titles utilizing text of different writing directions. Example 11-4 A test file with mixed character directionsLine 01 <!DOCTYPE doc [ 02 <!ENTITY hebrew-test "בדיקה 03 עברית"> 04 <!ENTITY arabic-test1 "إختبا"> 05 <!ENTITY arabic-test2 "ر عربي"> 06 <!ENTITY arabic-test "&arabic-test1;&arabic-test2;"> 07 ]> 08 <doc> 09 <section> 10 <title>English Test</title> 11 <subsection>Sub 1 in English</subsection> 12 ... 13 <subsection>Sub 15 in English</subsection> 14 </section> 15 <section> 16 <title>&hebrew-test;</title> 17 <subsection>Sub 1 in Hebrew</subsection> 18 ... 19 <subsection>Sub 14 in Hebrew</subsection> 20 </section> 21 <section> 22 <title>&arabic-test;</title> 23 <subsection>Sub 1 in Arabic</subsection> 24 ... 25 <subsection>Sub 14 in Arabic</subsection> 26 </section> 27 <section> 28 <title>Test Français</title> 29 <subsection>Sub 1 in French</subsection> 30 ... 31 <subsection>Sub 12 in French</subsection> 32 </section> The formatted result in Figure 11-2 illustrates the impact of including the marks for protection from the characters of the titles. Figure 11-2. Example of using marks
Note the behavior when the marks are not present (top rendering).
|