metanorma-ogc 2.5.6 → 2.5.7

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
 
@@ -6966,10 +6966,11 @@
6966
6966
  </xsl:template>
6967
6967
 
6968
6968
  <xsl:template match="*[local-name() = 'image']">
6969
+ <xsl:param name="indent">0</xsl:param>
6969
6970
  <xsl:variable name="isAdded" select="../@added"/>
6970
6971
  <xsl:variable name="isDeleted" select="../@deleted"/>
6971
6972
  <xsl:choose>
6972
- <xsl:when test="ancestor::*[local-name() = 'title'] or not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
6973
+ <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) -->
6973
6974
  <fo:inline padding-left="1mm" padding-right="1mm">
6974
6975
  <xsl:if test="not(parent::*[local-name() = 'figure']) or parent::*[local-name() = 'p']">
6975
6976
  <xsl:attribute name="padding-left">0mm</xsl:attribute>
@@ -6978,7 +6979,43 @@
6978
6979
  <xsl:variable name="src">
6979
6980
  <xsl:call-template name="image_src"/>
6980
6981
  </xsl:variable>
6981
- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" vertical-align="middle"/>
6982
+
6983
+ <xsl:variable name="scale">
6984
+ <xsl:call-template name="getImageScale">
6985
+ <xsl:with-param name="indent" select="$indent"/>
6986
+ </xsl:call-template>
6987
+ </xsl:variable>
6988
+
6989
+ <!-- debug scale='<xsl:value-of select="$scale"/>', indent='<xsl:value-of select="$indent"/>' -->
6990
+
6991
+ <!-- <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" vertical-align="middle"/> -->
6992
+ <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" vertical-align="middle">
6993
+
6994
+ <xsl:variable name="width">
6995
+ <xsl:call-template name="setImageWidth"/>
6996
+ </xsl:variable>
6997
+ <xsl:if test="$width != ''">
6998
+ <xsl:attribute name="width"><xsl:value-of select="$width"/></xsl:attribute>
6999
+ </xsl:if>
7000
+ <xsl:variable name="height">
7001
+ <xsl:call-template name="setImageHeight"/>
7002
+ </xsl:variable>
7003
+ <xsl:if test="$height != ''">
7004
+ <xsl:attribute name="height"><xsl:value-of select="$height"/></xsl:attribute>
7005
+ </xsl:if>
7006
+
7007
+ <xsl:if test="$width = '' and $height = ''">
7008
+ <xsl:if test="number($scale) &lt; 100">
7009
+ <xsl:attribute name="content-width"><xsl:value-of select="number($scale)"/>%</xsl:attribute>
7010
+ <!-- <xsl:attribute name="content-width">scale-to-fit</xsl:attribute>
7011
+ <xsl:attribute name="content-height">100%</xsl:attribute>
7012
+ <xsl:attribute name="width">100%</xsl:attribute>
7013
+ <xsl:attribute name="scaling">uniform</xsl:attribute> -->
7014
+ </xsl:if>
7015
+ </xsl:if>
7016
+
7017
+ </fo:external-graphic>
7018
+
6982
7019
  </fo:inline>
6983
7020
  </xsl:when>
6984
7021
  <xsl:otherwise>
@@ -6999,25 +7036,23 @@
6999
7036
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
7000
7037
  <xsl:attribute name="scaling">uniform</xsl:attribute>
7001
7038
 
7002
- <xsl:apply-templates select="." mode="cross_image"/>
7039
+ <xsl:apply-templates select="." mode="cross_image"/>
7003
7040
 
7004
7041
  </fo:instream-foreign-object>
7005
7042
  </xsl:when>
7006
7043
  <xsl:otherwise>
