metanorma-ogc 2.5.6 → 2.5.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -742,11 +742,15 @@
742
742
 
743
743
  <!-- Lato font doesn't contain 'thin space' glyph -->
744
744
  <xsl:template match="text()" priority="1">
745
- <xsl:value-of select="translate(., $thin_space, ' ')"/>
745
+ <xsl:call-template name="add_fo_character">
746
+ <xsl:with-param name="text" select="translate(., $thin_space, ' ')"/>
747
+ </xsl:call-template>
746
748
  </xsl:template>
747
749
 
748
750
  <xsl:template match="ogc:title//text() | ogc:name//text()" priority="3" mode="contents">
749
- <xsl:value-of select="translate(., $thin_space, ' ')"/>
751
+ <xsl:call-template name="add_fo_character">
752
+ <xsl:with-param name="text" select="translate(., $thin_space, ' ')"/>
753
+ </xsl:call-template>
750
754
  </xsl:template>
751
755
 
752
756
  <xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text()" priority="2">
@@ -762,7 +766,54 @@
762
766
  <!-- replace sequence #x200B to one &#x200B -->
763
767
  <xsl:variable name="content4" select="java:replaceAll(java:java.lang.String.new($content3), '\u200b{2,}', '​')"/>
764
768
 
765
- <xsl:value-of select="translate($content4, $thin_space, ' ')"/>
769
+ <xsl:call-template name="add_fo_character">
770
+ <xsl:with-param name="text" select="translate($content4, $thin_space, ' ')"/>
771
+ </xsl:call-template>
772
+ </xsl:template>
773
+
774
+ <xsl:template name="add_fo_character">
775
+ <xsl:param name="text"/>
776
+ <!-- https://github.com/metanorma/mn-native-pdf/issues/672, https://issues.apache.org/jira/browse/FOP-3175 -->
777
+ <!-- Miscellaneous Symbols https://www.compart.com/en/unicode/block/U+2600 U+2600 - U+26FF -->
778
+ <!-- Dingbats https://www.compart.com/en/unicode/block/U+2700 U+2700 - U+27BF -->
779
+ <!-- Miscellaneous Symbols and Arrows https://www.compart.com/en/unicode/block/U+2b55 U+2B00 - U+2BFF-->
780
+ <!-- enclose chars into <fo:character character="..."/> -->
781
+ <xsl:variable name="regex_dingbats_chars">([\u2100-\u2BFF])</xsl:variable> <!-- \u1F300;-\u1F5FF; not working in fo:character -->
782
+ <xsl:variable name="element_name_fo_character">fo:character</xsl:variable>
783
+ <xsl:variable name="tag_element_name_fo_character_open">###<xsl:value-of select="$element_name_fo_character"/>###</xsl:variable>
784
+ <xsl:variable name="tag_element_name_fo_character_close">###/<xsl:value-of select="$element_name_fo_character"/>###</xsl:variable>
785
+ <xsl:variable name="text_" select="java:replaceAll(java:java.lang.String.new($text), $regex_dingbats_chars, concat($tag_element_name_fo_character_open,'$1',$tag_element_name_fo_character_close))"/>
786
+ <xsl:call-template name="replace_text_tags_fo_character">
787
+ <xsl:with-param name="tag_open" select="$tag_element_name_fo_character_open"/>
788
+ <xsl:with-param name="tag_close" select="$tag_element_name_fo_character_close"/>
789
+ <xsl:with-param name="text" select="$text_"/>
790
+ </xsl:call-template>
791
+ </xsl:template>
792
+
793
+ <!-- ###fo:character###A###/fo:character### -->
794
+ <xsl:template name="replace_text_tags_fo_character">
795
+ <xsl:param name="tag_open"/>
796
+ <xsl:param name="tag_close"/>
797
+ <xsl:param name="text"/>
798
+ <xsl:choose>
799
+ <xsl:when test="contains($text, $tag_open)">
800
+ <xsl:value-of select="substring-before($text, $tag_open)"/>
801
+ <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/>
802
+
803
+ <xsl:element name="{substring-before(substring-after($tag_open, '###'),'###')}">
804
+ <xsl:attribute name="character">
805
+ <xsl:value-of select="substring-before($text_after, $tag_close)"/>
806
+ </xsl:attribute>
807
+ </xsl:element>
808
+
809
+ <xsl:call-template name="replace_text_tags_fo_character">
810
+ <xsl:with-param name="tag_open" select="$tag_open"/>
811
+ <xsl:with-param name="tag_close" select="$tag_close"/>
812
+ <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/>
813
+ </xsl:call-template>
814
+ </xsl:when>
815
+ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise>
816
+ </xsl:choose>
766
817
  </xsl:template>
