metanorma-iec 2.0.7 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isodoc/iec/base_convert.rb +5 -5
- data/lib/isodoc/iec/html/html_iec_titlepage.html +1 -0
- data/lib/isodoc/iec/iec.international-standard.xsl +1596 -311
- data/lib/isodoc/iec/init.rb +6 -5
- data/lib/isodoc/iec/metadata.rb +2 -2
- data/lib/isodoc/iec/presentation_xml_convert.rb +3 -3
- data/lib/isodoc/iec/word_convert.rb +3 -3
- data/lib/isodoc/iec/xref.rb +4 -0
- data/lib/metanorma/iec/biblio.rng +62 -10
- data/lib/metanorma/iec/front.rb +1 -1
- data/lib/metanorma/iec/iec.rng +1 -0
- data/lib/metanorma/iec/isodoc.rng +56 -0
- data/lib/metanorma/iec/version.rb +1 -1
- data/metanorma-iec.gemspec +3 -2
- data/spec/isodoc/blocks_spec.rb +146 -202
- data/spec/isodoc/i18n_spec.rb +22 -7
- data/spec/isodoc/iev_spec.rb +8 -8
- data/spec/isodoc/inline_spec.rb +255 -249
- data/spec/isodoc/metadata_spec.rb +9 -9
- data/spec/isodoc/postproc_spec.rb +2 -2
- data/spec/isodoc/ref_spec.rb +14 -62
- data/spec/metanorma/base_spec.rb +2 -2
- data/spec/metanorma/blocks_spec.rb +2 -2
- data/spec/metanorma/cleanup_spec.rb +1 -1
- data/spec/metanorma/iev_spec.rb +1 -1
- data/spec/metanorma/inline_spec.rb +86 -70
- data/spec/metanorma/section_spec.rb +196 -183
- data/spec/spec_helper.rb +7 -0
- metadata +4 -4
@@ -114,7 +114,13 @@
|
|
114
114
|
<xsl:call-template name="namespaceCheck"/>
|
115
115
|
<!-- https://stackoverflow.com/questions/25261949/xsl-fo-letter-spacing-with-text-align -->
|
116
116
|
<!-- https://xmlgraphics.apache.org/fop/knownissues.html -->
|
117
|
-
<fo:root
|
117
|
+
<fo:root xml:lang="{$lang}">
|
118
|
+
<xsl:variable name="root-style">
|
119
|
+
<root-style xsl:use-attribute-sets="root-style"/>
|
120
|
+
</xsl:variable>
|
121
|
+
<xsl:call-template name="insertRootStyle">
|
122
|
+
<xsl:with-param name="root-style" select="$root-style"/>
|
123
|
+
</xsl:call-template>
|
118
124
|
<fo:layout-master-set>
|
119
125
|
<!-- cover pages -->
|
120
126
|
<fo:simple-page-master master-name="cover" page-width="{$pageWidth}mm" page-height="{$pageHeight}mm">
|
@@ -930,14 +936,16 @@
|
|
930
936
|
<fo:inline keep-together.within-line="always" font-size="25pt" font-weight="bold" color="{$color_gray}" border-bottom="0.5pt solid {$color_gray}" padding-bottom="3.5mm" baseline-shift="5.5mm"><fo:leader leader-pattern="space"/><xsl:value-of select="//iec:iec-standard/iec:bibdata/iec:docidentifier[@type = 'iso' or @type = 'ISO']"/></fo:inline>
|
931
937
|
</fo:block>
|
932
938
|
<fo:block font-size="10.5pt" text-align="right" margin-top="0.5mm">
|
933
|
-
<xsl:
|
934
|
-
<xsl:
|
935
|
-
<xsl:
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
+
<xsl:call-template name="capitalize">
|
940
|
+
<xsl:with-param name="str">
|
941
|
+
<xsl:call-template name="getLocalizedString">
|
942
|
+
<xsl:with-param name="key">edition</xsl:with-param>
|
943
|
+
</xsl:call-template>
|
944
|
+
</xsl:with-param>
|
945
|
+
</xsl:call-template>
|
946
|
+
<xsl:text> </xsl:text>
|
939
947
|
<fo:inline>
|
940
|
-
<xsl:variable name="edition" select="//iec:iec-standard/iec:bibdata/iec:edition"/>
|
948
|
+
<xsl:variable name="edition" select="//iec:iec-standard/iec:bibdata/iec:edition[normalize-space(@language) = '']"/>
|
941
949
|
<xsl:value-of select="$edition"/>
|
942
950
|
<xsl:if test="not(contains($edition, '.'))">.0</xsl:if>
|
943
951
|
</fo:inline>
|
@@ -1633,6 +1641,7 @@
|
|
1633
1641
|
|
1634
1642
|
<xsl:template match="iec:p" name="paragraph">
|
1635
1643
|
<xsl:param name="inline" select="'false'"/>
|
1644
|
+
<xsl:param name="split_keep-within-line"/>
|
1636
1645
|
<xsl:variable name="previous-element" select="local-name(preceding-sibling::*[1])"/>
|
1637
1646
|
<xsl:variable name="element-name">
|
1638
1647
|
<xsl:choose>
|
@@ -1675,11 +1684,15 @@
|
|
1675
1684
|
</xsl:if>
|
1676
1685
|
|
1677
1686
|
<xsl:apply-templates select="@language"/>
|
1678
|
-
<xsl:apply-templates
|
1687
|
+
<xsl:apply-templates>
|
1688
|
+
<xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
|
1689
|
+
</xsl:apply-templates>
|
1679
1690
|
</xsl:element>
|
1680
1691
|
</xsl:when>
|
1681
1692
|
<xsl:otherwise>
|
1682
|
-
<xsl:apply-templates
|
1693
|
+
<xsl:apply-templates>
|
1694
|
+
<xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
|
1695
|
+
</xsl:apply-templates>
|
1683
1696
|
</xsl:otherwise>
|
1684
1697
|
</xsl:choose>
|
1685
1698
|
|
@@ -1922,7 +1935,9 @@
|
|
1922
1935
|
</xsl:copy>
|
1923
1936
|
</xsl:template> -->
|
1924
1937
|
|
1925
|
-
<xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:variable name="
|
1938
|
+
<xsl:param name="svg_images"/><xsl:variable name="images" select="document($svg_images)"/><xsl:param name="basepath"/><xsl:param name="external_index"/><xsl:param name="syntax-highlight">false</xsl:param><xsl:param name="add_math_as_text">true</xsl:param><xsl:param name="table_if">false</xsl:param><xsl:param name="table_widths"/><xsl:variable name="table_widths_from_if" select="xalan:nodeset($table_widths)"/><xsl:param name="table_if_debug">false</xsl:param><xsl:variable name="isGenerateTableIF_">
|
1939
|
+
false
|
1940
|
+
</xsl:variable><xsl:variable name="isGenerateTableIF" select="normalize-space($isGenerateTableIF_)"/><xsl:variable name="lang">
|
1926
1941
|
<xsl:call-template name="getLang"/>
|
1927
1942
|
</xsl:variable><xsl:variable name="pageWidth_">
|
1928
1943
|
210
|
@@ -1937,20 +1952,7 @@
|
|
1937
1952
|
</xsl:variable><xsl:variable name="marginTop" select="normalize-space($marginTop_)"/><xsl:variable name="marginBottom_">
|
1938
1953
|
15
|
1939
1954
|
</xsl:variable><xsl:variable name="marginBottom" select="normalize-space($marginBottom_)"/><xsl:variable name="titles_">
|
1940
|
-
|
1941
|
-
<title-edition lang="en">
|
1942
|
-
|
1943
|
-
<xsl:text>Edition </xsl:text>
|
1944
|
-
|
1945
|
-
</title-edition>
|
1946
|
-
|
1947
|
-
<title-edition lang="fr">
|
1948
|
-
<xsl:text>Édition </xsl:text>
|
1949
|
-
</title-edition>
|
1950
1955
|
|
1951
|
-
<title-edition lang="ru">
|
1952
|
-
<xsl:text>Издание </xsl:text>
|
1953
|
-
</title-edition>
|
1954
1956
|
|
1955
1957
|
<!-- These titles of Table of contents renders different than determined in localized-strings -->
|
1956
1958
|
<title-toc lang="en">
|
@@ -2035,7 +2037,7 @@
|
|
2035
2037
|
</xsl:variable><xsl:variable name="bibdata">
|
2036
2038
|
<xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/>
|
2037
2039
|
<xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/>
|
2038
|
-
</xsl:variable><xsl:variable name="linebreak">
</xsl:variable><xsl:variable name="tab_zh"> </xsl:variable><xsl:variable name="non_breaking_hyphen">‑</xsl:variable><xsl:variable name="thin_space"> </xsl:variable><xsl:variable name="zero_width_space"></xsl:variable><xsl:variable name="en_dash">–</xsl:variable><xsl:template name="getTitle">
|
2040
|
+
</xsl:variable><xsl:variable name="linebreak">
</xsl:variable><xsl:variable name="tab_zh"> </xsl:variable><xsl:variable name="non_breaking_hyphen">‑</xsl:variable><xsl:variable name="thin_space"> </xsl:variable><xsl:variable name="zero_width_space"></xsl:variable><xsl:variable name="hair_space"> </xsl:variable><xsl:variable name="en_dash">–</xsl:variable><xsl:template name="getTitle">
|
2039
2041
|
<xsl:param name="name"/>
|
2040
2042
|
<xsl:param name="lang"/>
|
2041
2043
|
<xsl:variable name="lang_">
|
@@ -2078,7 +2080,30 @@
|
|
2078
2080
|
|
2079
2081
|
|
2080
2082
|
|
2081
|
-
</xsl:attribute-set><xsl:
|
2083
|
+
</xsl:attribute-set><xsl:template name="insertRootStyle">
|
2084
|
+
<xsl:param name="root-style"/>
|
2085
|
+
<xsl:variable name="root-style_" select="xalan:nodeset($root-style)"/>
|
2086
|
+
|
2087
|
+
<xsl:variable name="additional_fonts_">
|
2088
|
+
<xsl:for-each select="//*[contains(local-name(), '-standard')][1]/*[local-name() = 'misc-container']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value'] | //*[contains(local-name(), '-standard')][1]/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'fonts']/*[local-name() = 'value']">
|
2089
|
+
<xsl:value-of select="."/><xsl:if test="position() != last()">, </xsl:if>
|
2090
|
+
</xsl:for-each>
|
2091
|
+
</xsl:variable>
|
2092
|
+
<xsl:variable name="additional_fonts" select="normalize-space($additional_fonts_)"/>
|
2093
|
+
|
2094
|
+
<xsl:for-each select="$root-style_/root-style/@*">
|
2095
|
+
<xsl:choose>
|
2096
|
+
<xsl:when test="local-name() = 'font-family' and $additional_fonts != ''">
|
2097
|
+
<xsl:attribute name="{local-name()}">
|
2098
|
+
<xsl:value-of select="."/>, <xsl:value-of select="$additional_fonts"/>
|
2099
|
+
</xsl:attribute>
|
2100
|
+
</xsl:when>
|
2101
|
+
<xsl:otherwise>
|
2102
|
+
<xsl:copy-of select="."/>
|
2103
|
+
</xsl:otherwise>
|
2104
|
+
</xsl:choose>
|
2105
|
+
</xsl:for-each>
|
2106
|
+
</xsl:template><xsl:attribute-set name="copyright-statement-style">
|
2082
2107
|
|
2083
2108
|
</xsl:attribute-set><xsl:attribute-set name="copyright-statement-title-style">
|
2084
2109
|
|
@@ -2136,7 +2161,6 @@
|
|
2136
2161
|
|
2137
2162
|
|
2138
2163
|
</xsl:attribute-set><xsl:attribute-set name="sourcecode-container-style">
|
2139
|
-
<xsl:attribute name="margin-left">0mm</xsl:attribute>
|
2140
2164
|
|
2141
2165
|
</xsl:attribute-set><xsl:attribute-set name="sourcecode-style">
|
2142
2166
|
<xsl:attribute name="white-space">pre</xsl:attribute>
|
@@ -2224,6 +2248,7 @@
|
|
2224
2248
|
<xsl:attribute name="margin-left">10mm</xsl:attribute>
|
2225
2249
|
|
2226
2250
|
|
2251
|
+
|
2227
2252
|
</xsl:attribute-set><xsl:attribute-set name="example-name-style">
|
2228
2253
|
|
2229
2254
|
|
@@ -2382,6 +2407,7 @@
|
|
2382
2407
|
<xsl:attribute name="font-weight">bold</xsl:attribute>
|
2383
2408
|
<xsl:attribute name="border">solid black 1pt</xsl:attribute>
|
2384
2409
|
<xsl:attribute name="padding-left">1mm</xsl:attribute>
|
2410
|
+
<xsl:attribute name="padding-right">1mm</xsl:attribute>
|
2385
2411
|
<xsl:attribute name="display-align">center</xsl:attribute>
|
2386
2412
|
|
2387
2413
|
|
@@ -2404,6 +2430,7 @@
|
|
2404
2430
|
<xsl:attribute name="display-align">center</xsl:attribute>
|
2405
2431
|
<xsl:attribute name="border">solid black 1pt</xsl:attribute>
|
2406
2432
|
<xsl:attribute name="padding-left">1mm</xsl:attribute>
|
2433
|
+
<xsl:attribute name="padding-right">1mm</xsl:attribute>
|
2407
2434
|
|
2408
2435
|
|
2409
2436
|
|
@@ -2507,7 +2534,8 @@
|
|
2507
2534
|
</xsl:attribute-set><xsl:attribute-set name="dt-row-style">
|
2508
2535
|
|
2509
2536
|
|
2510
|
-
</xsl:attribute-set><xsl:attribute-set name="dt-style">
|
2537
|
+
</xsl:attribute-set><xsl:attribute-set name="dt-cell-style">
|
2538
|
+
</xsl:attribute-set><xsl:attribute-set name="dt-block-style">
|
2511
2539
|
<xsl:attribute name="margin-top">6pt</xsl:attribute>
|
2512
2540
|
|
2513
2541
|
|
@@ -2521,6 +2549,8 @@
|
|
2521
2549
|
|
2522
2550
|
|
2523
2551
|
|
2552
|
+
</xsl:attribute-set><xsl:attribute-set name="dd-cell-style">
|
2553
|
+
<xsl:attribute name="padding-left">2mm</xsl:attribute>
|
2524
2554
|
</xsl:attribute-set><xsl:attribute-set name="appendix-style">
|
2525
2555
|
|
2526
2556
|
|
@@ -2620,7 +2650,7 @@
|
|
2620
2650
|
|
2621
2651
|
|
2622
2652
|
|
2623
|
-
</xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
|
2653
|
+
</xsl:attribute-set><xsl:attribute-set name="termnote-name-style">
|
2624
2654
|
|
2625
2655
|
|
2626
2656
|
|
@@ -3343,22 +3373,32 @@
|
|
3343
3373
|
<xsl:sort select="@displayorder" data-type="number"/>
|
3344
3374
|
<xsl:apply-templates select="."/>
|
3345
3375
|
</xsl:for-each>
|
3346
|
-
</xsl:template><xsl:variable name="
|
3347
|
-
|
3348
|
-
|
3349
|
-
|
3350
|
-
|
3351
|
-
|
3352
|
-
|
3376
|
+
</xsl:template><xsl:variable name="tag_fo_inline_keep-together_within-line_open">###fo:inline keep-together_within-line###</xsl:variable><xsl:variable name="tag_fo_inline_keep-together_within-line_close">###/fo:inline keep-together_within-line###</xsl:variable><xsl:template match="text()" name="text">
|
3377
|
+
|
3378
|
+
<xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
|
3379
|
+
<xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_fo_inline_keep-together_within-line_open,'$1',$tag_fo_inline_keep-together_within-line_close))"/>
|
3380
|
+
<xsl:call-template name="replace_fo_inline_tags">
|
3381
|
+
<xsl:with-param name="tag_open" select="$tag_fo_inline_keep-together_within-line_open"/>
|
3382
|
+
<xsl:with-param name="tag_close" select="$tag_fo_inline_keep-together_within-line_close"/>
|
3383
|
+
<xsl:with-param name="text" select="$text"/>
|
3384
|
+
</xsl:call-template>
|
3385
|
+
|
3386
|
+
</xsl:template><xsl:template name="replace_fo_inline_tags">
|
3387
|
+
<xsl:param name="tag_open"/>
|
3388
|
+
<xsl:param name="tag_close"/>
|
3353
3389
|
<xsl:param name="text"/>
|
3354
3390
|
<xsl:choose>
|
3355
3391
|
<xsl:when test="contains($text, $tag_open)">
|
3356
3392
|
<xsl:value-of select="substring-before($text, $tag_open)"/>
|
3357
|
-
<xsl:text disable-output-escaping="yes"><fo:inline keep-together.within-line="always"></xsl:text>
|
3393
|
+
<!-- <xsl:text disable-output-escaping="yes"><fo:inline keep-together.within-line="always"></xsl:text> -->
|
3358
3394
|
<xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
|
3359
|
-
<
|
3360
|
-
|
3361
|
-
|
3395
|
+
<fo:inline keep-together.within-line="always">
|
3396
|
+
<xsl:value-of select="substring-before($text_after, $tag_close)"/>
|
3397
|
+
</fo:inline>
|
3398
|
+
<!-- <xsl:text disable-output-escaping="yes"></fo:inline></xsl:text> -->
|
3399
|
+
<xsl:call-template name="replace_fo_inline_tags">
|
3400
|
+
<xsl:with-param name="tag_open" select="$tag_open"/>
|
3401
|
+
<xsl:with-param name="tag_close" select="$tag_close"/>
|
3362
3402
|
<xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
|
3363
3403
|
</xsl:call-template>
|
3364
3404
|
</xsl:when>
|
@@ -3366,6 +3406,39 @@
|
|
3366
3406
|
</xsl:choose>
|
3367
3407
|
</xsl:template><xsl:template match="*[local-name()='br']">
|
3368
3408
|
<xsl:value-of select="$linebreak"/>
|
3409
|
+
</xsl:template><xsl:template match="*[local-name() = 'keep-together_within-line']">
|
3410
|
+
<xsl:param name="split_keep-within-line"/>
|
3411
|
+
|
3412
|
+
<!-- <fo:inline>split_keep-within-line='<xsl:value-of select="$split_keep-within-line"/>'</fo:inline> -->
|
3413
|
+
<xsl:choose>
|
3414
|
+
|
3415
|
+
<xsl:when test="normalize-space($split_keep-within-line) = 'true'">
|
3416
|
+
<xsl:variable name="sep">_</xsl:variable>
|
3417
|
+
<xsl:variable name="items">
|
3418
|
+
<xsl:call-template name="split">
|
3419
|
+
<xsl:with-param name="pText" select="."/>
|
3420
|
+
<xsl:with-param name="sep" select="$sep"/>
|
3421
|
+
<xsl:with-param name="normalize-space">false</xsl:with-param>
|
3422
|
+
<xsl:with-param name="keep_sep">true</xsl:with-param>
|
3423
|
+
</xsl:call-template>
|
3424
|
+
</xsl:variable>
|
3425
|
+
<xsl:for-each select="xalan:nodeset($items)/item">
|
3426
|
+
<xsl:choose>
|
3427
|
+
<xsl:when test=". = $sep">
|
3428
|
+
<xsl:value-of select="$sep"/><xsl:value-of select="$zero_width_space"/>
|
3429
|
+
</xsl:when>
|
3430
|
+
<xsl:otherwise>
|
3431
|
+
<fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
|
3432
|
+
</xsl:otherwise>
|
3433
|
+
</xsl:choose>
|
3434
|
+
</xsl:for-each>
|
3435
|
+
</xsl:when>
|
3436
|
+
|
3437
|
+
<xsl:otherwise>
|
3438
|
+
<fo:inline keep-together.within-line="always"><xsl:apply-templates/></fo:inline>
|
3439
|
+
</xsl:otherwise>
|
3440
|
+
|
3441
|
+
</xsl:choose>
|
3369
3442
|
</xsl:template><xsl:template match="*[local-name()='copyright-statement']">
|
3370
3443
|
<fo:block xsl:use-attribute-sets="copyright-statement-style">
|
3371
3444
|
<xsl:apply-templates/>
|
@@ -3434,8 +3507,23 @@
|
|
3434
3507
|
</fo:block>
|
3435
3508
|
|
3436
3509
|
</xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1">
|
3437
|
-
|
3438
|
-
|
3510
|
+
<xsl:choose>
|
3511
|
+
<xsl:when test="parent::*[local-name() = 'keep-together_within-line']">
|
3512
|
+
<xsl:value-of select="."/>
|
3513
|
+
</xsl:when>
|
3514
|
+
<xsl:otherwise>
|
3515
|
+
<xsl:call-template name="addZeroWidthSpacesToTextNodes"/>
|
3516
|
+
</xsl:otherwise>
|
3517
|
+
</xsl:choose>
|
3518
|
+
</xsl:template><xsl:template name="addZeroWidthSpacesToTextNodes">
|
3519
|
+
<xsl:variable name="text"><text><xsl:call-template name="text"/></text></xsl:variable>
|
3520
|
+
<!-- <xsl:copy-of select="$text"/> -->
|
3521
|
+
<xsl:for-each select="xalan:nodeset($text)/text/node()">
|
3522
|
+
<xsl:choose>
|
3523
|
+
<xsl:when test="self::text()"><xsl:call-template name="add-zero-spaces-java"/></xsl:when>
|
3524
|
+
<xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
|
3525
|
+
</xsl:choose>
|
3526
|
+
</xsl:for-each>
|
3439
3527
|
</xsl:template><xsl:template match="*[local-name()='table']" name="table">
|
3440
3528
|
|
3441
3529
|
<xsl:variable name="table-preamble">
|
@@ -3445,9 +3533,14 @@
|
|
3445
3533
|
|
3446
3534
|
<xsl:variable name="table">
|
3447
3535
|
|
3448
|
-
<xsl:variable name="simple-table">
|
3449
|
-
<xsl:call-template name="getSimpleTable"
|
3536
|
+
<xsl:variable name="simple-table">
|
3537
|
+
<xsl:call-template name="getSimpleTable">
|
3538
|
+
<xsl:with-param name="id" select="@id"/>
|
3539
|
+
</xsl:call-template>
|
3450
3540
|
</xsl:variable>
|
3541
|
+
<!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
|
3542
|
+
|
3543
|
+
<!-- simple-table=<xsl:copy-of select="$simple-table"/> -->
|
3451
3544
|
|
3452
3545
|
|
3453
3546
|
<!-- Display table's name before table as standalone block -->
|
@@ -3470,7 +3563,23 @@
|
|
3470
3563
|
</xsl:call-template>
|
3471
3564
|
</xsl:if>
|
3472
3565
|
</xsl:variable>
|
3473
|
-
<!--
|
3566
|
+
<!-- <xsl:variable name="colwidths" select="xalan:nodeset($colwidths_)"/> -->
|
3567
|
+
|
3568
|
+
<!-- DEBUG -->
|
3569
|
+
<xsl:if test="$table_if_debug = 'true'">
|
3570
|
+
<fo:block font-size="60%">
|
3571
|
+
<xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
|
3572
|
+
</fo:block>
|
3573
|
+
</xsl:if>
|
3574
|
+
|
3575
|
+
|
3576
|
+
<!-- <xsl:copy-of select="$colwidths"/> -->
|
3577
|
+
|
3578
|
+
<!-- <xsl:text disable-output-escaping="yes"><!- -</xsl:text>
|
3579
|
+
DEBUG
|
3580
|
+
colwidths=<xsl:copy-of select="$colwidths"/>
|
3581
|
+
<xsl:text disable-output-escaping="yes">- -></xsl:text> -->
|
3582
|
+
|
3474
3583
|
|
3475
3584
|
|
3476
3585
|
<xsl:variable name="margin-side">
|
@@ -3541,9 +3650,17 @@
|
|
3541
3650
|
</xsl:element>
|
3542
3651
|
</xsl:variable>
|
3543
3652
|
|
3653
|
+
<xsl:if test="$isGenerateTableIF = 'true'">
|
3654
|
+
<!-- to determine start of table -->
|
3655
|
+
<fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
|
3656
|
+
</xsl:if>
|
3544
3657
|
|
3545
3658
|
<fo:table id="{@id}">
|
3546
3659
|
|
3660
|
+
<xsl:if test="$isGenerateTableIF = 'true'">
|
3661
|
+
<xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
|
3662
|
+
</xsl:if>
|
3663
|
+
|
3547
3664
|
<xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
|
3548
3665
|
<xsl:attribute name="{local-name()}">
|
3549
3666
|
<xsl:value-of select="."/>
|
@@ -3557,31 +3674,47 @@
|
|
3557
3674
|
|
3558
3675
|
|
3559
3676
|
<xsl:choose>
|
3560
|
-
<xsl:when test="
|
3561
|
-
|
3562
|
-
|
3563
|
-
|
3677
|
+
<xsl:when test="$isGenerateTableIF = 'true'">
|
3678
|
+
<!-- generate IF for table widths -->
|
3679
|
+
<!-- example:
|
3680
|
+
<tr>
|
3681
|
+
<td valign="top" align="left" id="tab-symdu_1_1">
|
3682
|
+
<p>Symbol</p>
|
3683
|
+
<word id="tab-symdu_1_1_word_1">Symbol</word>
|
3684
|
+
</td>
|
3685
|
+
<td valign="top" align="left" id="tab-symdu_1_2">
|
3686
|
+
<p>Description</p>
|
3687
|
+
<word id="tab-symdu_1_2_word_1">Description</word>
|
3688
|
+
</td>
|
3689
|
+
</tr>
|
3690
|
+
-->
|
3691
|
+
<xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if"/>
|
3692
|
+
|
3564
3693
|
</xsl:when>
|
3565
3694
|
<xsl:otherwise>
|
3566
|
-
<xsl:for-each select="xalan:nodeset($colwidths)//column">
|
3567
|
-
<xsl:choose>
|
3568
|
-
<xsl:when test=". = 1 or . = 0">
|
3569
|
-
<fo:table-column column-width="proportional-column-width(2)"/>
|
3570
|
-
</xsl:when>
|
3571
|
-
<xsl:otherwise>
|
3572
|
-
<fo:table-column column-width="proportional-column-width({.})"/>
|
3573
|
-
</xsl:otherwise>
|
3574
|
-
</xsl:choose>
|
3575
|
-
</xsl:for-each>
|
3576
|
-
</xsl:otherwise>
|
3577
|
-
</xsl:choose>
|
3578
3695
|
|
3579
|
-
|
3580
|
-
|
3581
|
-
|
3582
|
-
|
3583
|
-
|
3584
|
-
|
3696
|
+
<xsl:choose>
|
3697
|
+
<xsl:when test="*[local-name()='colgroup']/*[local-name()='col']">
|
3698
|
+
<xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']">
|
3699
|
+
<fo:table-column column-width="{@width}"/>
|
3700
|
+
</xsl:for-each>
|
3701
|
+
</xsl:when>
|
3702
|
+
<xsl:otherwise>
|
3703
|
+
<xsl:call-template name="insertTableColumnWidth">
|
3704
|
+
<xsl:with-param name="colwidths" select="$colwidths"/>
|
3705
|
+
</xsl:call-template>
|
3706
|
+
</xsl:otherwise>
|
3707
|
+
</xsl:choose>
|
3708
|
+
|
3709
|
+
<xsl:choose>
|
3710
|
+
<xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']">
|
3711
|
+
<xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/>
|
3712
|
+
</xsl:when>
|
3713
|
+
<xsl:otherwise>
|
3714
|
+
<xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer and note that renders separaterely -->
|
3715
|
+
</xsl:otherwise>
|
3716
|
+
</xsl:choose>
|
3717
|
+
|
3585
3718
|
</xsl:otherwise>
|
3586
3719
|
</xsl:choose>
|
3587
3720
|
|
@@ -3684,11 +3817,22 @@
|
|
3684
3817
|
<xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
|
3685
3818
|
<xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
|
3686
3819
|
</xsl:template><xsl:template name="calculate-column-widths">
|
3820
|
+
<xsl:param name="table"/>
|
3821
|
+
<xsl:param name="cols-count"/>
|
3822
|
+
|
3823
|
+
<xsl:call-template name="calculate-column-widths-proportional">
|
3824
|
+
<xsl:with-param name="cols-count" select="$cols-count"/>
|
3825
|
+
<xsl:with-param name="table" select="$table"/>
|
3826
|
+
</xsl:call-template>
|
3827
|
+
|
3828
|
+
</xsl:template><xsl:template name="calculate-column-widths-proportional">
|
3687
3829
|
<xsl:param name="table"/>
|
3688
3830
|
<xsl:param name="cols-count"/>
|
3689
3831
|
<xsl:param name="curr-col" select="1"/>
|
3690
3832
|
<xsl:param name="width" select="0"/>
|
3691
3833
|
|
3834
|
+
<!-- table=<xsl:copy-of select="$table"/> -->
|
3835
|
+
|
3692
3836
|
<xsl:if test="$curr-col <= $cols-count">
|
3693
3837
|
<xsl:variable name="widths">
|
3694
3838
|
<xsl:choose>
|
@@ -3726,16 +3870,22 @@
|
|
3726
3870
|
</xsl:for-each>
|
3727
3871
|
</xsl:when>
|
3728
3872
|
<xsl:otherwise>
|
3729
|
-
<xsl:
|
3873
|
+
<!-- <curr_col><xsl:value-of select="$curr-col"/></curr_col> -->
|
3874
|
+
|
3875
|
+
<!-- <table><xsl:copy-of select="$table"/></table>
|
3876
|
+
-->
|
3877
|
+
<xsl:for-each select="xalan:nodeset($table)/*/*[local-name()='tr']">
|
3730
3878
|
<xsl:variable name="td_text">
|
3731
3879
|
<xsl:apply-templates select="td[$curr-col]" mode="td_text"/>
|
3732
3880
|
</xsl:variable>
|
3881
|
+
<!-- <td_text><xsl:value-of select="$td_text"/></td_text> -->
|
3733
3882
|
<xsl:variable name="words">
|
3734
3883
|
<xsl:variable name="string_with_added_zerospaces">
|
3735
3884
|
<xsl:call-template name="add-zero-spaces-java">
|
3736
3885
|
<xsl:with-param name="text" select="$td_text"/>
|
3737
3886
|
</xsl:call-template>
|
3738
3887
|
</xsl:variable>
|
3888
|
+
<!-- <xsl:message>string_with_added_zerospaces=<xsl:value-of select="$string_with_added_zerospaces"/></xsl:message> -->
|
3739
3889
|
<xsl:call-template name="tokenize">
|
3740
3890
|
<!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', ' ')"/> -->
|
3741
3891
|
<!-- 2009 thinspace -->
|
@@ -3743,11 +3893,13 @@
|
|
3743
3893
|
<xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
|
3744
3894
|
</xsl:call-template>
|
3745
3895
|
</xsl:variable>
|
3896
|
+
<!-- words=<xsl:copy-of select="$words"/> -->
|
3746
3897
|
<xsl:variable name="max_length">
|
3747
3898
|
<xsl:call-template name="max_length">
|
3748
3899
|
<xsl:with-param name="words" select="xalan:nodeset($words)"/>
|
3749
3900
|
</xsl:call-template>
|
3750
3901
|
</xsl:variable>
|
3902
|
+
<!-- <xsl:message>max_length=<xsl:value-of select="$max_length"/></xsl:message> -->
|
3751
3903
|
<width>
|
3752
3904
|
<xsl:variable name="divider">
|
3753
3905
|
<xsl:choose>
|
@@ -3766,6 +3918,8 @@
|
|
3766
3918
|
</xsl:choose>
|
3767
3919
|
</xsl:variable>
|
3768
3920
|
|
3921
|
+
<!-- widths=<xsl:copy-of select="$widths"/> -->
|
3922
|
+
|
3769
3923
|
<column>
|
3770
3924
|
<xsl:for-each select="xalan:nodeset($widths)//width">
|
3771
3925
|
<xsl:sort select="." data-type="number" order="descending"/>
|
@@ -3774,29 +3928,327 @@
|
|
3774
3928
|
</xsl:if>
|
3775
3929
|
</xsl:for-each>
|
3776
3930
|
</column>
|
3777
|
-
<xsl:call-template name="calculate-column-widths">
|
3931
|
+
<xsl:call-template name="calculate-column-widths-proportional">
|
3778
3932
|
<xsl:with-param name="cols-count" select="$cols-count"/>
|
3779
3933
|
<xsl:with-param name="curr-col" select="$curr-col +1"/>
|
3780
3934
|
<xsl:with-param name="table" select="$table"/>
|
3781
3935
|
</xsl:call-template>
|
3782
3936
|
</xsl:if>
|
3937
|
+
</xsl:template><xsl:template match="*[@keep-together.within-line or local-name() = 'keep-together_within-line']/text()" priority="2" mode="td_text">
|
3938
|
+
<!-- <xsl:message>DEBUG t1=<xsl:value-of select="."/></xsl:message>
|
3939
|
+
<xsl:message>DEBUG t2=<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/></xsl:message> -->
|
3940
|
+
<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'.','X')"/>
|
3941
|
+
|
3942
|
+
<!-- if all capitals english letters or digits -->
|
3943
|
+
<xsl:if test="normalize-space(translate(., concat($upper,'0123456789'), '')) = ''">
|
3944
|
+
<xsl:call-template name="repeat">
|
3945
|
+
<xsl:with-param name="char" select="'X'"/>
|
3946
|
+
<xsl:with-param name="count" select="string-length(normalize-space(.)) * 0.5"/>
|
3947
|
+
</xsl:call-template>
|
3948
|
+
</xsl:if>
|
3783
3949
|
</xsl:template><xsl:template match="text()" mode="td_text">
|
3784
3950
|
<xsl:value-of select="translate(., $zero_width_space, ' ')"/><xsl:text> </xsl:text>
|
3785
3951
|
</xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
|
3786
3952
|
<xsl:value-of select="*[local-name()='origin']/@citeas"/>
|
3787
3953
|
</xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
|
3788
3954
|
<xsl:value-of select="@target"/>
|
3789
|
-
</xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
|
3790
|
-
<xsl:
|
3791
|
-
<xsl:
|
3792
|
-
<xsl:
|
3793
|
-
<xsl:
|
3955
|
+
</xsl:template><xsl:template match="*[local-name()='math']" mode="td_text" name="math_length">
|
3956
|
+
<xsl:if test="$isGenerateTableIF = 'false'">
|
3957
|
+
<xsl:variable name="mathml_">
|
3958
|
+
<xsl:for-each select="*">
|
3959
|
+
<xsl:if test="local-name() != 'unit' and local-name() != 'prefix' and local-name() != 'dimension' and local-name() != 'quantity'">
|
3960
|
+
<xsl:copy-of select="."/>
|
3961
|
+
</xsl:if>
|
3962
|
+
</xsl:for-each>
|
3963
|
+
</xsl:variable>
|
3964
|
+
<xsl:variable name="mathml" select="xalan:nodeset($mathml_)"/>
|
3965
|
+
|
3966
|
+
<xsl:variable name="math_text">
|
3967
|
+
<xsl:value-of select="normalize-space($mathml)"/>
|
3968
|
+
<xsl:for-each select="$mathml//@open"><xsl:value-of select="."/></xsl:for-each>
|
3969
|
+
<xsl:for-each select="$mathml//@close"><xsl:value-of select="."/></xsl:for-each>
|
3970
|
+
</xsl:variable>
|
3971
|
+
<xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
|
3972
|
+
</xsl:if>
|
3973
|
+
</xsl:template><xsl:template name="calculate-column-widths-autolayout-algorithm">
|
3974
|
+
<xsl:param name="table"/>
|
3975
|
+
<xsl:param name="if">false</xsl:param> <!-- via intermediate format -->
|
3976
|
+
|
3977
|
+
<!-- The algorithm uses two passes through the table data and scales linearly with the size of the table -->
|
3978
|
+
|
3979
|
+
<!-- In the first pass, line wrapping is disabled, and the user agent keeps track of the minimum and maximum width of each cell. -->
|
3980
|
+
|
3981
|
+
<!-- Since line wrap has been disabled, paragraphs are treated as long lines unless broken by BR elements. -->
|
3982
|
+
|
3983
|
+
<!-- get current table id -->
|
3984
|
+
<xsl:variable name="table_id" select="@id"/>
|
3985
|
+
<!-- find table by id in the file 'table_widths' -->
|
3986
|
+
<xsl:variable name="table-if_" select="$table_widths_from_if//table[@id = $table_id]"/>
|
3987
|
+
<xsl:variable name="table-if" select="xalan:nodeset($table-if_)"/>
|
3988
|
+
|
3989
|
+
|
3990
|
+
<!-- table='<xsl:copy-of select="$table"/>' -->
|
3991
|
+
<!-- table_id='<xsl:value-of select="$table_id"/>\ -->
|
3992
|
+
<!-- table-if='<xsl:copy-of select="$table-if"/>' -->
|
3993
|
+
<!-- table_widths_from_if='<xsl:copy-of select="$table_widths_from_if"/>' -->
|
3994
|
+
|
3995
|
+
<xsl:variable name="table_with_cell_widths_">
|
3996
|
+
<xsl:choose>
|
3997
|
+
<xsl:when test="$if = 'true' and normalize-space($table-if) != ''"> <!-- if we read column's width from IF and there is table in IF -->
|
3998
|
+
|
3999
|
+
<!-- Example: <column>10</column>
|
4000
|
+
<column>11</column>
|
4001
|
+
-->
|
4002
|
+
<xsl:apply-templates select="$table-if" mode="determine_cell_widths-if"/>
|
4003
|
+
</xsl:when>
|
4004
|
+
<xsl:otherwise>
|
4005
|
+
<xsl:apply-templates select="xalan:nodeset($table)" mode="determine_cell_widths"/>
|
4006
|
+
</xsl:otherwise>
|
4007
|
+
</xsl:choose>
|
4008
|
+
</xsl:variable>
|
4009
|
+
<xsl:variable name="table_with_cell_widths" select="xalan:nodeset($table_with_cell_widths_)"/>
|
4010
|
+
|
4011
|
+
<xsl:if test="$table_if_debug = 'true'">
|
4012
|
+
<xsl:copy-of select="$table_with_cell_widths"/>
|
4013
|
+
</xsl:if>
|
4014
|
+
|
4015
|
+
|
4016
|
+
<!-- The minimum and maximum cell widths are then used to determine the corresponding minimum and maximum widths for the columns. -->
|
4017
|
+
|
4018
|
+
<xsl:variable name="column_widths_">
|
4019
|
+
<!-- iteration of columns -->
|
4020
|
+
<xsl:for-each select="$table_with_cell_widths//tr[1]/td">
|
4021
|
+
<xsl:variable name="pos" select="position()"/>
|
4022
|
+
<column>
|
4023
|
+
<xsl:attribute name="width_max">
|
4024
|
+
<xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_max">
|
4025
|
+
<xsl:sort select="." data-type="number" order="descending"/>
|
4026
|
+
<xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
|
4027
|
+
</xsl:for-each>
|
4028
|
+
</xsl:attribute>
|
4029
|
+
<xsl:attribute name="width_min">
|
4030
|
+
<xsl:for-each select="ancestor::tbody//tr/td[$pos]/@width_min">
|
4031
|
+
<xsl:sort select="." data-type="number" order="descending"/>
|
4032
|
+
<xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
|
4033
|
+
</xsl:for-each>
|
4034
|
+
</xsl:attribute>
|
4035
|
+
</column>
|
4036
|
+
</xsl:for-each>
|
4037
|
+
</xsl:variable>
|
4038
|
+
<xsl:variable name="column_widths" select="xalan:nodeset($column_widths_)"/>
|
4039
|
+
|
4040
|
+
<!-- <column_widths>
|
4041
|
+
<xsl:copy-of select="$column_widths"/>
|
4042
|
+
</column_widths> -->
|
4043
|
+
|
4044
|
+
<!-- These in turn, are used to find the minimum and maximum width for the table. -->
|
4045
|
+
<xsl:variable name="table_widths_">
|
4046
|
+
<table>
|
4047
|
+
<xsl:attribute name="width_max">
|
4048
|
+
<xsl:value-of select="sum($column_widths/column/@width_max)"/>
|
4049
|
+
</xsl:attribute>
|
4050
|
+
<xsl:attribute name="width_min">
|
4051
|
+
<xsl:value-of select="sum($column_widths/column/@width_min)"/>
|
4052
|
+
</xsl:attribute>
|
4053
|
+
</table>
|
4054
|
+
</xsl:variable>
|
4055
|
+
<xsl:variable name="table_widths" select="xalan:nodeset($table_widths_)"/>
|
4056
|
+
|
4057
|
+
<xsl:variable name="page_width">
|
4058
|
+
<xsl:choose>
|
4059
|
+
<xsl:when test="$if = 'true'"><xsl:value-of select="$table-if/@page-width"/></xsl:when>
|
4060
|
+
<xsl:otherwise>75</xsl:otherwise>
|
4061
|
+
</xsl:choose>
|
4062
|
+
</xsl:variable>
|
4063
|
+
|
4064
|
+
<xsl:if test="$table_if_debug = 'true'">
|
4065
|
+
<table_width>
|
4066
|
+
<xsl:copy-of select="$table_widths"/>
|
4067
|
+
</table_width>
|
4068
|
+
<!-- <debug>$table_widths/@width_min=<xsl:value-of select="$table_widths/table/@width_min"/></debug>
|
4069
|
+
<debug>$table_widths/@width_max=<xsl:value-of select="$table_widths/table/@width_max"/></debug>
|
4070
|
+
-->
|
4071
|
+
<debug>$page_width=<xsl:value-of select="$page_width"/></debug>
|
4072
|
+
</xsl:if>
|
4073
|
+
|
4074
|
+
|
4075
|
+
<!-- There are three cases: -->
|
4076
|
+
<xsl:choose>
|
4077
|
+
<!-- 1. The minimum table width is equal to or wider than the available space -->
|
4078
|
+
<xsl:when test="$table_widths/table/@width_min >= $page_width and 1 = 2"> <!-- this condition isn't working see case 3 below -->
|
4079
|
+
<!-- call old algorithm -->
|
4080
|
+
<case1/>
|
4081
|
+
<xsl:variable name="cols-count" select="count(xalan:nodeset($table)/*/tr[1]/td)"/>
|
4082
|
+
<xsl:call-template name="calculate-column-widths-proportional">
|
4083
|
+
<xsl:with-param name="cols-count" select="$cols-count"/>
|
4084
|
+
<xsl:with-param name="table" select="$table"/>
|
4085
|
+
</xsl:call-template>
|
4086
|
+
</xsl:when>
|
4087
|
+
<!-- 2. The maximum table width fits within the available space. In this case, set the columns to their maximum widths. -->
|
4088
|
+
<xsl:when test="$table_widths/table/@width_max <= $page_width">
|
4089
|
+
<case2/>
|
4090
|
+
<autolayout/>
|
4091
|
+
<xsl:for-each select="$column_widths/column/@width_max">
|
4092
|
+
<column divider="100"><xsl:value-of select="."/></column>
|
4093
|
+
</xsl:for-each>
|
4094
|
+
</xsl:when>
|
4095
|
+
<!-- 3. The maximum width of the table is greater than the available space, but the minimum table width is smaller.
|
4096
|
+
In this case, find the difference between the available space and the minimum table width, lets call it W.
|
4097
|
+
Lets also call D the difference between maximum and minimum width of the table.
|
4098
|
+
For each column, let d be the difference between maximum and minimum width of that column.
|
4099
|
+
Now set the column's width to the minimum width plus d times W over D.
|
4100
|
+
This makes columns with large differences between minimum and maximum widths wider than columns with smaller differences. -->
|
4101
|
+
<xsl:when test="($table_widths/table/@width_max > $page_width and $table_widths/table/@width_min < $page_width) or ($table_widths/table/@width_min >= $page_width)">
|
4102
|
+
<!-- difference between the available space and the minimum table width -->
|
4103
|
+
<xsl:variable name="W" select="$page_width - $table_widths/table/@width_min"/>
|
4104
|
+
<W><xsl:value-of select="$W"/></W>
|
4105
|
+
<!-- difference between maximum and minimum width of the table -->
|
4106
|
+
<xsl:variable name="D" select="$table_widths/table/@width_max - $table_widths/table/@width_min"/>
|
4107
|
+
<D><xsl:value-of select="$D"/></D>
|
4108
|
+
<case3/>
|
4109
|
+
<autolayout/>
|
4110
|
+
<xsl:if test="$table_widths/table/@width_min >= $page_width">
|
4111
|
+
<split_keep-within-line>true</split_keep-within-line>
|
4112
|
+
</xsl:if>
|
4113
|
+
<xsl:for-each select="$column_widths/column">
|
4114
|
+
<!-- difference between maximum and minimum width of that column. -->
|
4115
|
+
<xsl:variable name="d" select="@width_max - @width_min"/>
|
4116
|
+
<d><xsl:value-of select="$d"/></d>
|
4117
|
+
<width_min><xsl:value-of select="@width_min"/></width_min>
|
4118
|
+
<e><xsl:value-of select="$d * $W div $D"/></e>
|
4119
|
+
<!-- set the column's width to the minimum width plus d times W over D. -->
|
4120
|
+
<column divider="100">
|
4121
|
+
<xsl:value-of select="round(@width_min + $d * $W div $D)"/> <!-- * 10 -->
|
4122
|
+
</column>
|
4123
|
+
</xsl:for-each>
|
4124
|
+
|
4125
|
+
</xsl:when>
|
4126
|
+
<xsl:otherwise><unknown_case/></xsl:otherwise>
|
4127
|
+
</xsl:choose>
|
4128
|
+
|
4129
|
+
|
4130
|
+
</xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths">
|
4131
|
+
<xsl:copy>
|
4132
|
+
<xsl:apply-templates select="@*|node()" mode="determine_cell_widths"/>
|
4133
|
+
</xsl:copy>
|
4134
|
+
</xsl:template><xsl:template match="td | th" mode="determine_cell_widths">
|
4135
|
+
<xsl:copy>
|
4136
|
+
<xsl:copy-of select="@*"/>
|
4137
|
+
|
4138
|
+
<!-- The maximum width is given by the widest line. -->
|
4139
|
+
<xsl:variable name="widths_max">
|
4140
|
+
<xsl:for-each select=".//*[local-name() = 'p']">
|
4141
|
+
<xsl:call-template name="add_width"/>
|
4142
|
+
</xsl:for-each>
|
4143
|
+
<xsl:if test="not(*[local-name() = 'p'])">
|
4144
|
+
<xsl:call-template name="add_width"/>
|
3794
4145
|
</xsl:if>
|
4146
|
+
</xsl:variable>
|
4147
|
+
<xsl:variable name="width_max">
|
4148
|
+
<xsl:for-each select="xalan:nodeset($widths_max)//width">
|
4149
|
+
<xsl:sort select="." data-type="number" order="descending"/>
|
4150
|
+
<xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
|
4151
|
+
</xsl:for-each>
|
4152
|
+
</xsl:variable>
|
4153
|
+
<xsl:attribute name="width_max">
|
4154
|
+
<xsl:value-of select="$width_max"/>
|
4155
|
+
</xsl:attribute>
|
4156
|
+
|
4157
|
+
<!-- The minimum width is given by the widest text element (word, image, etc.) -->
|
4158
|
+
<!-- To do: image width -->
|
4159
|
+
<xsl:variable name="td_text">
|
4160
|
+
<xsl:apply-templates select="." mode="td_text"/>
|
4161
|
+
</xsl:variable>
|
4162
|
+
<xsl:variable name="words">
|
4163
|
+
<xsl:variable name="string_with_added_zerospaces">
|
4164
|
+
<xsl:call-template name="add-zero-spaces-java">
|
4165
|
+
<xsl:with-param name="text" select="$td_text"/>
|
4166
|
+
</xsl:call-template>
|
4167
|
+
</xsl:variable>
|
4168
|
+
<xsl:call-template name="tokenize">
|
4169
|
+
<xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
|
4170
|
+
</xsl:call-template>
|
4171
|
+
</xsl:variable>
|
4172
|
+
|
4173
|
+
<xsl:variable name="max_word_length">
|
4174
|
+
<xsl:call-template name="max_length">
|
4175
|
+
<xsl:with-param name="words" select="xalan:nodeset($words)"/>
|
4176
|
+
</xsl:call-template>
|
4177
|
+
</xsl:variable>
|
4178
|
+
<xsl:variable name="width_min">
|
4179
|
+
<xsl:value-of select="$max_word_length"/>
|
4180
|
+
</xsl:variable>
|
4181
|
+
<xsl:attribute name="width_min">
|
4182
|
+
<xsl:value-of select="$width_min"/>
|
4183
|
+
</xsl:attribute>
|
4184
|
+
<!-- width_max="1" width_min="1.5"> --> <!-- see 'tokenize' template, multiply 1.5 for all latin capitals -->
|
4185
|
+
<xsl:if test="$width_min > $width_max">
|
4186
|
+
<xsl:attribute name="width_max">
|
4187
|
+
<xsl:value-of select="$width_min"/>
|
4188
|
+
</xsl:attribute>
|
4189
|
+
</xsl:if>
|
4190
|
+
<xsl:if test="$width_min = 0">
|
4191
|
+
<xsl:attribute name="width_min">1</xsl:attribute>
|
4192
|
+
</xsl:if>
|
4193
|
+
|
4194
|
+
<xsl:apply-templates select="node()" mode="determine_cell_widths"/>
|
4195
|
+
|
4196
|
+
</xsl:copy>
|
4197
|
+
</xsl:template><xsl:template name="add_width">
|
4198
|
+
<xsl:variable name="p_text"><xsl:apply-templates select="." mode="td_text"/></xsl:variable>
|
4199
|
+
<xsl:variable name="p_text_len_" select="string-length(normalize-space($p_text))"/>
|
4200
|
+
|
4201
|
+
<xsl:variable name="p_text_len">
|
4202
|
+
<xsl:choose>
|
4203
|
+
<xsl:when test="normalize-space(translate($p_text, concat($upper,'0123456789'), '')) = ''"> <!-- english word in CAPITAL letters -->
|
4204
|
+
<xsl:value-of select="$p_text_len_ * 1.5"/>
|
4205
|
+
</xsl:when>
|
4206
|
+
<xsl:otherwise><xsl:value-of select="$p_text_len_"/></xsl:otherwise>
|
4207
|
+
</xsl:choose>
|
4208
|
+
</xsl:variable>
|
4209
|
+
|
4210
|
+
<xsl:variable name="math_addon_text">
|
4211
|
+
<xsl:for-each select=".//*[local-name() = 'math']">
|
4212
|
+
<xsl:apply-templates mode="td_text"/>
|
3795
4213
|
</xsl:for-each>
|
3796
4214
|
</xsl:variable>
|
4215
|
+
<xsl:variable name="math_addon_length" select="string-length(normalize-space($math_addon_text)) * 0.2"/> <!-- plus 20% -->
|
3797
4216
|
|
3798
|
-
<xsl:
|
3799
|
-
|
4217
|
+
<width><xsl:value-of select="$p_text_len + $math_addon_length"/></width>
|
4218
|
+
</xsl:template><xsl:template match="@*|node()" mode="determine_cell_widths-if">
|
4219
|
+
<xsl:copy>
|
4220
|
+
<xsl:apply-templates select="@*|node()" mode="determine_cell_widths-if"/>
|
4221
|
+
</xsl:copy>
|
4222
|
+
</xsl:template><xsl:template match="td | th" mode="determine_cell_widths-if">
|
4223
|
+
<xsl:copy>
|
4224
|
+
<xsl:copy-of select="@*"/>
|
4225
|
+
|
4226
|
+
<!-- The maximum width is given by the widest line. -->
|
4227
|
+
<xsl:attribute name="width_max">
|
4228
|
+
<xsl:for-each select="p_len">
|
4229
|
+
<xsl:sort select="." data-type="number" order="descending"/>
|
4230
|
+
<xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
|
4231
|
+
</xsl:for-each>
|
4232
|
+
</xsl:attribute>
|
4233
|
+
|
4234
|
+
<!-- The minimum width is given by the widest text element (word, image, etc.) -->
|
4235
|
+
<xsl:variable name="width_min">
|
4236
|
+
<xsl:for-each select="word_len">
|
4237
|
+
<xsl:sort select="." data-type="number" order="descending"/>
|
4238
|
+
<xsl:if test="position() = 1"><xsl:value-of select="."/></xsl:if>
|
4239
|
+
</xsl:for-each>
|
4240
|
+
</xsl:variable>
|
4241
|
+
<xsl:attribute name="width_min">
|
4242
|
+
<xsl:value-of select="$width_min"/>
|
4243
|
+
</xsl:attribute>
|
4244
|
+
|
4245
|
+
<xsl:if test="$width_min = 0">
|
4246
|
+
<xsl:attribute name="width_min">1</xsl:attribute>
|
4247
|
+
</xsl:if>
|
4248
|
+
|
4249
|
+
<xsl:apply-templates select="node()" mode="determine_cell_widths-if"/>
|
4250
|
+
|
4251
|
+
</xsl:copy>
|
3800
4252
|
</xsl:template><xsl:template match="*[local-name()='thead']">
|
3801
4253
|
<xsl:param name="cols-count"/>
|
3802
4254
|
<fo:table-header>
|
@@ -3881,16 +4333,10 @@
|
|
3881
4333
|
</xsl:for-each>
|
3882
4334
|
</xsl:when>
|
3883
4335
|
<xsl:otherwise>
|
3884
|
-
|
3885
|
-
|
3886
|
-
|
3887
|
-
|
3888
|
-
</xsl:when>
|
3889
|
-
<xsl:otherwise>
|
3890
|
-
<fo:table-column column-width="proportional-column-width({.})"/>
|
3891
|
-
</xsl:otherwise>
|
3892
|
-
</xsl:choose>
|
3893
|
-
</xsl:for-each>
|
4336
|
+
<!-- $colwidths=<xsl:copy-of select="$colwidths"/> -->
|
4337
|
+
<xsl:call-template name="insertTableColumnWidth">
|
4338
|
+
<xsl:with-param name="colwidths" select="$colwidths"/>
|
4339
|
+
</xsl:call-template>
|
3894
4340
|
</xsl:otherwise>
|
3895
4341
|
</xsl:choose>
|
3896
4342
|
|
@@ -3977,29 +4423,75 @@
|
|
3977
4423
|
|
3978
4424
|
</fo:table-body>
|
3979
4425
|
|
3980
|
-
</xsl:template><xsl:template match="
|
3981
|
-
<
|
4426
|
+
</xsl:template><xsl:template match="/" mode="process_table-if">
|
4427
|
+
<xsl:param name="table_or_dl">table</xsl:param>
|
4428
|
+
<xsl:apply-templates mode="process_table-if">
|
4429
|
+
<xsl:with-param name="table_or_dl" select="$table_or_dl"/>
|
4430
|
+
</xsl:apply-templates>
|
4431
|
+
</xsl:template><xsl:template match="*[local-name()='tbody']" mode="process_table-if">
|
4432
|
+
<xsl:param name="table_or_dl">table</xsl:param>
|
3982
4433
|
|
3983
|
-
|
3984
|
-
|
3985
|
-
|
4434
|
+
<fo:table-body>
|
4435
|
+
<xsl:for-each select="*[local-name() = 'tr']">
|
4436
|
+
<xsl:variable name="col_count" select="count(*)"/>
|
3986
4437
|
|
4438
|
+
<!-- iteration for each tr/td -->
|
4439
|
+
|
4440
|
+
<xsl:choose>
|
4441
|
+
<xsl:when test="$table_or_dl = 'table'">
|
4442
|
+
<xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']/*">
|
4443
|
+
<fo:table-row number-columns-spanned="{$col_count}">
|
4444
|
+
<!-- <test_table><xsl:copy-of select="."/></test_table> -->
|
4445
|
+
<xsl:call-template name="td"/>
|
4446
|
+
</fo:table-row>
|
4447
|
+
</xsl:for-each>
|
4448
|
+
</xsl:when>
|
4449
|
+
<xsl:otherwise> <!-- $table_or_dl = 'dl' -->
|
4450
|
+
<xsl:for-each select="*[local-name() = 'td' or local-name() = 'th']">
|
4451
|
+
<xsl:variable name="is_dt" select="position() = 1"/>
|
4452
|
+
|
4453
|
+
<xsl:for-each select="*">
|
4454
|
+
<!-- <test><xsl:copy-of select="."/></test> -->
|
4455
|
+
<fo:table-row number-columns-spanned="{$col_count}">
|
4456
|
+
<xsl:choose>
|
4457
|
+
<xsl:when test="$is_dt">
|
4458
|
+
<xsl:call-template name="insert_dt_cell"/>
|
4459
|
+
</xsl:when>
|
4460
|
+
<xsl:otherwise>
|
4461
|
+
<xsl:call-template name="insert_dd_cell"/>
|
4462
|
+
</xsl:otherwise>
|
4463
|
+
</xsl:choose>
|
4464
|
+
</fo:table-row>
|
4465
|
+
</xsl:for-each>
|
4466
|
+
</xsl:for-each>
|
4467
|
+
</xsl:otherwise>
|
4468
|
+
</xsl:choose>
|
4469
|
+
|
4470
|
+
</xsl:for-each>
|
4471
|
+
</fo:table-body>
|
4472
|
+
</xsl:template><xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2">
|
4473
|
+
<fo:table-row xsl:use-attribute-sets="table-header-row-style">
|
4474
|
+
|
4475
|
+
|
4476
|
+
|
4477
|
+
|
4478
|
+
|
4479
|
+
|
4480
|
+
|
4481
|
+
<xsl:call-template name="setTableRowAttributes"/>
|
4482
|
+
|
4483
|
+
<xsl:apply-templates/>
|
4484
|
+
</fo:table-row>
|
4485
|
+
</xsl:template><xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
|
4486
|
+
<fo:table-row xsl:use-attribute-sets="table-footer-row-style">
|
4487
|
+
|
4488
|
+
<xsl:call-template name="setTableRowAttributes"/>
|
4489
|
+
<xsl:apply-templates/>
|
4490
|
+
</fo:table-row>
|
4491
|
+
</xsl:template><xsl:template match="*[local-name()='tr']">
|
4492
|
+
<fo:table-row xsl:use-attribute-sets="table-body-row-style">
|
4493
|
+
|
3987
4494
|
|
3988
|
-
|
3989
|
-
<xsl:call-template name="setTableRowAttributes"/>
|
3990
|
-
|
3991
|
-
<xsl:apply-templates/>
|
3992
|
-
</fo:table-row>
|
3993
|
-
</xsl:template><xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2">
|
3994
|
-
<fo:table-row xsl:use-attribute-sets="table-footer-row-style">
|
3995
|
-
|
3996
|
-
<xsl:call-template name="setTableRowAttributes"/>
|
3997
|
-
<xsl:apply-templates/>
|
3998
|
-
</fo:table-row>
|
3999
|
-
</xsl:template><xsl:template match="*[local-name()='tr']">
|
4000
|
-
<fo:table-row xsl:use-attribute-sets="table-body-row-style">
|
4001
|
-
|
4002
|
-
|
4003
4495
|
|
4004
4496
|
|
4005
4497
|
|
@@ -4068,7 +4560,7 @@
|
|
4068
4560
|
</xsl:choose>
|
4069
4561
|
</xsl:attribute>
|
4070
4562
|
</xsl:if>
|
4071
|
-
</xsl:template><xsl:template match="*[local-name()='td']">
|
4563
|
+
</xsl:template><xsl:template match="*[local-name()='td']" name="td">
|
4072
4564
|
<fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" -->
|
4073
4565
|
<xsl:call-template name="setTextAlignment">
|
4074
4566
|
<xsl:with-param name="default">left</xsl:with-param>
|
@@ -4106,11 +4598,24 @@
|
|
4106
4598
|
|
4107
4599
|
<xsl:call-template name="setTableCellAttributes"/>
|
4108
4600
|
|
4601
|
+
<xsl:if test="$isGenerateTableIF = 'true'">
|
4602
|
+
<xsl:attribute name="border">1pt solid black</xsl:attribute> <!-- border is mandatory, to determine page width -->
|
4603
|
+
<xsl:attribute name="text-align">left</xsl:attribute>
|
4604
|
+
</xsl:if>
|
4605
|
+
|
4109
4606
|
<fo:block>
|
4110
4607
|
|
4608
|
+
<xsl:if test="$isGenerateTableIF = 'true'">
|
4609
|
+
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
|
4610
|
+
</xsl:if>
|
4611
|
+
|
4612
|
+
|
4111
4613
|
|
4112
4614
|
|
4113
4615
|
<xsl:apply-templates/>
|
4616
|
+
|
4617
|
+
<xsl:if test="$isGenerateTableIF = 'true'"><fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> -->
|
4618
|
+
|
4114
4619
|
</fo:block>
|
4115
4620
|
</fo:table-cell>
|
4116
4621
|
</xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']" priority="2">
|
@@ -4307,9 +4812,9 @@
|
|
4307
4812
|
<!-- current hierarchy is 'figure' element -->
|
4308
4813
|
<xsl:variable name="following_dl_colwidths">
|
4309
4814
|
<xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
|
4310
|
-
<xsl:variable name="
|
4311
|
-
<xsl:variable name="doc_ns">
|
4312
|
-
|
4815
|
+
<xsl:variable name="simple-table">
|
4816
|
+
<!-- <xsl:variable name="doc_ns">
|
4817
|
+
<xsl:if test="$namespace = 'bipm'">bipm</xsl:if>
|
4313
4818
|
</xsl:variable>
|
4314
4819
|
<xsl:variable name="ns">
|
4315
4820
|
<xsl:choose>
|
@@ -4320,7 +4825,7 @@
|
|
4320
4825
|
<xsl:value-of select="substring-before(name(/*), '-')"/>
|
4321
4826
|
</xsl:otherwise>
|
4322
4827
|
</xsl:choose>
|
4323
|
-
</xsl:variable>
|
4828
|
+
</xsl:variable> -->
|
4324
4829
|
|
4325
4830
|
<xsl:for-each select="*[local-name() = 'dl'][1]">
|
4326
4831
|
<tbody>
|
@@ -4331,7 +4836,7 @@
|
|
4331
4836
|
|
4332
4837
|
<xsl:call-template name="calculate-column-widths">
|
4333
4838
|
<xsl:with-param name="cols-count" select="2"/>
|
4334
|
-
<xsl:with-param name="table" select="$
|
4839
|
+
<xsl:with-param name="table" select="$simple-table"/>
|
4335
4840
|
</xsl:call-template>
|
4336
4841
|
|
4337
4842
|
</xsl:if>
|
@@ -4457,8 +4962,10 @@
|
|
4457
4962
|
<!-- and (not(../@class) or ../@class !='pseudocode') -->
|
4458
4963
|
</xsl:variable>
|
4459
4964
|
|
4965
|
+
<xsl:variable name="onlyOneComponent" select="normalize-space($parent = 'formula' and count(*[local-name()='dt']) = 1)"/>
|
4966
|
+
|
4460
4967
|
<xsl:choose>
|
4461
|
-
<xsl:when test="$
|
4968
|
+
<xsl:when test="$onlyOneComponent = 'true'"> <!-- only one component -->
|
4462
4969
|
|
4463
4970
|
<fo:block text-align="left">
|
4464
4971
|
|
@@ -4480,7 +4987,7 @@
|
|
4480
4987
|
<xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
|
4481
4988
|
</fo:block>
|
4482
4989
|
|
4483
|
-
</xsl:when>
|
4990
|
+
</xsl:when> <!-- END: only one component -->
|
4484
4991
|
<xsl:when test="$parent = 'formula'"> <!-- a few components -->
|
4485
4992
|
<fo:block margin-bottom="12pt" text-align="left">
|
4486
4993
|
|
@@ -4496,8 +5003,8 @@
|
|
4496
5003
|
</xsl:variable>
|
4497
5004
|
<xsl:value-of select="$title-where"/>
|
4498
5005
|
</fo:block>
|
4499
|
-
</xsl:when>
|
4500
|
-
<xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')">
|
5006
|
+
</xsl:when> <!-- END: a few components -->
|
5007
|
+
<xsl:when test="$parent = 'figure' and (not(../@class) or ../@class !='pseudocode')"> <!-- definition list in a figure -->
|
4501
5008
|
<fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">
|
4502
5009
|
|
4503
5010
|
|
@@ -4513,11 +5020,11 @@
|
|
4513
5020
|
</xsl:variable>
|
4514
5021
|
<xsl:value-of select="$title-key"/>
|
4515
5022
|
</fo:block>
|
4516
|
-
</xsl:when>
|
5023
|
+
</xsl:when> <!-- END: definition list in a figure -->
|
4517
5024
|
</xsl:choose>
|
4518
5025
|
|
4519
5026
|
<!-- a few components -->
|
4520
|
-
<xsl:if test="
|
5027
|
+
<xsl:if test="$onlyOneComponent = 'false'">
|
4521
5028
|
<fo:block>
|
4522
5029
|
|
4523
5030
|
|
@@ -4528,7 +5035,18 @@
|
|
4528
5035
|
|
4529
5036
|
|
4530
5037
|
|
5038
|
+
|
5039
|
+
<xsl:if test="$isGenerateTableIF = 'true'">
|
5040
|
+
<!-- to determine start of table -->
|
5041
|
+
<fo:block id="{concat('table_if_start_',@id)}" keep-with-next="always" font-size="1pt">Start table '<xsl:value-of select="@id"/>'.</fo:block>
|
5042
|
+
</xsl:if>
|
5043
|
+
|
4531
5044
|
<fo:table width="95%" table-layout="fixed">
|
5045
|
+
|
5046
|
+
<xsl:if test="$isGenerateTableIF = 'true'">
|
5047
|
+
<xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
|
5048
|
+
</xsl:if>
|
5049
|
+
|
4532
5050
|
|
4533
5051
|
<xsl:choose>
|
4534
5052
|
<xsl:when test="normalize-space($key_iso) = 'true' and $parent = 'formula'"/>
|
@@ -4539,54 +5057,143 @@
|
|
4539
5057
|
|
4540
5058
|
</xsl:when>
|
4541
5059
|
</xsl:choose>
|
4542
|
-
|
4543
|
-
|
4544
|
-
|
5060
|
+
|
5061
|
+
|
5062
|
+
<xsl:choose>
|
5063
|
+
<xsl:when test="$isGenerateTableIF = 'true'">
|
5064
|
+
<!-- generate IF for table widths -->
|
5065
|
+
<!-- example:
|
5066
|
+
<tr>
|
5067
|
+
<td valign="top" align="left" id="tab-symdu_1_1">
|
5068
|
+
<p>Symbol</p>
|
5069
|
+
<word id="tab-symdu_1_1_word_1">Symbol</word>
|
5070
|
+
</td>
|
5071
|
+
<td valign="top" align="left" id="tab-symdu_1_2">
|
5072
|
+
<p>Description</p>
|
5073
|
+
<word id="tab-symdu_1_2_word_1">Description</word>
|
5074
|
+
</td>
|
5075
|
+
</tr>
|
5076
|
+
-->
|
4545
5077
|
|
4546
|
-
|
4547
|
-
|
4548
|
-
|
4549
|
-
<xsl:
|
4550
|
-
<
|
4551
|
-
|
4552
|
-
|
4553
|
-
|
4554
|
-
|
4555
|
-
|
4556
|
-
|
4557
|
-
|
4558
|
-
|
4559
|
-
|
4560
|
-
|
4561
|
-
|
4562
|
-
|
4563
|
-
|
4564
|
-
|
4565
|
-
|
4566
|
-
|
4567
|
-
|
4568
|
-
|
4569
|
-
|
4570
|
-
|
4571
|
-
|
4572
|
-
|
4573
|
-
|
4574
|
-
|
4575
|
-
|
4576
|
-
|
4577
|
-
|
4578
|
-
|
4579
|
-
|
4580
|
-
|
5078
|
+
<!-- create virtual html table for dl/[dt and dd] -->
|
5079
|
+
<xsl:variable name="simple-table">
|
5080
|
+
|
5081
|
+
<xsl:variable name="dl_table">
|
5082
|
+
<tbody>
|
5083
|
+
<xsl:apply-templates mode="dl_if">
|
5084
|
+
<xsl:with-param name="id" select="@id"/>
|
5085
|
+
</xsl:apply-templates>
|
5086
|
+
</tbody>
|
5087
|
+
</xsl:variable>
|
5088
|
+
|
5089
|
+
<!-- dl_table='<xsl:copy-of select="$dl_table"/>' -->
|
5090
|
+
|
5091
|
+
<!-- Step: replace <br/> to <p>...</p> -->
|
5092
|
+
<xsl:variable name="table_without_br">
|
5093
|
+
<xsl:apply-templates select="xalan:nodeset($dl_table)" mode="table-without-br"/>
|
5094
|
+
</xsl:variable>
|
5095
|
+
|
5096
|
+
<!-- table_without_br='<xsl:copy-of select="$table_without_br"/>' -->
|
5097
|
+
|
5098
|
+
<!-- Step: add id to each cell -->
|
5099
|
+
<!-- add <word>...</word> for each word, image, math -->
|
5100
|
+
<xsl:variable name="simple-table-id">
|
5101
|
+
<xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-id">
|
5102
|
+
<xsl:with-param name="id" select="@id"/>
|
5103
|
+
</xsl:apply-templates>
|
5104
|
+
</xsl:variable>
|
5105
|
+
|
5106
|
+
<!-- simple-table-id='<xsl:copy-of select="$simple-table-id"/>' -->
|
5107
|
+
|
5108
|
+
<xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
|
5109
|
+
|
5110
|
+
</xsl:variable>
|
5111
|
+
|
5112
|
+
<!-- DEBUG: simple-table<xsl:copy-of select="$simple-table"/> -->
|
5113
|
+
|
5114
|
+
<xsl:apply-templates select="xalan:nodeset($simple-table)" mode="process_table-if">
|
5115
|
+
<xsl:with-param name="table_or_dl">dl</xsl:with-param>
|
5116
|
+
</xsl:apply-templates>
|
5117
|
+
|
5118
|
+
</xsl:when>
|
5119
|
+
<xsl:otherwise>
|
5120
|
+
|
5121
|
+
<xsl:variable name="simple-table">
|
5122
|
+
|
5123
|
+
<xsl:variable name="dl_table">
|
5124
|
+
<tbody>
|
5125
|
+
<xsl:apply-templates mode="dl">
|
5126
|
+
<xsl:with-param name="id" select="@id"/>
|
5127
|
+
</xsl:apply-templates>
|
5128
|
+
</tbody>
|
5129
|
+
</xsl:variable>
|
5130
|
+
|
5131
|
+
<xsl:copy-of select="$dl_table"/>
|
5132
|
+
</xsl:variable>
|
5133
|
+
|
5134
|
+
<xsl:variable name="colwidths">
|
5135
|
+
<xsl:call-template name="calculate-column-widths">
|
5136
|
+
<xsl:with-param name="cols-count" select="2"/>
|
5137
|
+
<xsl:with-param name="table" select="$simple-table"/>
|
5138
|
+
</xsl:call-template>
|
5139
|
+
</xsl:variable>
|
5140
|
+
|
5141
|
+
<!-- <xsl:text disable-output-escaping="yes"><!- -</xsl:text>
|
5142
|
+
DEBUG
|
5143
|
+
colwidths=<xsl:copy-of select="$colwidths"/>
|
5144
|
+
<xsl:text disable-output-escaping="yes">- -></xsl:text> -->
|
5145
|
+
|
5146
|
+
<!-- colwidths=<xsl:copy-of select="$colwidths"/> -->
|
5147
|
+
|
5148
|
+
<xsl:variable name="maxlength_dt">
|
5149
|
+
<xsl:call-template name="getMaxLength_dt"/>
|
5150
|
+
</xsl:variable>
|
5151
|
+
|
5152
|
+
<xsl:variable name="isContainsKeepTogetherTag_">
|
5153
|
+
false
|
5154
|
+
</xsl:variable>
|
5155
|
+
<xsl:variable name="isContainsKeepTogetherTag" select="normalize-space($isContainsKeepTogetherTag_)"/>
|
5156
|
+
<!-- isContainsExpressReference=<xsl:value-of select="$isContainsExpressReference"/> -->
|
5157
|
+
|
5158
|
+
|
5159
|
+
<xsl:call-template name="setColumnWidth_dl">
|
5160
|
+
<xsl:with-param name="colwidths" select="$colwidths"/>
|
5161
|
+
<xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
|
5162
|
+
<xsl:with-param name="isContainsKeepTogetherTag" select="$isContainsKeepTogetherTag"/>
|
5163
|
+
</xsl:call-template>
|
5164
|
+
|
5165
|
+
<fo:table-body>
|
5166
|
+
|
5167
|
+
<!-- DEBUG -->
|
5168
|
+
<xsl:if test="$table_if_debug = 'true'">
|
5169
|
+
<fo:table-row>
|
5170
|
+
<fo:table-cell number-columns-spanned="2" font-size="60%">
|
5171
|
+
<xsl:apply-templates select="xalan:nodeset($colwidths)" mode="print_as_xml"/>
|
5172
|
+
</fo:table-cell>
|
5173
|
+
</fo:table-row>
|
5174
|
+
</xsl:if>
|
5175
|
+
|
5176
|
+
<xsl:apply-templates>
|
5177
|
+
<xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
|
5178
|
+
<xsl:with-param name="split_keep-within-line" select="xalan:nodeset($colwidths)/split_keep-within-line"/>
|
5179
|
+
</xsl:apply-templates>
|
5180
|
+
|
5181
|
+
</fo:table-body>
|
5182
|
+
</xsl:otherwise>
|
5183
|
+
</xsl:choose>
|
4581
5184
|
</fo:table>
|
4582
5185
|
</fo:block>
|
4583
5186
|
</fo:block>
|
4584
|
-
</xsl:if>
|
5187
|
+
</xsl:if> <!-- END: a few components -->
|
4585
5188
|
</fo:block-container>
|
4586
5189
|
</fo:block-container>
|
4587
5190
|
</xsl:template><xsl:template name="setColumnWidth_dl">
|
4588
5191
|
<xsl:param name="colwidths"/>
|
4589
5192
|
<xsl:param name="maxlength_dt"/>
|
5193
|
+
<xsl:param name="isContainsKeepTogetherTag"/>
|
5194
|
+
|
5195
|
+
<!-- <colwidths><xsl:copy-of select="$colwidths"/></colwidths> -->
|
5196
|
+
|
4590
5197
|
<xsl:choose>
|
4591
5198
|
<xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
|
4592
5199
|
<fo:table-column column-width="50%"/>
|
@@ -4594,6 +5201,16 @@
|
|
4594
5201
|
</xsl:when>
|
4595
5202
|
<xsl:otherwise>
|
4596
5203
|
<xsl:choose>
|
5204
|
+
<xsl:when test="xalan:nodeset($colwidths)/autolayout">
|
5205
|
+
<xsl:call-template name="insertTableColumnWidth">
|
5206
|
+
<xsl:with-param name="colwidths" select="$colwidths"/>
|
5207
|
+
</xsl:call-template>
|
5208
|
+
</xsl:when>
|
5209
|
+
<xsl:when test="$isContainsKeepTogetherTag">
|
5210
|
+
<xsl:call-template name="insertTableColumnWidth">
|
5211
|
+
<xsl:with-param name="colwidths" select="$colwidths"/>
|
5212
|
+
</xsl:call-template>
|
5213
|
+
</xsl:when>
|
4597
5214
|
<!-- to set width check most wide chars like `W` -->
|
4598
5215
|
<xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) <= 2"> <!-- if dt contains short text like t90, a, etc -->
|
4599
5216
|
<fo:table-column column-width="7%"/>
|
@@ -4624,20 +5241,31 @@
|
|
4624
5241
|
<fo:table-column column-width="60%"/>
|
4625
5242
|
</xsl:when>
|
4626
5243
|
<xsl:otherwise>
|
4627
|
-
<xsl:
|
4628
|
-
<xsl:
|
4629
|
-
|
4630
|
-
<fo:table-column column-width="proportional-column-width(2)"/>
|
4631
|
-
</xsl:when>
|
4632
|
-
<xsl:otherwise>
|
4633
|
-
<fo:table-column column-width="proportional-column-width({.})"/>
|
4634
|
-
</xsl:otherwise>
|
4635
|
-
</xsl:choose>
|
4636
|
-
</xsl:for-each>
|
5244
|
+
<xsl:call-template name="insertTableColumnWidth">
|
5245
|
+
<xsl:with-param name="colwidths" select="$colwidths"/>
|
5246
|
+
</xsl:call-template>
|
4637
5247
|
</xsl:otherwise>
|
4638
5248
|
</xsl:choose>
|
4639
5249
|
</xsl:otherwise>
|
4640
5250
|
</xsl:choose>
|
5251
|
+
</xsl:template><xsl:template name="insertTableColumnWidth">
|
5252
|
+
<xsl:param name="colwidths"/>
|
5253
|
+
|
5254
|
+
<xsl:for-each select="xalan:nodeset($colwidths)//column">
|
5255
|
+
<xsl:choose>
|
5256
|
+
<xsl:when test=". = 1 or . = 0">
|
5257
|
+
<fo:table-column column-width="proportional-column-width(2)"/>
|
5258
|
+
</xsl:when>
|
5259
|
+
<xsl:otherwise>
|
5260
|
+
<!-- <fo:table-column column-width="proportional-column-width({.})"/> -->
|
5261
|
+
<xsl:variable name="divider">
|
5262
|
+
<xsl:value-of select="@divider"/>
|
5263
|
+
<xsl:if test="not(@divider)">1</xsl:if>
|
5264
|
+
</xsl:variable>
|
5265
|
+
<fo:table-column column-width="proportional-column-width({round(. div $divider)})"/>
|
5266
|
+
</xsl:otherwise>
|
5267
|
+
</xsl:choose>
|
5268
|
+
</xsl:for-each>
|
4641
5269
|
</xsl:template><xsl:template name="getMaxLength_dt">
|
4642
5270
|
<xsl:variable name="lengths">
|
4643
5271
|
<xsl:for-each select="*[local-name()='dt']">
|
@@ -4661,7 +5289,6 @@
|
|
4661
5289
|
<xsl:value-of select="$maxLength"/>
|
4662
5290
|
</xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
|
4663
5291
|
<xsl:param name="key_iso"/>
|
4664
|
-
|
4665
5292
|
<!-- <tr>
|
4666
5293
|
<td>NOTE</td>
|
4667
5294
|
<td>
|
@@ -4669,27 +5296,47 @@
|
|
4669
5296
|
</td>
|
4670
5297
|
</tr>
|
4671
5298
|
-->
|
4672
|
-
|
5299
|
+
<!-- OLD Variant -->
|
5300
|
+
<!-- <fo:table-row>
|
4673
5301
|
<fo:table-cell>
|
4674
5302
|
<fo:block margin-top="6pt">
|
4675
5303
|
<xsl:if test="normalize-space($key_iso) = 'true'">
|
4676
5304
|
<xsl:attribute name="margin-top">0</xsl:attribute>
|
4677
5305
|
</xsl:if>
|
4678
|
-
<xsl:apply-templates select="*[local-name() = 'name']"/>
|
5306
|
+
<xsl:apply-templates select="*[local-name() = 'name']" />
|
4679
5307
|
</fo:block>
|
4680
5308
|
</fo:table-cell>
|
4681
5309
|
<fo:table-cell>
|
4682
5310
|
<fo:block>
|
4683
|
-
<xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
|
5311
|
+
<xsl:apply-templates select="node()[not(local-name() = 'name')]" />
|
5312
|
+
</fo:block>
|
5313
|
+
</fo:table-cell>
|
5314
|
+
</fo:table-row> -->
|
5315
|
+
<!-- <tr>
|
5316
|
+
<td number-columns-spanned="2">NOTE <xsl:apply-templates /> </td>
|
5317
|
+
</tr>
|
5318
|
+
-->
|
5319
|
+
<fo:table-row>
|
5320
|
+
<fo:table-cell number-columns-spanned="2">
|
5321
|
+
<fo:block>
|
5322
|
+
<xsl:call-template name="note"/>
|
4684
5323
|
</fo:block>
|
4685
5324
|
</fo:table-cell>
|
4686
5325
|
</fo:table-row>
|
4687
5326
|
</xsl:template><xsl:template match="*[local-name()='dt']" mode="dl">
|
5327
|
+
<xsl:param name="id"/>
|
5328
|
+
<xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
|
4688
5329
|
<tr>
|
4689
5330
|
<td>
|
5331
|
+
<xsl:attribute name="id">
|
5332
|
+
<xsl:value-of select="concat($id,'_',$row_number,'_1')"/>
|
5333
|
+
</xsl:attribute>
|
4690
5334
|
<xsl:apply-templates/>
|
4691
5335
|
</td>
|
4692
5336
|
<td>
|
5337
|
+
<xsl:attribute name="id">
|
5338
|
+
<xsl:value-of select="concat($id,'_',$row_number,'_2')"/>
|
5339
|
+
</xsl:attribute>
|
4693
5340
|
|
4694
5341
|
<xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]">
|
4695
5342
|
<xsl:with-param name="process">true</xsl:with-param>
|
@@ -4700,50 +5347,122 @@
|
|
4700
5347
|
|
4701
5348
|
</xsl:template><xsl:template match="*[local-name()='dt']">
|
4702
5349
|
<xsl:param name="key_iso"/>
|
5350
|
+
<xsl:param name="split_keep-within-line"/>
|
4703
5351
|
|
4704
5352
|
<fo:table-row xsl:use-attribute-sets="dt-row-style">
|
4705
|
-
<
|
5353
|
+
<xsl:call-template name="insert_dt_cell">
|
5354
|
+
<xsl:with-param name="key_iso" select="$key_iso"/>
|
5355
|
+
<xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
|
5356
|
+
</xsl:call-template>
|
5357
|
+
<xsl:for-each select="following-sibling::*[local-name()='dd'][1]">
|
5358
|
+
<xsl:call-template name="insert_dd_cell">
|
5359
|
+
<xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
|
5360
|
+
</xsl:call-template>
|
5361
|
+
</xsl:for-each>
|
5362
|
+
</fo:table-row>
|
5363
|
+
</xsl:template><xsl:template name="insert_dt_cell">
|
5364
|
+
<xsl:param name="key_iso"/>
|
5365
|
+
<xsl:param name="split_keep-within-line"/>
|
5366
|
+
<fo:table-cell xsl:use-attribute-sets="dt-cell-style">
|
5367
|
+
|
5368
|
+
<xsl:if test="$isGenerateTableIF = 'true'">
|
5369
|
+
<!-- border is mandatory, to calculate real width -->
|
5370
|
+
<xsl:attribute name="border">0.1pt solid black</xsl:attribute>
|
5371
|
+
<xsl:attribute name="text-align">left</xsl:attribute>
|
5372
|
+
</xsl:if>
|
5373
|
+
|
5374
|
+
|
5375
|
+
<fo:block xsl:use-attribute-sets="dt-block-style">
|
5376
|
+
<xsl:copy-of select="@id"/>
|
5377
|
+
|
5378
|
+
<xsl:if test="normalize-space($key_iso) = 'true'">
|
5379
|
+
<xsl:attribute name="margin-top">0</xsl:attribute>
|
5380
|
+
</xsl:if>
|
5381
|
+
|
5382
|
+
|
5383
|
+
|
5384
|
+
<xsl:apply-templates>
|
5385
|
+
<xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
|
5386
|
+
</xsl:apply-templates>
|
5387
|
+
|
5388
|
+
<xsl:if test="$isGenerateTableIF = 'true'"><fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> -->
|
5389
|
+
|
5390
|
+
</fo:block>
|
5391
|
+
</fo:table-cell>
|
5392
|
+
</xsl:template><xsl:template name="insert_dd_cell">
|
5393
|
+
<xsl:param name="split_keep-within-line"/>
|
5394
|
+
<fo:table-cell xsl:use-attribute-sets="dd-cell-style">
|
5395
|
+
|
5396
|
+
<xsl:if test="$isGenerateTableIF = 'true'">
|
5397
|
+
<!-- border is mandatory, to calculate real width -->
|
5398
|
+
<xsl:attribute name="border">0.1pt solid black</xsl:attribute>
|
5399
|
+
</xsl:if>
|
5400
|
+
|
5401
|
+
<fo:block>
|
5402
|
+
|
5403
|
+
<xsl:if test="$isGenerateTableIF = 'true'">
|
5404
|
+
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
|
5405
|
+
</xsl:if>
|
5406
|
+
|
4706
5407
|
|
4707
|
-
<fo:block xsl:use-attribute-sets="dt-style">
|
4708
|
-
<xsl:copy-of select="@id"/>
|
4709
|
-
|
4710
|
-
<xsl:if test="normalize-space($key_iso) = 'true'">
|
4711
|
-
<xsl:attribute name="margin-top">0</xsl:attribute>
|
4712
|
-
</xsl:if>
|
4713
|
-
|
4714
|
-
|
4715
|
-
|
4716
|
-
<xsl:apply-templates/>
|
4717
|
-
</fo:block>
|
4718
|
-
</fo:table-cell>
|
4719
|
-
<fo:table-cell>
|
4720
|
-
<fo:block>
|
4721
|
-
|
4722
5408
|
|
4723
|
-
|
4724
|
-
|
4725
|
-
|
4726
|
-
|
4727
|
-
|
4728
|
-
|
5409
|
+
<xsl:choose>
|
5410
|
+
<xsl:when test="$isGenerateTableIF = 'true'">
|
5411
|
+
<xsl:apply-templates> <!-- following-sibling::*[local-name()='dd'][1] -->
|
5412
|
+
<xsl:with-param name="process">true</xsl:with-param>
|
5413
|
+
</xsl:apply-templates>
|
5414
|
+
</xsl:when>
|
5415
|
+
<xsl:otherwise>
|
5416
|
+
<xsl:apply-templates select="."> <!-- following-sibling::*[local-name()='dd'][1] -->
|
5417
|
+
<xsl:with-param name="process">true</xsl:with-param>
|
5418
|
+
<xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
|
5419
|
+
</xsl:apply-templates>
|
5420
|
+
</xsl:otherwise>
|
5421
|
+
|
5422
|
+
</xsl:choose>
|
5423
|
+
|
5424
|
+
<xsl:if test="$isGenerateTableIF = 'true'"><fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> -->
|
5425
|
+
|
5426
|
+
</fo:block>
|
5427
|
+
</fo:table-cell>
|
4729
5428
|
</xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
|
4730
5429
|
<xsl:apply-templates/>
|
4731
5430
|
</xsl:template><xsl:template match="*[local-name()='dd']">
|
4732
5431
|
<xsl:param name="process">false</xsl:param>
|
5432
|
+
<xsl:param name="split_keep-within-line"/>
|
4733
5433
|
<xsl:if test="$process = 'true'">
|
4734
5434
|
<xsl:apply-templates select="@language"/>
|
4735
|
-
<xsl:apply-templates
|
5435
|
+
<xsl:apply-templates>
|
5436
|
+
<xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
|
5437
|
+
</xsl:apply-templates>
|
4736
5438
|
</xsl:if>
|
4737
5439
|
</xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
|
4738
5440
|
<fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
|
4739
|
-
</xsl:template><xsl:template match="*[local-name()='
|
5441
|
+
</xsl:template><xsl:template match="*[local-name()='dt']" mode="dl_if">
|
5442
|
+
<xsl:param name="id"/>
|
5443
|
+
<xsl:variable name="row_number" select="count(preceding-sibling::*[local-name()='dt']) + 1"/>
|
5444
|
+
<tr>
|
5445
|
+
<td>
|
5446
|
+
<xsl:copy-of select="node()"/>
|
5447
|
+
</td>
|
5448
|
+
<td>
|
5449
|
+
|
5450
|
+
<xsl:copy-of select="following-sibling::*[local-name()='dd'][1]/node()"/>
|
5451
|
+
|
5452
|
+
</td>
|
5453
|
+
</tr>
|
5454
|
+
|
5455
|
+
</xsl:template><xsl:template match="*[local-name()='dd']" mode="dl_if"/><xsl:template match="*[local-name()='em']">
|
4740
5456
|
<fo:inline font-style="italic">
|
4741
5457
|
<xsl:apply-templates/>
|
4742
5458
|
</fo:inline>
|
4743
5459
|
</xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
|
5460
|
+
<xsl:param name="split_keep-within-line"/>
|
4744
5461
|
<fo:inline font-weight="bold">
|
4745
5462
|
|
4746
|
-
<xsl:apply-templates
|
5463
|
+
<xsl:apply-templates>
|
5464
|
+
<xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
|
5465
|
+
</xsl:apply-templates>
|
4747
5466
|
</fo:inline>
|
4748
5467
|
</xsl:template><xsl:template match="*[local-name()='padding']">
|
4749
5468
|
<fo:inline padding-right="{@value}"> </fo:inline>
|
@@ -4782,13 +5501,15 @@
|
|
4782
5501
|
<xsl:choose>
|
4783
5502
|
<xsl:when test="$font-size = 'inherit'"><xsl:value-of select="$font-size"/></xsl:when>
|
4784
5503
|
<xsl:when test="contains($font-size, '%')"><xsl:value-of select="$font-size"/></xsl:when>
|
4785
|
-
<xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
|
5504
|
+
<xsl:when test="ancestor::*[local-name()='note'] or ancestor::*[local-name()='example']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
|
4786
5505
|
<xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
|
4787
5506
|
</xsl:choose>
|
4788
5507
|
</xsl:attribute>
|
4789
5508
|
</xsl:if>
|
4790
5509
|
<xsl:apply-templates/>
|
4791
5510
|
</fo:inline>
|
5511
|
+
</xsl:template><xsl:template match="*[local-name()='tt']/text()" priority="2">
|
5512
|
+
<xsl:call-template name="add_spaces_to_sourcecode"/>
|
4792
5513
|
</xsl:template><xsl:template match="*[local-name()='underline']">
|
4793
5514
|
<fo:inline text-decoration="underline">
|
4794
5515
|
<xsl:apply-templates/>
|
@@ -4936,54 +5657,120 @@
|
|
4936
5657
|
<fo:block break-after="page"/>
|
4937
5658
|
<fo:block> </fo:block>
|
4938
5659
|
<fo:block break-after="page"/>
|
5660
|
+
</xsl:template><xsl:template match="*[local-name() = 'span']">
|
5661
|
+
<xsl:apply-templates/>
|
4939
5662
|
</xsl:template><xsl:template name="tokenize">
|
4940
5663
|
<xsl:param name="text"/>
|
4941
5664
|
<xsl:param name="separator" select="' '"/>
|
4942
5665
|
<xsl:choose>
|
5666
|
+
|
5667
|
+
<xsl:when test="$isGenerateTableIF = 'true' and not(contains($text, $separator))">
|
5668
|
+
<word><xsl:value-of select="normalize-space($text)"/></word>
|
5669
|
+
</xsl:when>
|
4943
5670
|
<xsl:when test="not(contains($text, $separator))">
|
4944
5671
|
<word>
|
4945
|
-
<xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
|
4946
|
-
<xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
|
4947
5672
|
<xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
|
4948
|
-
<xsl:variable name="len_str">
|
4949
|
-
<xsl:choose>
|
4950
|
-
<xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
|
4951
|
-
<xsl:value-of select="$len_str_tmp * 1.5"/>
|
4952
|
-
</xsl:when>
|
4953
|
-
<xsl:otherwise>
|
4954
|
-
<xsl:value-of select="$len_str_tmp"/>
|
4955
|
-
</xsl:otherwise>
|
4956
|
-
</xsl:choose>
|
4957
|
-
</xsl:variable>
|
4958
|
-
|
4959
|
-
<!-- <xsl:if test="$len_str_no_en_chars div $len_str > 0.8">
|
4960
|
-
<xsl:message>
|
4961
|
-
div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
|
4962
|
-
len_str=<xsl:value-of select="$len_str"/>
|
4963
|
-
len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
|
4964
|
-
</xsl:message>
|
4965
|
-
</xsl:if> -->
|
4966
|
-
<!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
|
4967
|
-
<len_str><xsl:value-of select="$len_str"/></len_str> -->
|
4968
5673
|
<xsl:choose>
|
4969
|
-
<xsl:when test="$
|
4970
|
-
<xsl:value-of select="$
|
5674
|
+
<xsl:when test="normalize-space(translate($text, 'X', '')) = ''"> <!-- special case for keep-together.within-line -->
|
5675
|
+
<xsl:value-of select="$len_str_tmp"/>
|
4971
5676
|
</xsl:when>
|
4972
5677
|
<xsl:otherwise>
|
4973
|
-
<xsl:
|
5678
|
+
<xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
|
5679
|
+
<xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
|
5680
|
+
<xsl:variable name="len_str">
|
5681
|
+
<xsl:choose>
|
5682
|
+
<xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
|
5683
|
+
<xsl:value-of select="$len_str_tmp * 1.5"/>
|
5684
|
+
</xsl:when>
|
5685
|
+
<xsl:otherwise>
|
5686
|
+
<xsl:value-of select="$len_str_tmp"/>
|
5687
|
+
</xsl:otherwise>
|
5688
|
+
</xsl:choose>
|
5689
|
+
</xsl:variable>
|
5690
|
+
|
5691
|
+
<!-- <xsl:if test="$len_str_no_en_chars div $len_str > 0.8">
|
5692
|
+
<xsl:message>
|
5693
|
+
div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
|
5694
|
+
len_str=<xsl:value-of select="$len_str"/>
|
5695
|
+
len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
|
5696
|
+
</xsl:message>
|
5697
|
+
</xsl:if> -->
|
5698
|
+
<!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
|
5699
|
+
<len_str><xsl:value-of select="$len_str"/></len_str> -->
|
5700
|
+
<xsl:choose>
|
5701
|
+
<xsl:when test="$len_str_no_en_chars div $len_str > 0.8"> <!-- means non-english string -->
|
5702
|
+
<xsl:value-of select="$len_str - $len_str_no_en_chars"/>
|
5703
|
+
</xsl:when>
|
5704
|
+
<xsl:otherwise>
|
5705
|
+
<xsl:value-of select="$len_str"/>
|
5706
|
+
</xsl:otherwise>
|
5707
|
+
</xsl:choose>
|
4974
5708
|
</xsl:otherwise>
|
4975
5709
|
</xsl:choose>
|
4976
5710
|
</word>
|
4977
5711
|
</xsl:when>
|
4978
5712
|
<xsl:otherwise>
|
4979
5713
|
<word>
|
4980
|
-
<xsl:
|
5714
|
+
<xsl:variable name="word" select="normalize-space(substring-before($text, $separator))"/>
|
5715
|
+
<xsl:choose>
|
5716
|
+
<xsl:when test="$isGenerateTableIF = 'true'">
|
5717
|
+
<xsl:value-of select="$word"/>
|
5718
|
+
</xsl:when>
|
5719
|
+
<xsl:otherwise>
|
5720
|
+
<xsl:value-of select="string-length($word)"/>
|
5721
|
+
</xsl:otherwise>
|
5722
|
+
</xsl:choose>
|
4981
5723
|
</word>
|
4982
5724
|
<xsl:call-template name="tokenize">
|
4983
5725
|
<xsl:with-param name="text" select="substring-after($text, $separator)"/>
|
4984
5726
|
</xsl:call-template>
|
4985
5727
|
</xsl:otherwise>
|
4986
5728
|
</xsl:choose>
|
5729
|
+
</xsl:template><xsl:template name="tokenize_with_tags">
|
5730
|
+
<xsl:param name="tags"/>
|
5731
|
+
<xsl:param name="text"/>
|
5732
|
+
<xsl:param name="separator" select="' '"/>
|
5733
|
+
<xsl:choose>
|
5734
|
+
|
5735
|
+
<xsl:when test="not(contains($text, $separator))">
|
5736
|
+
<word>
|
5737
|
+
<xsl:call-template name="enclose_text_in_tags">
|
5738
|
+
<xsl:with-param name="text" select="normalize-space($text)"/>
|
5739
|
+
<xsl:with-param name="tags" select="$tags"/>
|
5740
|
+
</xsl:call-template>
|
5741
|
+
</word>
|
5742
|
+
</xsl:when>
|
5743
|
+
<xsl:otherwise>
|
5744
|
+
<word>
|
5745
|
+
<xsl:call-template name="enclose_text_in_tags">
|
5746
|
+
<xsl:with-param name="text" select="normalize-space(substring-before($text, $separator))"/>
|
5747
|
+
<xsl:with-param name="tags" select="$tags"/>
|
5748
|
+
</xsl:call-template>
|
5749
|
+
</word>
|
5750
|
+
<xsl:call-template name="tokenize_with_tags">
|
5751
|
+
<xsl:with-param name="text" select="substring-after($text, $separator)"/>
|
5752
|
+
</xsl:call-template>
|
5753
|
+
</xsl:otherwise>
|
5754
|
+
</xsl:choose>
|
5755
|
+
</xsl:template><xsl:template name="enclose_text_in_tags">
|
5756
|
+
<xsl:param name="text"/>
|
5757
|
+
<xsl:param name="tags"/>
|
5758
|
+
<xsl:param name="num">1</xsl:param> <!-- default (start) value -->
|
5759
|
+
|
5760
|
+
<xsl:variable name="tag_name" select="normalize-space(xalan:nodeset($tags)//tag[$num])"/>
|
5761
|
+
|
5762
|
+
<xsl:choose>
|
5763
|
+
<xsl:when test="$tag_name = ''"><xsl:value-of select="$text"/></xsl:when>
|
5764
|
+
<xsl:otherwise>
|
5765
|
+
<xsl:element name="{$tag_name}">
|
5766
|
+
<xsl:call-template name="enclose_text_in_tags">
|
5767
|
+
<xsl:with-param name="text" select="$text"/>
|
5768
|
+
<xsl:with-param name="tags" select="$tags"/>
|
5769
|
+
<xsl:with-param name="num" select="$num + 1"/>
|
5770
|
+
</xsl:call-template>
|
5771
|
+
</xsl:element>
|
5772
|
+
</xsl:otherwise>
|
5773
|
+
</xsl:choose>
|
4987
5774
|
</xsl:template><xsl:template name="max_length">
|
4988
5775
|
<xsl:param name="words"/>
|
4989
5776
|
<xsl:for-each select="$words//word">
|
@@ -5056,36 +5843,47 @@
|
|
5056
5843
|
</xsl:template><xsl:template name="add-zero-spaces-equal">
|
5057
5844
|
<xsl:param name="text" select="."/>
|
5058
5845
|
<xsl:variable name="zero-space-after-equals">==========</xsl:variable>
|
5846
|
+
<xsl:variable name="regex_zero-space-after-equals">(==========)</xsl:variable>
|
5059
5847
|
<xsl:variable name="zero-space-after-equal">=</xsl:variable>
|
5848
|
+
<xsl:variable name="regex_zero-space-after-equal">(=)</xsl:variable>
|
5060
5849
|
<xsl:variable name="zero-space"></xsl:variable>
|
5061
5850
|
<xsl:choose>
|
5062
5851
|
<xsl:when test="contains($text, $zero-space-after-equals)">
|
5063
|
-
<xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
|
5852
|
+
<!-- <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
|
5064
5853
|
<xsl:value-of select="$zero-space-after-equals"/>
|
5065
5854
|
<xsl:value-of select="$zero-space"/>
|
5066
5855
|
<xsl:call-template name="add-zero-spaces-equal">
|
5067
5856
|
<xsl:with-param name="text" select="substring-after($text, $zero-space-after-equals)"/>
|
5068
|
-
</xsl:call-template>
|
5857
|
+
</xsl:call-template> -->
|
5858
|
+
<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equals,concat('$1',$zero_width_space))"/>
|
5069
5859
|
</xsl:when>
|
5070
5860
|
<xsl:when test="contains($text, $zero-space-after-equal)">
|
5071
|
-
<xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
|
5861
|
+
<!-- <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
|
5072
5862
|
<xsl:value-of select="$zero-space-after-equal"/>
|
5073
5863
|
<xsl:value-of select="$zero-space"/>
|
5074
5864
|
<xsl:call-template name="add-zero-spaces-equal">
|
5075
5865
|
<xsl:with-param name="text" select="substring-after($text, $zero-space-after-equal)"/>
|
5076
|
-
</xsl:call-template>
|
5866
|
+
</xsl:call-template> -->
|
5867
|
+
<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),$regex_zero-space-after-equal,concat('$1',$zero_width_space))"/>
|
5077
5868
|
</xsl:when>
|
5078
5869
|
<xsl:otherwise>
|
5079
5870
|
<xsl:value-of select="$text"/>
|
5080
5871
|
</xsl:otherwise>
|
5081
5872
|
</xsl:choose>
|
5082
5873
|
</xsl:template><xsl:template name="getSimpleTable">
|
5874
|
+
<xsl:param name="id"/>
|
5875
|
+
|
5083
5876
|
<xsl:variable name="simple-table">
|
5084
5877
|
|
5878
|
+
<!-- Step 0. replace <br/> to <p>...</p> -->
|
5879
|
+
<xsl:variable name="table_without_br">
|
5880
|
+
<xsl:apply-templates mode="table-without-br"/>
|
5881
|
+
</xsl:variable>
|
5882
|
+
|
5085
5883
|
<!-- Step 1. colspan processing -->
|
5086
5884
|
<xsl:variable name="simple-table-colspan">
|
5087
5885
|
<tbody>
|
5088
|
-
<xsl:apply-templates mode="simple-table-colspan"/>
|
5886
|
+
<xsl:apply-templates select="xalan:nodeset($table_without_br)" mode="simple-table-colspan"/>
|
5089
5887
|
</tbody>
|
5090
5888
|
</xsl:variable>
|
5091
5889
|
|
@@ -5094,10 +5892,67 @@
|
|
5094
5892
|
<xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
|
5095
5893
|
</xsl:variable>
|
5096
5894
|
|
5097
|
-
|
5098
|
-
|
5895
|
+
<!-- Step 3: add id to each cell -->
|
5896
|
+
<!-- add <word>...</word> for each word, image, math -->
|
5897
|
+
<xsl:variable name="simple-table-id">
|
5898
|
+
<xsl:apply-templates select="xalan:nodeset($simple-table-rowspan)" mode="simple-table-id">
|
5899
|
+
<xsl:with-param name="id" select="$id"/>
|
5900
|
+
</xsl:apply-templates>
|
5901
|
+
</xsl:variable>
|
5902
|
+
|
5903
|
+
<xsl:copy-of select="xalan:nodeset($simple-table-id)"/>
|
5904
|
+
|
5099
5905
|
</xsl:variable>
|
5100
5906
|
<xsl:copy-of select="$simple-table"/>
|
5907
|
+
</xsl:template><xsl:template match="@*|node()" mode="table-without-br">
|
5908
|
+
<xsl:copy>
|
5909
|
+
<xsl:apply-templates select="@*|node()" mode="table-without-br"/>
|
5910
|
+
</xsl:copy>
|
5911
|
+
</xsl:template><xsl:template match="*[local-name()='th' or local-name() = 'td'][not(*[local-name()='br']) and not(*[local-name()='p'])]" mode="table-without-br">
|
5912
|
+
<xsl:copy>
|
5913
|
+
<xsl:copy-of select="@*"/>
|
5914
|
+
<p>
|
5915
|
+
<xsl:copy-of select="node()"/>
|
5916
|
+
</p>
|
5917
|
+
</xsl:copy>
|
5918
|
+
</xsl:template><xsl:template match="*[local-name()='th' or local-name()='td'][*[local-name()='br']]" mode="table-without-br">
|
5919
|
+
<xsl:copy>
|
5920
|
+
<xsl:copy-of select="@*"/>
|
5921
|
+
<xsl:for-each select="*[local-name()='br']">
|
5922
|
+
<xsl:variable name="current_id" select="generate-id()"/>
|
5923
|
+
<p>
|
5924
|
+
<xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
|
5925
|
+
<xsl:copy-of select="."/>
|
5926
|
+
</xsl:for-each>
|
5927
|
+
</p>
|
5928
|
+
<xsl:if test="not(following-sibling::*[local-name() = 'br'])">
|
5929
|
+
<p>
|
5930
|
+
<xsl:for-each select="following-sibling::node()">
|
5931
|
+
<xsl:copy-of select="."/>
|
5932
|
+
</xsl:for-each>
|
5933
|
+
</p>
|
5934
|
+
</xsl:if>
|
5935
|
+
</xsl:for-each>
|
5936
|
+
</xsl:copy>
|
5937
|
+
</xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']/*[local-name() = 'p'][*[local-name()='br']]" mode="table-without-br">
|
5938
|
+
<xsl:for-each select="*[local-name()='br']">
|
5939
|
+
<xsl:variable name="current_id" select="generate-id()"/>
|
5940
|
+
<p>
|
5941
|
+
<xsl:for-each select="preceding-sibling::node()[following-sibling::*[local-name() = 'br'][1][generate-id() = $current_id]][not(local-name() = 'br')]">
|
5942
|
+
<xsl:copy-of select="."/>
|
5943
|
+
</xsl:for-each>
|
5944
|
+
</p>
|
5945
|
+
<xsl:if test="not(following-sibling::*[local-name() = 'br'])">
|
5946
|
+
<p>
|
5947
|
+
<xsl:for-each select="following-sibling::node()">
|
5948
|
+
<xsl:copy-of select="."/>
|
5949
|
+
</xsl:for-each>
|
5950
|
+
</p>
|
5951
|
+
</xsl:if>
|
5952
|
+
</xsl:for-each>
|
5953
|
+
</xsl:template><xsl:template match="text()[not(ancestor::*[local-name() = 'sourcecode'])]" mode="table-without-br">
|
5954
|
+
<xsl:variable name="text" select="translate(.,'	 ','')"/>
|
5955
|
+
<xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),' {2,}',' ')"/>
|
5101
5956
|
</xsl:template><xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
|
5102
5957
|
<xsl:apply-templates mode="simple-table-colspan"/>
|
5103
5958
|
</xsl:template><xsl:template match="*[local-name()='fn']" mode="simple-table-colspan"/><xsl:template match="*[local-name()='th'] | *[local-name()='td']" mode="simple-table-colspan">
|
@@ -5187,6 +6042,126 @@
|
|
5187
6042
|
<xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan">
|
5188
6043
|
<xsl:with-param name="previousRow" select="$newRow"/>
|
5189
6044
|
</xsl:apply-templates>
|
6045
|
+
</xsl:template><xsl:template match="/" mode="simple-table-id">
|
6046
|
+
<xsl:param name="id"/>
|
6047
|
+
<xsl:variable name="id_prefixed" select="concat('table_if_',$id)"/> <!-- table id prefixed by 'table_if_' to simple search in IF -->
|
6048
|
+
<xsl:apply-templates select="@*|node()" mode="simple-table-id">
|
6049
|
+
<xsl:with-param name="id" select="$id_prefixed"/>
|
6050
|
+
</xsl:apply-templates>
|
6051
|
+
</xsl:template><xsl:template match="@*|node()" mode="simple-table-id">
|
6052
|
+
<xsl:param name="id"/>
|
6053
|
+
<xsl:copy>
|
6054
|
+
<xsl:apply-templates select="@*|node()" mode="simple-table-id">
|
6055
|
+
<xsl:with-param name="id" select="$id"/>
|
6056
|
+
</xsl:apply-templates>
|
6057
|
+
</xsl:copy>
|
6058
|
+
</xsl:template><xsl:template match="*[local-name()='tbody']" mode="simple-table-id">
|
6059
|
+
<xsl:param name="id"/>
|
6060
|
+
<xsl:copy>
|
6061
|
+
<xsl:copy-of select="@*"/>
|
6062
|
+
<xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
|
6063
|
+
<xsl:apply-templates select="node()" mode="simple-table-id">
|
6064
|
+
<xsl:with-param name="id" select="$id"/>
|
6065
|
+
</xsl:apply-templates>
|
6066
|
+
</xsl:copy>
|
6067
|
+
</xsl:template><xsl:template match="*[local-name()='th' or local-name()='td']" mode="simple-table-id">
|
6068
|
+
<xsl:param name="id"/>
|
6069
|
+
<xsl:copy>
|
6070
|
+
<xsl:copy-of select="@*"/>
|
6071
|
+
<xsl:variable name="row_number" select="count(../preceding-sibling::*) + 1"/>
|
6072
|
+
<xsl:variable name="col_number" select="count(preceding-sibling::*) + 1"/>
|
6073
|
+
<xsl:attribute name="id">
|
6074
|
+
<xsl:value-of select="concat($id,'_',$row_number,'_',$col_number)"/>
|
6075
|
+
</xsl:attribute>
|
6076
|
+
|
6077
|
+
<xsl:for-each select="*[local-name() = 'p']">
|
6078
|
+
<xsl:copy>
|
6079
|
+
<xsl:copy-of select="@*"/>
|
6080
|
+
<xsl:variable name="p_num" select="count(preceding-sibling::*[local-name() = 'p']) + 1"/>
|
6081
|
+
<xsl:attribute name="id">
|
6082
|
+
<xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_p_',$p_num)"/>
|
6083
|
+
</xsl:attribute>
|
6084
|
+
|
6085
|
+
<xsl:copy-of select="node()"/>
|
6086
|
+
</xsl:copy>
|
6087
|
+
</xsl:for-each>
|
6088
|
+
|
6089
|
+
|
6090
|
+
<xsl:if test="$isGenerateTableIF = 'true'"> <!-- split each paragraph to words, image, math -->
|
6091
|
+
|
6092
|
+
<xsl:variable name="td_text">
|
6093
|
+
<xsl:apply-templates select="." mode="td_text_with_formatting"/>
|
6094
|
+
</xsl:variable>
|
6095
|
+
|
6096
|
+
<!-- td_text='<xsl:copy-of select="$td_text"/>' -->
|
6097
|
+
|
6098
|
+
<xsl:variable name="words">
|
6099
|
+
<xsl:for-each select=".//*[local-name() = 'image' or local-name() = 'stem']">
|
6100
|
+
<word>
|
6101
|
+
<xsl:copy-of select="."/>
|
6102
|
+
</word>
|
6103
|
+
</xsl:for-each>
|
6104
|
+
|
6105
|
+
<xsl:for-each select="xalan:nodeset($td_text)//*[local-name() = 'word'][normalize-space() != '']">
|
6106
|
+
<xsl:copy-of select="."/>
|
6107
|
+
</xsl:for-each>
|
6108
|
+
|
6109
|
+
</xsl:variable>
|
6110
|
+
|
6111
|
+
<xsl:for-each select="xalan:nodeset($words)/word">
|
6112
|
+
<xsl:variable name="num" select="count(preceding-sibling::word) + 1"/>
|
6113
|
+
<xsl:copy>
|
6114
|
+
<xsl:attribute name="id">
|
6115
|
+
<xsl:value-of select="concat($id,'_',$row_number,'_',$col_number,'_word_',$num)"/>
|
6116
|
+
</xsl:attribute>
|
6117
|
+
<xsl:copy-of select="node()"/>
|
6118
|
+
</xsl:copy>
|
6119
|
+
</xsl:for-each>
|
6120
|
+
</xsl:if>
|
6121
|
+
</xsl:copy>
|
6122
|
+
|
6123
|
+
</xsl:template><xsl:template match="@*|node()" mode="td_text_with_formatting">
|
6124
|
+
<xsl:copy>
|
6125
|
+
<xsl:apply-templates select="@*|node()" mode="td_text_with_formatting"/>
|
6126
|
+
</xsl:copy>
|
6127
|
+
</xsl:template><xsl:template match="*[local-name() = 'stem' or local-name() = 'image']" mode="td_text_with_formatting"/><xsl:template match="*[local-name() = 'keep-together_within-line']/text()" mode="td_text_with_formatting">
|
6128
|
+
<xsl:variable name="formatting_tags">
|
6129
|
+
<xsl:call-template name="getFormattingTags"/>
|
6130
|
+
</xsl:variable>
|
6131
|
+
<word>
|
6132
|
+
<xsl:call-template name="enclose_text_in_tags">
|
6133
|
+
<xsl:with-param name="text" select="normalize-space(.)"/>
|
6134
|
+
<xsl:with-param name="tags" select="$formatting_tags"/>
|
6135
|
+
</xsl:call-template>
|
6136
|
+
</word>
|
6137
|
+
</xsl:template><xsl:template match="*[local-name() != 'keep-together_within-line']/text()" mode="td_text_with_formatting">
|
6138
|
+
|
6139
|
+
<xsl:variable name="td_text" select="."/>
|
6140
|
+
|
6141
|
+
<xsl:variable name="string_with_added_zerospaces">
|
6142
|
+
<xsl:call-template name="add-zero-spaces-java">
|
6143
|
+
<xsl:with-param name="text" select="$td_text"/>
|
6144
|
+
</xsl:call-template>
|
6145
|
+
</xsl:variable>
|
6146
|
+
|
6147
|
+
<xsl:variable name="formatting_tags">
|
6148
|
+
<xsl:call-template name="getFormattingTags"/>
|
6149
|
+
</xsl:variable>
|
6150
|
+
|
6151
|
+
<!-- <word>text</word> -->
|
6152
|
+
<xsl:call-template name="tokenize_with_tags">
|
6153
|
+
<xsl:with-param name="tags" select="$formatting_tags"/>
|
6154
|
+
<xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '', ' '))"/> <!-- replace zero-width-space and soft-hyphen to space -->
|
6155
|
+
</xsl:call-template>
|
6156
|
+
</xsl:template><xsl:template name="getFormattingTags">
|
6157
|
+
<tags>
|
6158
|
+
<xsl:if test="ancestor::*[local-name() = 'strong']"><tag>strong</tag></xsl:if>
|
6159
|
+
<xsl:if test="ancestor::*[local-name() = 'em']"><tag>em</tag></xsl:if>
|
6160
|
+
<xsl:if test="ancestor::*[local-name() = 'sub']"><tag>sub</tag></xsl:if>
|
6161
|
+
<xsl:if test="ancestor::*[local-name() = 'sup']"><tag>sup</tag></xsl:if>
|
6162
|
+
<xsl:if test="ancestor::*[local-name() = 'tt']"><tag>tt</tag></xsl:if>
|
6163
|
+
<xsl:if test="ancestor::*[local-name() = 'keep-together_within-line']"><tag>keep-together_within-line</tag></xsl:if>
|
6164
|
+
</tags>
|
5190
6165
|
</xsl:template><xsl:template name="getLang">
|
5191
6166
|
<xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/>
|
5192
6167
|
<xsl:variable name="language">
|
@@ -5241,6 +6216,9 @@
|
|
5241
6216
|
<xsl:variable name="isDeleted" select="@deleted"/>
|
5242
6217
|
|
5243
6218
|
<fo:inline xsl:use-attribute-sets="mathml-style">
|
6219
|
+
|
6220
|
+
|
6221
|
+
|
5244
6222
|
|
5245
6223
|
|
5246
6224
|
<xsl:call-template name="setTrackChangesStyles">
|
@@ -5248,48 +6226,80 @@
|
|
5248
6226
|
<xsl:with-param name="isDeleted" select="$isDeleted"/>
|
5249
6227
|
</xsl:call-template>
|
5250
6228
|
|
6229
|
+
<xsl:if test="$add_math_as_text = 'true'">
|
6230
|
+
<!-- insert helper tag -->
|
6231
|
+
<!-- set unique font-size (fiction) -->
|
6232
|
+
<xsl:variable name="font-size_sfx"><xsl:number level="any"/></xsl:variable>
|
6233
|
+
<fo:inline color="white" font-size="1.{$font-size_sfx}pt" font-style="normal" font-weight="normal"><xsl:value-of select="$zero_width_space"/></fo:inline> <!-- zero width space -->
|
6234
|
+
</xsl:if>
|
5251
6235
|
|
5252
|
-
|
5253
|
-
|
5254
|
-
<xsl:apply-templates select="." mode="mathml"/>
|
6236
|
+
<xsl:variable name="mathml_content">
|
6237
|
+
<xsl:apply-templates select="." mode="mathml_actual_text"/>
|
5255
6238
|
</xsl:variable>
|
5256
|
-
<fo:instream-foreign-object fox:alt-text="Math">
|
5257
6239
|
|
6240
|
+
|
6241
|
+
<xsl:call-template name="mathml_instream_object">
|
6242
|
+
<xsl:with-param name="mathml_content" select="$mathml_content"/>
|
6243
|
+
</xsl:call-template>
|
5258
6244
|
|
5259
|
-
|
5260
|
-
<xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
|
5261
|
-
<xsl:variable name="comment_text_">
|
5262
|
-
<xsl:choose>
|
5263
|
-
<xsl:when test="normalize-space($comment_text_following) != ''">
|
5264
|
-
<xsl:value-of select="$comment_text_following"/>
|
5265
|
-
</xsl:when>
|
5266
|
-
<xsl:otherwise>
|
5267
|
-
<xsl:value-of select="normalize-space(translate(.,' ',' '))"/>
|
5268
|
-
</xsl:otherwise>
|
5269
|
-
</xsl:choose>
|
5270
|
-
</xsl:variable>
|
5271
|
-
<xsl:variable name="comment_text" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
|
5272
|
-
|
5273
|
-
<xsl:if test="normalize-space($comment_text) != ''">
|
5274
|
-
<!-- put Mathin Alternate Text -->
|
5275
|
-
<xsl:attribute name="fox:alt-text">
|
5276
|
-
<xsl:value-of select="java:org.metanorma.fop.Util.unescape($comment_text)"/>
|
5277
|
-
</xsl:attribute>
|
5278
|
-
</xsl:if>
|
5279
|
-
|
5280
|
-
<xsl:variable name="mathml_content">
|
5281
|
-
<xsl:apply-templates select="." mode="mathml_actual_text"/>
|
5282
|
-
</xsl:variable>
|
5283
|
-
<!-- put MathML in Actual Text -->
|
5284
|
-
<xsl:attribute name="fox:actual-text">
|
5285
|
-
<xsl:value-of select="$mathml_content"/>
|
5286
|
-
</xsl:attribute>
|
5287
|
-
|
5288
|
-
|
5289
|
-
|
5290
|
-
<xsl:copy-of select="xalan:nodeset($mathml)"/>
|
5291
|
-
</fo:instream-foreign-object>
|
6245
|
+
|
5292
6246
|
</fo:inline>
|
6247
|
+
</xsl:template><xsl:template name="getMathml_comment_text">
|
6248
|
+
<xsl:variable name="comment_text_following" select="following-sibling::node()[1][self::comment()]"/>
|
6249
|
+
<xsl:variable name="comment_text_">
|
6250
|
+
<xsl:choose>
|
6251
|
+
<xsl:when test="normalize-space($comment_text_following) != ''">
|
6252
|
+
<xsl:value-of select="$comment_text_following"/>
|
6253
|
+
</xsl:when>
|
6254
|
+
<xsl:otherwise>
|
6255
|
+
<xsl:value-of select="normalize-space(translate(.,' ',' '))"/>
|
6256
|
+
</xsl:otherwise>
|
6257
|
+
</xsl:choose>
|
6258
|
+
</xsl:variable>
|
6259
|
+
<xsl:variable name="comment_text_2" select="java:org.metanorma.fop.Util.unescape($comment_text_)"/>
|
6260
|
+
<xsl:variable name="comment_text" select="java:trim(java:java.lang.String.new($comment_text_2))"/>
|
6261
|
+
<xsl:value-of select="$comment_text"/>
|
6262
|
+
</xsl:template><xsl:template name="mathml_instream_object">
|
6263
|
+
<xsl:param name="comment_text"/>
|
6264
|
+
<xsl:param name="mathml_content"/>
|
6265
|
+
|
6266
|
+
<xsl:variable name="comment_text_">
|
6267
|
+
<xsl:choose>
|
6268
|
+
<xsl:when test="normalize-space($comment_text) != ''"><xsl:value-of select="$comment_text"/></xsl:when>
|
6269
|
+
<xsl:otherwise><xsl:call-template name="getMathml_comment_text"/></xsl:otherwise>
|
6270
|
+
</xsl:choose>
|
6271
|
+
</xsl:variable>
|
6272
|
+
|
6273
|
+
<xsl:variable name="mathml">
|
6274
|
+
<xsl:apply-templates select="." mode="mathml"/>
|
6275
|
+
</xsl:variable>
|
6276
|
+
|
6277
|
+
<fo:instream-foreign-object fox:alt-text="Math">
|
6278
|
+
|
6279
|
+
|
6280
|
+
|
6281
|
+
|
6282
|
+
|
6283
|
+
|
6284
|
+
|
6285
|
+
<!-- put MathML in Actual Text -->
|
6286
|
+
<!-- DEBUG: mathml_content=<xsl:value-of select="$mathml_content"/> -->
|
6287
|
+
<xsl:attribute name="fox:actual-text">
|
6288
|
+
<xsl:value-of select="$mathml_content"/>
|
6289
|
+
</xsl:attribute>
|
6290
|
+
|
6291
|
+
<!-- <xsl:if test="$add_math_as_text = 'true'"> -->
|
6292
|
+
<xsl:if test="normalize-space($comment_text_) != ''">
|
6293
|
+
<!-- put Mathin Alternate Text -->
|
6294
|
+
<xsl:attribute name="fox:alt-text">
|
6295
|
+
<xsl:value-of select="$comment_text_"/>
|
6296
|
+
</xsl:attribute>
|
6297
|
+
</xsl:if>
|
6298
|
+
<!-- </xsl:if> -->
|
6299
|
+
|
6300
|
+
<xsl:copy-of select="xalan:nodeset($mathml)"/>
|
6301
|
+
|
6302
|
+
</fo:instream-foreign-object>
|
5293
6303
|
</xsl:template><xsl:template match="mathml:*" mode="mathml_actual_text">
|
5294
6304
|
<!-- <xsl:text>a+b</xsl:text> -->
|
5295
6305
|
<xsl:text><</xsl:text>
|
@@ -5320,7 +6330,9 @@
|
|
5320
6330
|
<!-- replace start and end spaces to non-break space -->
|
5321
6331
|
<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/>
|
5322
6332
|
</xsl:copy>
|
5323
|
-
</xsl:template><xsl:template match="mathml:math/*[local-name()='unit']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='prefix']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='dimension']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='quantity']" mode="mathml"/><xsl:template match="
|
6333
|
+
</xsl:template><xsl:template match="mathml:math/*[local-name()='unit']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='prefix']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='dimension']" mode="mathml"/><xsl:template match="mathml:math/*[local-name()='quantity']" mode="mathml"/><xsl:template match="mathml:mtd/mathml:mo/text()[. = '/']" mode="mathml">
|
6334
|
+
<xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
|
6335
|
+
</xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link">
|
5324
6336
|
<xsl:variable name="target">
|
5325
6337
|
<xsl:choose>
|
5326
6338
|
<xsl:when test="@updatetype = 'true'">
|
@@ -5553,7 +6565,12 @@
|
|
5553
6565
|
|
5554
6566
|
<fo:inline xsl:use-attribute-sets="termnote-name-style">
|
5555
6567
|
|
6568
|
+
<xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])">
|
6569
|
+
<xsl:attribute name="padding-right">1mm</xsl:attribute>
|
6570
|
+
</xsl:if>
|
6571
|
+
|
5556
6572
|
|
6573
|
+
|
5557
6574
|
|
5558
6575
|
<!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
|
5559
6576
|
<!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
|
@@ -5912,18 +6929,33 @@
|
|
5912
6929
|
</xsl:template><xsl:template match="*[local-name() = 'svg'][not(@width and @height)]" mode="svg_update">
|
5913
6930
|
<xsl:copy>
|
5914
6931
|
<xsl:apply-templates select="@*" mode="svg_update"/>
|
5915
|
-
<xsl:variable name="
|
6932
|
+
<xsl:variable name="viewbox_">
|
5916
6933
|
<xsl:call-template name="split">
|
5917
6934
|
<xsl:with-param name="pText" select="@viewBox"/>
|
5918
6935
|
<xsl:with-param name="sep" select="' '"/>
|
5919
6936
|
</xsl:call-template>
|
5920
6937
|
</xsl:variable>
|
6938
|
+
<xsl:variable name="viewbox" select="xalan:nodeset($viewbox_)"/>
|
6939
|
+
<xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
|
6940
|
+
<xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
|
6941
|
+
|
5921
6942
|
<xsl:attribute name="width">
|
5922
|
-
<xsl:
|
6943
|
+
<xsl:choose>
|
6944
|
+
<xsl:when test="$width != ''">
|
6945
|
+
<xsl:value-of select="round($width)"/>
|
6946
|
+
</xsl:when>
|
6947
|
+
<xsl:otherwise>400</xsl:otherwise> <!-- default width -->
|
6948
|
+
</xsl:choose>
|
5923
6949
|
</xsl:attribute>
|
5924
6950
|
<xsl:attribute name="height">
|
5925
|
-
<xsl:
|
6951
|
+
<xsl:choose>
|
6952
|
+
<xsl:when test="$height != ''">
|
6953
|
+
<xsl:value-of select="round($height)"/>
|
6954
|
+
</xsl:when>
|
6955
|
+
<xsl:otherwise>400</xsl:otherwise> <!-- default height -->
|
6956
|
+
</xsl:choose>
|
5926
6957
|
</xsl:attribute>
|
6958
|
+
|
5927
6959
|
<xsl:apply-templates mode="svg_update"/>
|
5928
6960
|
</xsl:copy>
|
5929
6961
|
</xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'image'][*[local-name() = 'svg']]" priority="3">
|
@@ -6118,7 +7150,11 @@
|
|
6118
7150
|
<xsl:apply-templates mode="bookmarks"/>
|
6119
7151
|
</xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents">
|
6120
7152
|
<xsl:apply-templates select="."/>
|
6121
|
-
</xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/><xsl:template match="*[local-name() = 'references']/*[local-name() = 'bibitem']" mode="contents"/><xsl:template match="*[local-name() = '
|
7153
|
+
</xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/><xsl:template match="*[local-name() = 'references']/*[local-name() = 'bibitem']" mode="contents"/><xsl:template match="*[local-name() = 'span']" mode="contents">
|
7154
|
+
<xsl:apply-templates mode="contents"/>
|
7155
|
+
</xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
|
7156
|
+
<xsl:apply-templates mode="bookmarks"/>
|
7157
|
+
</xsl:template><xsl:template match="*[local-name() = 'span']" mode="bookmarks">
|
6122
7158
|
<xsl:apply-templates mode="bookmarks"/>
|
6123
7159
|
</xsl:template><xsl:template name="addBookmarks">
|
6124
7160
|
<xsl:param name="contents"/>
|
@@ -6409,7 +7445,9 @@
|
|
6409
7445
|
<xsl:apply-templates/>
|
6410
7446
|
</xsl:otherwise>
|
6411
7447
|
</xsl:choose>
|
6412
|
-
</xsl:template><xsl:template match="*[local-name() = 'fn']" mode="contents"/><xsl:template match="*[local-name() = 'fn']" mode="bookmarks"/><xsl:template match="*[local-name() = 'fn']" mode="contents_item"/><xsl:template match="*[local-name() = '
|
7448
|
+
</xsl:template><xsl:template match="*[local-name() = 'fn']" mode="contents"/><xsl:template match="*[local-name() = 'fn']" mode="bookmarks"/><xsl:template match="*[local-name() = 'fn']" mode="contents_item"/><xsl:template match="*[local-name() = 'xref']" mode="contents">
|
7449
|
+
<xsl:value-of select="."/>
|
7450
|
+
</xsl:template><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
|
6413
7451
|
<xsl:text> </xsl:text>
|
6414
7452
|
</xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
|
6415
7453
|
<xsl:copy>
|
@@ -6440,9 +7478,22 @@
|
|
6440
7478
|
</xsl:when>
|
6441
7479
|
<xsl:otherwise><xsl:apply-templates mode="contents_item"/></xsl:otherwise>
|
6442
7480
|
</xsl:choose>
|
7481
|
+
</xsl:template><xsl:template match="text()" mode="contents_item">
|
7482
|
+
<xsl:call-template name="keep_together_standard_number"/>
|
7483
|
+
</xsl:template><xsl:template match="*[local-name() = 'span']" mode="contents_item">
|
7484
|
+
<xsl:apply-templates mode="contents_item"/>
|
6443
7485
|
</xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode">
|
6444
7486
|
|
6445
7487
|
<fo:block-container xsl:use-attribute-sets="sourcecode-container-style">
|
7488
|
+
|
7489
|
+
<xsl:if test="not(ancestor::*[local-name() = 'li']) or ancestor::*[local-name() = 'example']">
|
7490
|
+
<xsl:attribute name="margin-left">0mm</xsl:attribute>
|
7491
|
+
</xsl:if>
|
7492
|
+
|
7493
|
+
<xsl:if test="ancestor::*[local-name() = 'example']">
|
7494
|
+
<xsl:attribute name="margin-right">0mm</xsl:attribute>
|
7495
|
+
</xsl:if>
|
7496
|
+
|
6446
7497
|
<xsl:copy-of select="@id"/>
|
6447
7498
|
|
6448
7499
|
<xsl:if test="parent::*[local-name() = 'note']">
|
@@ -6542,17 +7593,15 @@
|
|
6542
7593
|
|
6543
7594
|
<!-- split text by zero-width space -->
|
6544
7595
|
<xsl:variable name="text_step4">
|
6545
|
-
<xsl:call-template name="
|
7596
|
+
<xsl:call-template name="split_for_interspers">
|
6546
7597
|
<xsl:with-param name="pText" select="$text_step3"/>
|
6547
7598
|
<xsl:with-param name="sep" select="$zero_width_space"/>
|
6548
|
-
<xsl:with-param name="normalize-space">false</xsl:with-param>
|
6549
|
-
<xsl:with-param name="keep_sep">true</xsl:with-param>
|
6550
7599
|
</xsl:call-template>
|
6551
7600
|
</xsl:variable>
|
6552
7601
|
|
6553
|
-
<xsl:for-each select="xalan:nodeset($text_step4)/
|
7602
|
+
<xsl:for-each select="xalan:nodeset($text_step4)/node()">
|
6554
7603
|
<xsl:choose>
|
6555
|
-
<xsl:when test="
|
7604
|
+
<xsl:when test="local-name() = 'interspers'"> <!-- word with length more than 30 will be interspersed with zero-width space -->
|
6556
7605
|
<xsl:call-template name="interspers">
|
6557
7606
|
<xsl:with-param name="str" select="."/>
|
6558
7607
|
</xsl:call-template>
|
@@ -6563,6 +7612,30 @@
|
|
6563
7612
|
</xsl:choose>
|
6564
7613
|
</xsl:for-each>
|
6565
7614
|
|
7615
|
+
</xsl:template><xsl:variable name="interspers_tag_open">###interspers123###</xsl:variable><xsl:variable name="interspers_tag_close">###/interspers123###</xsl:variable><xsl:template name="split_for_interspers">
|
7616
|
+
<xsl:param name="pText" select="."/>
|
7617
|
+
<xsl:param name="sep" select="','"/>
|
7618
|
+
<!-- word with length more than 30 will be interspersed with zero-width space -->
|
7619
|
+
<xsl:variable name="regex" select="concat('([^', $zero_width_space, ']{31,})')"/> <!-- sequence of characters (more 31), that doesn't contains zero-width space -->
|
7620
|
+
<xsl:variable name="text" select="java:replaceAll(java:java.lang.String.new($pText),$regex,concat($interspers_tag_open,'$1',$interspers_tag_close))"/>
|
7621
|
+
<xsl:call-template name="replace_tag_interspers">
|
7622
|
+
<xsl:with-param name="text" select="$text"/>
|
7623
|
+
</xsl:call-template>
|
7624
|
+
</xsl:template><xsl:template name="replace_tag_interspers">
|
7625
|
+
<xsl:param name="text"/>
|
7626
|
+
<xsl:choose>
|
7627
|
+
<xsl:when test="contains($text, $interspers_tag_open)">
|
7628
|
+
<xsl:value-of select="substring-before($text, $interspers_tag_open)"/>
|
7629
|
+
<xsl:variable name="text_after" select="substring-after($text, $interspers_tag_open)"/>
|
7630
|
+
<interspers>
|
7631
|
+
<xsl:value-of select="substring-before($text_after, $interspers_tag_close)"/>
|
7632
|
+
</interspers>
|
7633
|
+
<xsl:call-template name="replace_tag_interspers">
|
7634
|
+
<xsl:with-param name="text" select="substring-after($text_after, $interspers_tag_close)"/>
|
7635
|
+
</xsl:call-template>
|
7636
|
+
</xsl:when>
|
7637
|
+
<xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
|
7638
|
+
</xsl:choose>
|
6566
7639
|
</xsl:template><xsl:template name="interspers">
|
6567
7640
|
<xsl:param name="str"/>
|
6568
7641
|
<xsl:param name="char" select="$zero_width_space"/>
|
@@ -6791,7 +7864,9 @@
|
|
6791
7864
|
<!-- <xsl:attribute name="border">0.5pt solid black</xsl:attribute> -->
|
6792
7865
|
</xsl:if>
|
6793
7866
|
<xsl:variable name="simple-table">
|
6794
|
-
<xsl:call-template name="getSimpleTable"
|
7867
|
+
<xsl:call-template name="getSimpleTable">
|
7868
|
+
<xsl:with-param name="id" select="@id"/>
|
7869
|
+
</xsl:call-template>
|
6795
7870
|
</xsl:variable>
|
6796
7871
|
<xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/>
|
6797
7872
|
<xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])">
|
@@ -6898,11 +7973,13 @@
|
|
6898
7973
|
</xsl:otherwise>
|
6899
7974
|
</xsl:choose>
|
6900
7975
|
</xsl:template><xsl:template match="*[local-name() = 'example']">
|
6901
|
-
|
6902
|
-
|
7976
|
+
|
7977
|
+
<fo:block-container id="{@id}" xsl:use-attribute-sets="example-style">
|
7978
|
+
|
6903
7979
|
|
7980
|
+
|
6904
7981
|
<xsl:variable name="fo_element">
|
6905
|
-
<xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl']">block</xsl:if>
|
7982
|
+
<xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if>
|
6906
7983
|
|
6907
7984
|
<xsl:choose>
|
6908
7985
|
<!-- if example contains only one (except 'name') element (paragraph for example), then display it on the same line as EXAMPLE title -->
|
@@ -6912,31 +7989,57 @@
|
|
6912
7989
|
|
6913
7990
|
</xsl:variable>
|
6914
7991
|
|
6915
|
-
|
6916
|
-
<xsl:apply-templates select="*[local-name()='name']">
|
6917
|
-
<xsl:with-param name="fo_element" select="$fo_element"/>
|
6918
|
-
</xsl:apply-templates>
|
7992
|
+
<fo:block-container margin-left="0mm">
|
6919
7993
|
|
6920
|
-
|
6921
|
-
|
6922
|
-
<
|
6923
|
-
|
6924
|
-
|
7994
|
+
<xsl:choose>
|
7995
|
+
|
7996
|
+
<xsl:when test="contains(normalize-space($fo_element), 'block')">
|
7997
|
+
|
7998
|
+
<!-- display name 'EXAMPLE' in a separate block -->
|
7999
|
+
<fo:block>
|
8000
|
+
<xsl:apply-templates select="*[local-name()='name']">
|
6925
8001
|
<xsl:with-param name="fo_element" select="$fo_element"/>
|
6926
8002
|
</xsl:apply-templates>
|
8003
|
+
</fo:block>
|
8004
|
+
|
8005
|
+
<fo:block-container xsl:use-attribute-sets="example-body-style">
|
8006
|
+
<fo:block-container margin-left="0mm" margin-right="0mm">
|
8007
|
+
<xsl:apply-templates select="node()[not(local-name() = 'name')]">
|
8008
|
+
<xsl:with-param name="fo_element" select="$fo_element"/>
|
8009
|
+
</xsl:apply-templates>
|
8010
|
+
</fo:block-container>
|
6927
8011
|
</fo:block-container>
|
6928
|
-
</
|
6929
|
-
|
6930
|
-
|
6931
|
-
|
6932
|
-
|
6933
|
-
|
6934
|
-
|
6935
|
-
|
6936
|
-
|
6937
|
-
|
6938
|
-
|
6939
|
-
|
8012
|
+
</xsl:when> <!-- end block -->
|
8013
|
+
|
8014
|
+
<xsl:otherwise> <!-- inline -->
|
8015
|
+
|
8016
|
+
<!-- display 'EXAMPLE' and first element in the same line -->
|
8017
|
+
<fo:block>
|
8018
|
+
<xsl:apply-templates select="*[local-name()='name']">
|
8019
|
+
<xsl:with-param name="fo_element" select="$fo_element"/>
|
8020
|
+
</xsl:apply-templates>
|
8021
|
+
<fo:inline>
|
8022
|
+
<xsl:apply-templates select="*[not(local-name() = 'name')][1]">
|
8023
|
+
<xsl:with-param name="fo_element" select="$fo_element"/>
|
8024
|
+
</xsl:apply-templates>
|
8025
|
+
</fo:inline>
|
8026
|
+
</fo:block>
|
8027
|
+
|
8028
|
+
<xsl:if test="*[not(local-name() = 'name')][position() > 1]">
|
8029
|
+
<!-- display further elements in blocks -->
|
8030
|
+
<fo:block-container xsl:use-attribute-sets="example-body-style">
|
8031
|
+
<fo:block-container margin-left="0mm" margin-right="0mm">
|
8032
|
+
<xsl:apply-templates select="*[not(local-name() = 'name')][position() > 1]">
|
8033
|
+
<xsl:with-param name="fo_element" select="'block'"/>
|
8034
|
+
</xsl:apply-templates>
|
8035
|
+
</fo:block-container>
|
8036
|
+
</fo:block-container>
|
8037
|
+
</xsl:if>
|
8038
|
+
</xsl:otherwise> <!-- end inline -->
|
8039
|
+
|
8040
|
+
</xsl:choose>
|
8041
|
+
</fo:block-container>
|
8042
|
+
</fo:block-container>
|
6940
8043
|
</xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']">
|
6941
8044
|
<xsl:param name="fo_element">block</xsl:param>
|
6942
8045
|
|
@@ -6968,10 +8071,16 @@
|
|
6968
8071
|
</xsl:variable>
|
6969
8072
|
<xsl:choose>
|
6970
8073
|
<xsl:when test="starts-with(normalize-space($element), 'block')">
|
6971
|
-
<fo:block
|
6972
|
-
|
6973
|
-
|
6974
|
-
|
8074
|
+
<fo:block-container>
|
8075
|
+
<xsl:if test="ancestor::*[local-name() = 'li'] and contains(normalize-space($fo_element), 'block')">
|
8076
|
+
<xsl:attribute name="margin-left">0mm</xsl:attribute>
|
8077
|
+
<xsl:attribute name="margin-right">0mm</xsl:attribute>
|
8078
|
+
</xsl:if>
|
8079
|
+
<fo:block xsl:use-attribute-sets="example-p-style">
|
8080
|
+
|
8081
|
+
<xsl:apply-templates/>
|
8082
|
+
</fo:block>
|
8083
|
+
</fo:block-container>
|
6975
8084
|
</xsl:when>
|
6976
8085
|
<xsl:otherwise>
|
6977
8086
|
<fo:inline xsl:use-attribute-sets="example-p-style">
|
@@ -7016,7 +8125,7 @@
|
|
7016
8125
|
</xsl:otherwise>
|
7017
8126
|
</xsl:choose> -->
|
7018
8127
|
</fo:block>
|
7019
|
-
</xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ')]" priority="2">
|
8128
|
+
</xsl:template><xsl:template match="*[local-name() = 'termsource']/text()[starts-with(., '[SOURCE: Adapted from: ') or starts-with(., '[SOURCE: Quoted from: ') or starts-with(., '[SOURCE: Modified from: ')]" priority="2">
|
7020
8129
|
<xsl:text>[</xsl:text><xsl:value-of select="substring-after(., '[SOURCE: ')"/>
|
7021
8130
|
</xsl:template><xsl:template match="*[local-name() = 'termsource']/text()">
|
7022
8131
|
<xsl:if test="normalize-space() != ''">
|
@@ -7150,7 +8259,16 @@
|
|
7150
8259
|
</fo:inline>
|
7151
8260
|
</xsl:when>
|
7152
8261
|
<xsl:otherwise> <!-- if there is key('bibitems_hidden', $current_bibitemid) -->
|
7153
|
-
|
8262
|
+
|
8263
|
+
<!-- if in bibitem[@hidden='true'] there is url[@type='src'], then create hyperlink -->
|
8264
|
+
<xsl:variable name="uri_src" select="normalize-space($bibitems_hidden/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'src'])"/>
|
8265
|
+
<xsl:choose>
|
8266
|
+
<xsl:when test="$uri_src != ''">
|
8267
|
+
<fo:basic-link external-destination="{$uri_src}" fox:alt-text="{$uri_src}"><xsl:apply-templates/></fo:basic-link>
|
8268
|
+
</xsl:when>
|
8269
|
+
<xsl:otherwise><fo:inline><xsl:apply-templates/></fo:inline></xsl:otherwise>
|
8270
|
+
</xsl:choose>
|
8271
|
+
|
7154
8272
|
</xsl:otherwise>
|
7155
8273
|
</xsl:choose>
|
7156
8274
|
</xsl:template><xsl:template match="*[local-name() = 'tab']">
|
@@ -7327,10 +8445,24 @@
|
|
7327
8445
|
|
7328
8446
|
</fo:block>
|
7329
8447
|
<xsl:apply-templates/>
|
7330
|
-
</xsl:template><xsl:template match="*[local-name() = 'review']">
|
8448
|
+
</xsl:template><xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl -->
|
7331
8449
|
<!-- comment 2019-11-29 -->
|
7332
8450
|
<!-- <fo:block font-weight="bold">Review:</fo:block>
|
7333
8451
|
<xsl:apply-templates /> -->
|
8452
|
+
|
8453
|
+
<xsl:variable name="id_from" select="normalize-space(current()/@from)"/>
|
8454
|
+
|
8455
|
+
<xsl:choose>
|
8456
|
+
<!-- if there isn't the attribute '@from', then -->
|
8457
|
+
<xsl:when test="$id_from = ''">
|
8458
|
+
<fo:block id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
|
8459
|
+
</xsl:when>
|
8460
|
+
<!-- if there isn't element with id 'from', then create 'bookmark' here -->
|
8461
|
+
<xsl:when test="not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
|
8462
|
+
<fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
|
8463
|
+
</xsl:when>
|
8464
|
+
</xsl:choose>
|
8465
|
+
|
7334
8466
|
</xsl:template><xsl:template match="*[local-name() = 'name']/text()">
|
7335
8467
|
<!-- 0xA0 to space replacement -->
|
7336
8468
|
<xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/>
|
@@ -7696,7 +8828,10 @@
|
|
7696
8828
|
<!-- to split by '_' and other chars -->
|
7697
8829
|
<xsl:call-template name="add-zero-spaces-java"/>
|
7698
8830
|
</xsl:template><xsl:template match="*[local-name() = 'bookmark']" name="bookmark">
|
7699
|
-
<fo:inline id="{@id}" font-size="1pt"/>
|
8831
|
+
<!-- <fo:inline id="{@id}" font-size="1pt"/> -->
|
8832
|
+
<fo:inline id="{@id}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:inline>
|
8833
|
+
<!-- we need to add zero-width space, otherwise this fo:inline is missing in IF xml -->
|
8834
|
+
<xsl:if test="not(following-sibling::node()[normalize-space() != ''])"><fo:inline font-size="1pt"> </fo:inline></xsl:if>
|
7700
8835
|
</xsl:template><xsl:template match="*[local-name() = 'errata']">
|
7701
8836
|
<!-- <row>
|
7702
8837
|
<date>05-07-2013</date>
|
@@ -8242,6 +9377,120 @@
|
|
8242
9377
|
<xsl:apply-templates select="." mode="update_xml_step1"/>
|
8243
9378
|
</xsl:for-each>
|
8244
9379
|
</xsl:copy>
|
9380
|
+
</xsl:template><xsl:template match="*[local-name() = 'span']" mode="update_xml_step1">
|
9381
|
+
<xsl:apply-templates mode="update_xml_step1"/>
|
9382
|
+
</xsl:template><xsl:template match="@*|node()" mode="update_xml_enclose_keep-together_within-line">
|
9383
|
+
<xsl:copy>
|
9384
|
+
<xsl:apply-templates select="@*|node()" mode="update_xml_enclose_keep-together_within-line"/>
|
9385
|
+
</xsl:copy>
|
9386
|
+
</xsl:template><xsl:variable name="express_reference_separators">_.\</xsl:variable><xsl:variable name="express_reference_characters" select="concat($upper,$lower,'1234567890',$express_reference_separators)"/><xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable><xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'])]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line">
|
9387
|
+
|
9388
|
+
<!-- enclose standard's number into tag 'keep-together_within-line' -->
|
9389
|
+
<xsl:variable name="regex_standard_reference">([A-Z]{2,}(/[A-Z]{2,})* \d+(-\d+)*(:\d{4})?)</xsl:variable>
|
9390
|
+
<xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
|
9391
|
+
<xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable>
|
9392
|
+
<xsl:variable name="text_" select="java:replaceAll(java:java.lang.String.new(.),$regex_standard_reference,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
|
9393
|
+
<xsl:variable name="text"><text><xsl:call-template name="replace_text_tags">
|
9394
|
+
<xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
|
9395
|
+
<xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
|
9396
|
+
<xsl:with-param name="text" select="$text_"/>
|
9397
|
+
</xsl:call-template></text></xsl:variable>
|
9398
|
+
|
9399
|
+
<xsl:variable name="parent" select="local-name(..)"/>
|
9400
|
+
|
9401
|
+
<xsl:variable name="text2">
|
9402
|
+
<text><xsl:for-each select="xalan:nodeset($text)/text/node()">
|
9403
|
+
<xsl:copy-of select="."/>
|
9404
|
+
</xsl:for-each></text>
|
9405
|
+
</xsl:variable>
|
9406
|
+
|
9407
|
+
<!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b -->
|
9408
|
+
<xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable>
|
9409
|
+
<xsl:variable name="text3">
|
9410
|
+
<text><xsl:for-each select="xalan:nodeset($text2)/text/node()">
|
9411
|
+
<xsl:choose>
|
9412
|
+
<xsl:when test="self::text()">
|
9413
|
+
<xsl:variable name="text_units_" select="java:replaceAll(java:java.lang.String.new(.),$regex_solidus_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
|
9414
|
+
<xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags">
|
9415
|
+
<xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
|
9416
|
+
<xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
|
9417
|
+
<xsl:with-param name="text" select="$text_units_"/>
|
9418
|
+
</xsl:call-template></text></xsl:variable>
|
9419
|
+
<xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/>
|
9420
|
+
</xsl:when>
|
9421
|
+
<xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
|
9422
|
+
</xsl:choose>
|
9423
|
+
</xsl:for-each></text>
|
9424
|
+
</xsl:variable>
|
9425
|
+
|
9426
|
+
<xsl:choose>
|
9427
|
+
<xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']">
|
9428
|
+
<!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY -->
|
9429
|
+
<xsl:variable name="regex_dots_units">((\b((\S{1,3}\.\S+)|(\S+\.\S{1,3}))\b)|(\.\S{1,3})\b)</xsl:variable>
|
9430
|
+
<xsl:for-each select="xalan:nodeset($text3)/text/node()">
|
9431
|
+
<xsl:choose>
|
9432
|
+
<xsl:when test="self::text()">
|
9433
|
+
<xsl:variable name="text_dots_" select="java:replaceAll(java:java.lang.String.new(.),$regex_dots_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/>
|
9434
|
+
<xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags">
|
9435
|
+
<xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/>
|
9436
|
+
<xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/>
|
9437
|
+
<xsl:with-param name="text" select="$text_dots_"/>
|
9438
|
+
</xsl:call-template></text></xsl:variable>
|
9439
|
+
<xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/>
|
9440
|
+
</xsl:when>
|
9441
|
+
<xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... -->
|
9442
|
+
</xsl:choose>
|
9443
|
+
</xsl:for-each>
|
9444
|
+
</xsl:when>
|
9445
|
+
<xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise>
|
9446
|
+
</xsl:choose>
|
9447
|
+
|
9448
|
+
</xsl:template><xsl:template name="replace_text_tags">
|
9449
|
+
<xsl:param name="tag_open"/>
|
9450
|
+
<xsl:param name="tag_close"/>
|
9451
|
+
<xsl:param name="text"/>
|
9452
|
+
<xsl:choose>
|
9453
|
+
<xsl:when test="contains($text, $tag_open)">
|
9454
|
+
<xsl:value-of select="substring-before($text, $tag_open)"/>
|
9455
|
+
<xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
|
9456
|
+
|
9457
|
+
<xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
|
9458
|
+
<xsl:value-of select="substring-before($text_after, $tag_close)"/>
|
9459
|
+
</xsl:element>
|
9460
|
+
|
9461
|
+
<xsl:call-template name="replace_text_tags">
|
9462
|
+
<xsl:with-param name="tag_open" select="$tag_open"/>
|
9463
|
+
<xsl:with-param name="tag_close" select="$tag_close"/>
|
9464
|
+
<xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
|
9465
|
+
</xsl:call-template>
|
9466
|
+
</xsl:when>
|
9467
|
+
<xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
|
9468
|
+
</xsl:choose>
|
9469
|
+
</xsl:template><xsl:template name="printEdition">
|
9470
|
+
<xsl:variable name="edition_i18n" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
|
9471
|
+
<xsl:text> </xsl:text>
|
9472
|
+
<xsl:choose>
|
9473
|
+
<xsl:when test="$edition_i18n != ''">
|
9474
|
+
<!-- Example: <edition language="fr">deuxième édition</edition> -->
|
9475
|
+
<xsl:call-template name="capitalize">
|
9476
|
+
<xsl:with-param name="str" select="$edition_i18n"/>
|
9477
|
+
</xsl:call-template>
|
9478
|
+
</xsl:when>
|
9479
|
+
<xsl:otherwise>
|
9480
|
+
<xsl:variable name="edition" select="normalize-space((//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'])"/>
|
9481
|
+
<xsl:if test="$edition != ''"> <!-- Example: 1.3 -->
|
9482
|
+
<xsl:call-template name="capitalize">
|
9483
|
+
<xsl:with-param name="str">
|
9484
|
+
<xsl:call-template name="getLocalizedString">
|
9485
|
+
<xsl:with-param name="key">edition</xsl:with-param>
|
9486
|
+
</xsl:call-template>
|
9487
|
+
</xsl:with-param>
|
9488
|
+
</xsl:call-template>
|
9489
|
+
<xsl:text> </xsl:text>
|
9490
|
+
<xsl:value-of select="$edition"/>
|
9491
|
+
</xsl:if>
|
9492
|
+
</xsl:otherwise>
|
9493
|
+
</xsl:choose>
|
8245
9494
|
</xsl:template><xsl:template name="convertDate">
|
8246
9495
|
<xsl:param name="date"/>
|
8247
9496
|
<xsl:param name="format" select="'short'"/>
|
@@ -8929,4 +10178,40 @@
|
|
8929
10178
|
<xsl:value-of select="$value"/>
|
8930
10179
|
</xsl:otherwise>
|
8931
10180
|
</xsl:choose>
|
10181
|
+
</xsl:template><xsl:template match="*" mode="print_as_xml">
|
10182
|
+
<xsl:param name="level">0</xsl:param>
|
10183
|
+
|
10184
|
+
<fo:block margin-left="{2*$level}mm">
|
10185
|
+
<xsl:text>
|
10186
|
+
<</xsl:text>
|
10187
|
+
<xsl:value-of select="local-name()"/>
|
10188
|
+
<xsl:for-each select="@*">
|
10189
|
+
<xsl:text> </xsl:text>
|
10190
|
+
<xsl:value-of select="local-name()"/>
|
10191
|
+
<xsl:text>="</xsl:text>
|
10192
|
+
<xsl:value-of select="."/>
|
10193
|
+
<xsl:text>"</xsl:text>
|
10194
|
+
</xsl:for-each>
|
10195
|
+
<xsl:text>></xsl:text>
|
10196
|
+
|
10197
|
+
<xsl:if test="not(*)">
|
10198
|
+
<fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
|
10199
|
+
<xsl:text></</xsl:text>
|
10200
|
+
<xsl:value-of select="local-name()"/>
|
10201
|
+
<xsl:text>></xsl:text>
|
10202
|
+
</xsl:if>
|
10203
|
+
</fo:block>
|
10204
|
+
|
10205
|
+
<xsl:if test="*">
|
10206
|
+
<fo:block>
|
10207
|
+
<xsl:apply-templates mode="print_as_xml">
|
10208
|
+
<xsl:with-param name="level" select="$level + 1"/>
|
10209
|
+
</xsl:apply-templates>
|
10210
|
+
</fo:block>
|
10211
|
+
<fo:block margin-left="{2*$level}mm">
|
10212
|
+
<xsl:text></</xsl:text>
|
10213
|
+
<xsl:value-of select="local-name()"/>
|
10214
|
+
<xsl:text>></xsl:text>
|
10215
|
+
</fo:block>
|
10216
|
+
</xsl:if>
|
8932
10217
|
</xsl:template></xsl:stylesheet>
|