7044
+ <!-- <fo:block>debug block image:
7045
+ <xsl:variable name="scale">
7046
+ <xsl:call-template name="getImageScale">
7047
+ <xsl:with-param name="indent" select="$indent"/>
7048
+ </xsl:call-template>
7049
+ </xsl:variable>
7050
+ <xsl:value-of select="concat('scale=', $scale,', indent=', $indent)"/>
7051
+ </fo:block> -->
7007
7052
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
7008
7053
  <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'])">
7009
7054
 
7010
- <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
7011
- <xsl:attribute name="width">
7012
- <xsl:value-of select="@width"/>
7013
- </xsl:attribute>
7014
- </xsl:if>
7015
-
7016
- <xsl:if test="@height != '' and @height != 'auto'">
7017
- <xsl:attribute name="height">
7018
- <xsl:value-of select="@height"/>
7019
- </xsl:attribute>
7020
- </xsl:if>
7055
+ <xsl:call-template name="setImageWidthHeight"/>
7021
7056
 
7022
7057
  <xsl:choose>
7023
7058
  <xsl:when test="@width != '' and @width != 'auto' and @height != '' and @height != 'auto'">
@@ -7025,24 +7060,18 @@
7025
7060
  </xsl:when>
7026
7061
  <xsl:otherwise>
7027
7062
 
7028
- <xsl:variable name="img_src">
7029
- <xsl:choose>
7030
- <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
7031
- <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
7032
- </xsl:choose>
7063
+ <xsl:variable name="scale">
7064
+ <xsl:call-template name="getImageScale">
7065
+ <xsl:with-param name="indent" select="$indent"/>
7066
+ </xsl:call-template>
7033
7067
  </xsl:variable>
7034
7068
 
7035
- <xsl:variable name="image_width_effective">
7036
-
7037
- <xsl:value-of select="$width_effective"/>
7038
-
7069
+ <xsl:variable name="scaleRatio">
7070
+ 1
7039
7071
  </xsl:variable>
7040
7072
 
7041
- <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
7042
7073
  <xsl:if test="number($scale) &lt; 100">
7043
-
7044
- <xsl:attribute name="content-width"><xsl:value-of select="$scale"/>%</xsl:attribute>
7045
-
7074
+ <xsl:attribute name="content-width"><xsl:value-of select="number($scale) * number($scaleRatio)"/>%</xsl:attribute>
7046
7075
  </xsl:if>
7047
7076
  </xsl:otherwise>
7048
7077
  </xsl:choose>
@@ -7058,6 +7087,62 @@
7058
7087
  </xsl:choose>
7059
7088
  </xsl:template>
7060
7089
 
7090
+ <xsl:template name="setImageWidth">
7091
+ <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
7092
+ <xsl:value-of select="@width"/>
7093
+ </xsl:if>
7094
+ </xsl:template>
7095
+ <xsl:template name="setImageHeight">
7096
+ <xsl:if test="@height != '' and @height != 'auto'">
7097
+ <xsl:value-of select="@height"/>
7098
+ </xsl:if>
7099
+ </xsl:template>
7100
+ <xsl:template name="setImageWidthHeight">
7101
+ <xsl:variable name="width">
7102
+ <xsl:call-template name="setImageWidth"/>
7103
+ </xsl:variable>
7104
+ <xsl:if test="$width != ''">
7105
+ <xsl:attribute name="width">
7106
+ <xsl:value-of select="$width"/>
7107
+ </xsl:attribute>
7108
+ </xsl:if>
7109
+ <xsl:variable name="height">
7110
+ <xsl:call-template name="setImageHeight"/>
7111
+ </xsl:variable>
7112
+ <xsl:if test="$height != ''">
7113
+ <xsl:attribute name="height">
7114
+ <xsl:value-of select="$height"/>
7115
+ </xsl:attribute>
7116
+ </xsl:if>
7117
+ </xsl:template>
7118
+
7119
+ <xsl:template name="getImageScale">
7120
+ <xsl:param name="indent"/>
7121
+ <xsl:variable name="indent_left">
7122
+ <xsl:choose>
7123
+ <xsl:when test="$indent != ''"><xsl:value-of select="$indent"/></xsl:when>
7124
+ <xsl:otherwise>0</xsl:otherwise>
7125
+ </xsl:choose>
7126
+ </xsl:variable>
7127
+ <xsl:variable name="img_src">
7128
+ <xsl:choose>
7129
+ <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when>
7130
+ <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
7131
+ </xsl:choose>
7132
+ </xsl:variable>
7133
+
7134
+ <xsl:variable name="image_width_effective">
7135
+
7136
+ <xsl:value-of select="$width_effective - number($indent_left)"/>
7137
+
7138
+ </xsl:variable>
7139
+ <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message>
7140
+ <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message>
7141
+ <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> -->
7142
+ <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/>
7143
+ <xsl:value-of select="$scale"/>
7144
+ </xsl:template>
7145
+
7061
7146
  <xsl:template name="image_src">