767
818
 
768
819
  <xsl:template match="node()" mode="sections">
@@ -1057,6 +1108,8 @@
1057
1108
  <xsl:template match="ogc:p" name="paragraph">
1058
1109
  <xsl:param name="inline" select="'false'"/>
1059
1110
  <xsl:param name="split_keep-within-line"/>
1111
+ <xsl:param name="indent">0</xsl:param>
1112
+ <!-- <fo:block>debug p indent=<xsl:value-of select="$indent"/></fo:block> -->
1060
1113
  <xsl:variable name="previous-element" select="local-name(preceding-sibling::*[1])"/>
1061
1114
  <xsl:variable name="element-name">
1062
1115
  <xsl:choose>
@@ -1092,6 +1145,7 @@
1092
1145
 
1093
1146
  <xsl:apply-templates>
1094
1147
  <xsl:with-param name="split_keep-within-line" select="$split_keep-within-line"/>
1148
+ <xsl:with-param name="indent" select="$indent"/>
1095
1149
  </xsl:apply-templates>
1096
1150
  </xsl:element>
1097
1151
  <xsl:if test="$element-name = 'fo:inline' and not($inline = 'true') and not(local-name(..) = 'admonition')">
@@ -1114,17 +1168,18 @@
1114
1168
  </xsl:template>
1115
1169
 
1116
1170
  <xsl:template match="ogc:ul | ogc:ol" mode="list" priority="2">
1117
- <xsl:variable name="ul_indent">6mm</xsl:variable>
1118
- <fo:block-container margin-left="13mm">
1119
- <xsl:if test="self::ogc:ul and not(ancestor::ogc:ul) and not(ancestor::ogc:ol)"> <!-- if first level -->
1120
- <xsl:attribute name="margin-left">4mm</xsl:attribute>
1121
- </xsl:if>
1122
- <xsl:if test="self::ogc:ul and ancestor::*[2][self::ogc:ul]"> <!-- ul/li/ul -->
1123
- <xsl:attribute name="margin-left"><xsl:value-of select="$ul_indent"/></xsl:attribute>
1124
- </xsl:if>
1125
- <xsl:if test="ancestor::ogc:table">
1126
- <xsl:attribute name="margin-left">4mm</xsl:attribute>
1127
- </xsl:if>
1171
+ <xsl:param name="indent">0</xsl:param>
1172
+ <!-- <fo:block>debug ul ol indent=<xsl:value-of select="$indent"/></fo:block> -->
1173
+ <xsl:variable name="ul_indent">6</xsl:variable>
1174
+ <xsl:variable name="margin_left">
1175
+ <xsl:choose>
1176
+ <xsl:when test="self::ogc:ul and not(ancestor::ogc:ul) and not(ancestor::ogc:ol)">4</xsl:when> <!-- if first level -->
1177
+ <xsl:when test="self::ogc:ul and ancestor::*[2][self::ogc:ul]"><xsl:value-of select="$ul_indent"/></xsl:when> <!-- ul/li/ul -->
1178
+ <xsl:when test="ancestor::ogc:table">4</xsl:when>
1179
+ <xsl:otherwise>13</xsl:otherwise>
1180
+ </xsl:choose>
1181
+ </xsl:variable>
1182
+ <fo:block-container margin-left="{$margin_left}mm">
1128
1183
  <xsl:if test="ancestor::ogc:ul or ancestor::ogc:ol">
1129
1184
  <xsl:attribute name="margin-top">10pt</xsl:attribute>
1130
1185
  <xsl:if test="ancestor::ogc:table">
@@ -1134,7 +1189,7 @@
1134
1189
  <fo:block-container margin-left="0mm">
1135
1190
  <fo:list-block xsl:use-attribute-sets="list-style">
1136
1191
  <xsl:if test="self::ogc:ul">
1137
- <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$ul_indent"/></xsl:attribute>
1192
+ <xsl:attribute name="provisional-distance-between-starts"><xsl:value-of select="$ul_indent"/>mm</xsl:attribute>
1138
1193
  </xsl:if>
1139
1194
  <xsl:if test="ancestor::ogc:table">