7062
7147
  <xsl:choose>
7063
7148
  <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]">
@@ -9765,6 +9850,7 @@
9765
9850
  </xsl:template>
9766
9851
 
9767
9852
  <xsl:template match="*[local-name() = 'ul'] | *[local-name() = 'ol']">
9853
+ <xsl:param name="indent">0</xsl:param>
9768
9854
  <xsl:choose>
9769
9855
  <xsl:when test="parent::*[local-name() = 'note'] or parent::*[local-name() = 'termnote']">
9770
9856
  <fo:block-container role="SKIP">
@@ -9779,7 +9865,9 @@
9779
9865
 
9780
9866
  <fo:block-container margin-left="0mm" role="SKIP">
9781
9867
  <fo:block>
9782
- <xsl:apply-templates select="." mode="list"/>
9868
+ <xsl:apply-templates select="." mode="list">
9869
+ <xsl:with-param name="indent" select="$indent"/>
9870
+ </xsl:apply-templates>
9783
9871
  </fo:block>
9784
9872
  </fo:block-container>
9785
9873
  </fo:block-container>
@@ -9787,7 +9875,9 @@
9787
9875
  <xsl:otherwise>
9788
9876
 
9789
9877
  <fo:block role="SKIP">
9790
- <xsl:apply-templates select="." mode="list"/>
9878
+ <xsl:apply-templates select="." mode="list">
9879
+ <xsl:with-param name="indent" select="$indent"/>
9880
+ </xsl:apply-templates>
9791
9881
  </fo:block>
9792
9882
 
9793
9883
  </xsl:otherwise>
@@ -9872,6 +9962,13 @@
9872
9962
  </xsl:template>
9873
9963
 
9874
9964
  <xsl:template match="*[local-name()='li']">
9965
+ <xsl:param name="indent">0</xsl:param>
9966
+ <!-- <fo:list-item xsl:use-attribute-sets="list-item-style">
9967
+ <fo:list-item-label end-indent="label-end()"><fo:block>x</fo:block></fo:list-item-label>
9968
+ <fo:list-item-body start-indent="body-start()" xsl:use-attribute-sets="list-item-body-style">
9969
+ <fo:block>debug li indent=<xsl:value-of select="$indent"/></fo:block>
9970
+ </fo:list-item-body>
9971
+ </fo:list-item> -->
9875
9972
  <fo:list-item xsl:use-attribute-sets="list-item-style">
9876
9973
  <xsl:copy-of select="@id"/>
9877
9974
 
@@ -9896,7 +9993,9 @@
9896
9993
 
9897
9994
  <xsl:call-template name="refine_list-item-body-style"/>
9898
9995
 
9899
- <xsl:apply-templates/>
9996
+ <xsl:apply-templates>
9997
+ <xsl:with-param name="indent" select="$indent"/>
9998
+ </xsl:apply-templates>
9900
9999
 
9901
10000
  <!-- <xsl:apply-templates select="node()[not(local-name() = 'note')]" />
9902
10001