1140
1195
  <xsl:attribute name="provisional-distance-between-starts">5mm</xsl:attribute>
@@ -1148,7 +1203,9 @@
1148
1203
  <xsl:if test="following-sibling::*[1][local-name() = 'ul' or local-name() = 'ol']">
1149
1204
  <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
1150
1205
  </xsl:if>
1151
- <xsl:apply-templates/>
1206
+ <xsl:apply-templates>
1207
+ <xsl:with-param name="indent" select="$indent + $ul_indent"/>
1208
+ </xsl:apply-templates>
1152
1209
  </fo:list-block>
1153
1210
  </fo:block-container>
1154
1211
  </fo:block-container>
@@ -1256,9 +1313,13 @@
1256
1313
  </xsl:template>
1257
1314
 
1258
1315
  <xsl:template match="ogc:figure" priority="2">
1316
+ <xsl:param name="indent"/>
1317
+ <!-- <fo:block>debug figure indent=<xsl:value-of select="$indent"/></fo:block> -->
1259
1318
  <fo:block-container id="{@id}" margin-top="12pt" margin-bottom="12pt">
1260
1319
  <fo:block>
1261
- <xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
1320
+ <xsl:apply-templates select="node()[not(local-name() = 'name')]">
1321
+ <xsl:with-param name="indent" select="$indent"/>
1322
+ </xsl:apply-templates>
1262
1323
  </fo:block>
1263
1324
  <xsl:call-template name="fn_display_figure"/>
1264
1325
  <xsl:for-each select="ogc:note">
@@ -7935,10 +7996,11 @@
7935
7996
  </xsl:template>
7936
7997
 
7937
7998
  <xsl:template match="*[local-name() = 'image']">
7999
+ <xsl:param name="indent">0</xsl:param>
7938
8000
  <xsl:variable name="isAdded" select="../@added"/>
7939
8001
  <xsl:variable name="isDeleted" select="../@deleted"/>
7940
8002
  <xsl:choose>
7941
- <xsl:when test="ancestor::*[local-name() = 'title'] or not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
8003
+ <xsl:when test="ancestor::*[local-name() = 'title'] or not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']"> <!-- inline image ( 'image:path' in adoc, with one colon after image) -->
7942
8004
  <fo:inline padding-left="1mm" padding-right="1mm">
7943
8005
  <xsl:if test="not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
7944
8006
  <xsl:attribute name="padding-left">0mm</xsl:attribute>
@@ -7947,7 +8009,43 @@
7947
8009
  <xsl:variable name="src">
7948
8010
  <xsl:call-template name="image_src"/>
7949
8011
  </xsl:variable>
7950
- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" vertical-align="middle"/>
8012
+
8013
+ <xsl:variable name="scale">
8014
+ <xsl:call-template name="getImageScale">
8015
+ <xsl:with-param name="indent" select="$indent"/>
8016
+ </xsl:call-template>
8017
+ </xsl:variable>
8018
+
8019
+ <!-- debug scale='<xsl:value-of select="$scale"/>', indent='<xsl:value-of select="$indent"/>' -->
8020
+
8021
+ <!-- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" vertical-align="middle"/> -->
8022
+ <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" vertical-align="middle">
8023
+
8024
+ <xsl:variable name="width">
8025
+ <xsl:call-template name="setImageWidth"/>
8026
+ </xsl:variable>
8027
+ <xsl:if test="$width != ''">
8028
+ <xsl:attribute name="width"><xsl:value-of select="$width"/></xsl:attribute>
8029
+ </xsl:if>
8030
+ <xsl:variable name="height">
8031
+ <xsl:call-template name="setImageHeight"/>
8032
+ </xsl:variable>
8033
+ <xsl:if test="$height != ''">
8034
+ <xsl:attribute name="height"><xsl:value-of select="$height"/></xsl:attribute>
8035
+ </xsl:if>
8036
+
8037
+ <xsl:if test="$width = '' and $height = ''">
8038
+ <xsl:if test="number($scale) &lt; 100">
8039
+ <xsl:attribute name="content-width"><xsl:value-of select="number($scale)"/>%</xsl:attribute>
8040
+ <!-- <xsl:attribute name="content-width">scale-to-fit</xsl:attribute>
8041
+ <xsl:attribute name="content-height">100%</xsl:attribute>
8042
+ <xsl:attribute name="width">100%</xsl:attribute>
8043
+ <xsl:attribute name="scaling">uniform</xsl:attribute> -->
8044
+ </xsl:if>
8045
+ </xsl:if>
8046
+
8047
+ </fo:external-graphic>
8048
+
7951
8049
  </fo:inline>
7952
8050
  </xsl:when>
7953
8051
  <xsl:otherwise>
@@ -7968,25 +8066,23 @@
7968
8066
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
7969
8067
  <xsl:attribute name="scaling">uniform</xsl:attribute>
7970
8068
 
7971
- <xsl:apply-templates select="." mode="cross_image"/>
8069
+ <xsl:apply-templates select="." mode="cross_image"/>
7972
8070
 
7973
8071
  </fo:instream-foreign-object>
7974
8072
  </xsl:when>
7975
8073
  <xsl:otherwise>
8074
+ <!-- <fo:block>debug block image:
8075
+ <xsl:variable name="scale">
8076
+ <xsl:call-template name="getImageScale">
8077
+ <xsl:with-param name="indent" select="$indent"/>
8078
+ </xsl:call-template>
8079
+ </xsl:variable>
8080
+ <xsl:value-of select="concat('scale=', $scale,', indent=', $indent)"/>
8081
+ </fo:block> -->
7976
8082
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
7977
8083
  <xsl:if test="not(@mimetype = 'image/svg+xml') and (../*[local-name() = 'name'] or parent::*[local-name() = 'figure'][@unnumbered = 'true']) and not(ancestor::*[local-name() = 'table'])">
7978
8084
 
7979
- <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
7980
- <xsl:attribute name="width">
7981
- <xsl:value-of select="@width"/>
7982
- </xsl:attribute>
7983
- </xsl:if>
7984
-
7985
- <xsl:if test="@height != '' and @height != 'auto'">
7986
- <xsl:attribute name="height">
7987
- <xsl:value-of select="@height"/>
7988
- </xsl:attribute>
7989
- </xsl:if>
8085
+ <xsl:call-template name="setImageWidthHeight"/>
7990
8086
 
7991
8087
  <xsl:choose>
7992
8088
  <xsl:when test="@width != '' and @width != 'auto' and @height != '' and @height != 'auto'">
@@ -7994,24 +8090,18 @@
7994
8090
  </xsl:when>
7995
8091
  <xsl:otherwise>
7996
8092
 
7997
- <xsl:variable name="img_src">
7998
- <xsl:choose>
7999
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
8000
- <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
8001
- </xsl:choose>
8093
+ <xsl:variable name="scale">
8094
+ <xsl:call-template name="getImageScale">
8095
+ <xsl:with-param name="indent" select="$indent"/>
8096
+ </xsl:call-template>
8002
8097
  </xsl:variable>
8003
8098
 
8004
- <xsl:variable name="image_width_effective">
8005
-
8006
- <xsl:value-of select="$width_effective"/>
8007
-
8099
+ <xsl:variable name="scaleRatio">
8100
+ 1
8008
8101
  </xsl:variable>
8009
8102
 
8010
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8011
8103
  <xsl:if test="number($scale) &lt; 100">
8012
-
8013
- <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
8014
-
8104
+ <xsl:attribute name="content-width"><xsl:value-of select="number($scale) * number($scaleRatio)"/>%</xsl:attribute>
8015
8105
  </xsl:if>
8016
8106
  </xsl:otherwise>
8017
8107
  </xsl:choose>
@@ -8027,6 +8117,62 @@
8027
8117
  </xsl:choose>
8028
8118
  </xsl:template>
8029
8119
 
8120
+ <xsl:template name="setImageWidth">
8121
+ <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
8122
+ <xsl:value-of select="@width"/>
8123
+ </xsl:if>
8124
+ </xsl:template>
8125
+ <xsl:template name="setImageHeight">
8126
+ <xsl:if test="@height != '' and @height != 'auto'">
8127
+ <xsl:value-of select="@height"/>
8128
+ </xsl:if>
8129
+ </xsl:template>
8130
+ <xsl:template name="setImageWidthHeight">
8131
+ <xsl:variable name="width">
8132
+ <xsl:call-template name="setImageWidth"/>
8133
+ </xsl:variable>
8134
+ <xsl:if test="$width != ''">
8135
+ <xsl:attribute name="width">
8136
+ <xsl:value-of select="$width"/>
8137
+ </xsl:attribute>
8138
+ </xsl:if>
8139
+ <xsl:variable name="height">
8140
+ <xsl:call-template name="setImageHeight"/>
8141
+ </xsl:variable>
8142
+ <xsl:if test="$height != ''">
8143
+ <xsl:attribute name="height">
8144
+ <xsl:value-of select="$height"/>
8145
+ </xsl:attribute>
8146
+ </xsl:if>
8147
+ </xsl:template>
8148
+
8149
+ <xsl:template name="getImageScale">
8150
+ <xsl:param name="indent"/>
8151
+ <xsl:variable name="indent_left">
8152
+ <xsl:choose>
8153
+ <xsl:when test="$indent != ''"><xsl:value-of select="$indent"/></xsl:when>
8154
+ <xsl:otherwise>0</xsl:otherwise>
8155
+ </xsl:choose>
8156
+ </xsl:variable>
8157
+ <xsl:variable name="img_src">
8158
+ <xsl:choose>
8159
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
8160
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
8161
+ </xsl:choose>
8162
+ </xsl:variable>
8163
+
8164
+ <xsl:variable name="image_width_effective">
8165
+
8166
+ <xsl:value-of select="$width_effective - number($indent_left)"/>
8167
+
8168
+ </xsl:variable>
8169
+ <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
8170
+ <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
8171
+ <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
8172
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
8173
+ <xsl:value-of select="$scale"/>
8174
+ </xsl:template>
8175
+
8030
8176
  <xsl:template name="image_src">
8031
8177
  <xsl:choose>
8032
8178
  <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]">
@@ -10753,6 +10899,7 @@
10753
10899
  </xsl:template>
10754
10900
 
10755
10901
  <xsl:template match="*[local-name() = 'ul'] | *[local-name() = 'ol']">
10902
+ <xsl:param name="indent">0</xsl:param>
10756
10903
  <xsl:choose>
10757
10904
  <xsl:when test="parent::*[local-name() = 'note'] or parent::*[local-name() = 'termnote']">
10758
10905
  <fo:block-container role="SKIP">
@@ -10767,7 +10914,9 @@
10767
10914
 
10768
10915
  <fo:block-container margin-left="0mm" role="SKIP">
10769
10916
  <fo:block>
10770
- <xsl:apply-templates select="." mode="list"/>
10917
+ <xsl:apply-templates select="." mode="list">
10918
+ <xsl:with-param name="indent" select="$indent"/>
10919
+ </xsl:apply-templates>
10771
10920
  </fo:block>
10772
10921
  </fo:block-container>
10773
10922
  </fo:block-container>
@@ -10775,7 +10924,9 @@
10775
10924
  <xsl:otherwise>
10776
10925
 
10777
10926
  <fo:block role="SKIP">
10778
- <xsl:apply-templates select="." mode="list"/>
10927
+ <xsl:apply-templates select="." mode="list">
10928
+ <xsl:with-param name="indent" select="$indent"/>
10929
+ </xsl:apply-templates>
10779
10930
  </fo:block>
10780
10931
 
10781
10932
  </xsl:otherwise>
@@ -10860,6 +11011,13 @@
10860
11011
  </xsl:template>
10861
11012
 
10862
11013
  <xsl:template match="*[local-name()='li']">
11014
+ <xsl:param name="indent">0</xsl:param>
11015
+ <!-- <fo:list-item xsl:use-attribute-sets="list-item-style">
11016
+ <fo:list-item-label end-indent="label-end()"><fo:block>x</fo:block></fo:list-item-label>
11017
+ <fo:list-item-body start-indent="body-start()" xsl:use-attribute-sets="list-item-body-style">
11018
+ <fo:block>debug li indent=<xsl:value-of select="$indent"/></fo:block>
11019
+ </fo:list-item-body>
11020
+ </fo:list-item> -->
10863
11021
  <fo:list-item xsl:use-attribute-sets="list-item-style">
10864
11022
  <xsl:copy-of select="@id"/>
10865
11023
 
@@ -10884,7 +11042,9 @@
10884
11042
 
10885
11043
  <xsl:call-template name="refine_list-item-body-style"/>
10886
11044
 
10887
- <xsl:apply-templates/>
11045
+ <xsl:apply-templates>
11046
+ <xsl:with-param name="indent" select="$indent"/>
11047
+ </xsl:apply-templates>
10888
11048
 
10889
11049
  <!-- <xsl:apply-templates select="node()[not(local-name() = 'note')]" />
10890
11050