metanorma-un 0.12.3 → 0.12.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afef4ddbab8e145f16145d3073dab882a4655888e14361bfcd0cafa8df0df6f5
4
- data.tar.gz: 376ced8cee4bb57461c1aeaaf4dc93d1160da3e08cdc2aa455c5e30faff1d5c7
3
+ metadata.gz: 2ea1d0a3c64d0112d31b61f1ea0bccf373a6b56140c824dba7fa8013d30c50c9
4
+ data.tar.gz: bba26136fc35c6f240f631bf70996c1e36b510ad555421e3c07a1221821680c0
5
5
  SHA512:
6
- metadata.gz: e78e0ea377c90c1f10c2dad246747f34d52bcc4135bf4d5528cec7cad043f72fe1546bbe53057eaf0ade3bbc421e95f3d311d3ffe61fe4b52c94adc26143b146
7
- data.tar.gz: 5f951a6ac21e68a2bc21e4b60d855d8230f978d242fc96bbad62ca691287461cea5d9c8a8e686235510a0a2b5f7513f8eeda5483eddf855417d5f0d109541884
6
+ metadata.gz: cb9884d76badbeb5d8f61e60dbe379ec1c1580fb1758ec2649ed36c6cbd8760b7533536dd129c53f9d9c6aa27c101c90dbd70d5c248070ad81eb994721aea4dc
7
+ data.tar.gz: c98cfb6f6fe725362740900f1dbabe87b8d88197db2740559f31ed1d47c2fca79a0853749195a8e48a89a9540b215d7cf0f9e3b628f02e01b66592b89b165abe
@@ -738,6 +738,8 @@
738
738
  <xsl:param name="svg_images"/> <!-- svg images array -->
739
739
  <xsl:variable name="images" select="document($svg_images)"/>
740
740
  <xsl:param name="basepath"/> <!-- base path for images -->
741
+ <xsl:param name="inputxml_basepath"/> <!-- input xml file path -->
742
+ <xsl:param name="inputxml_filename"/> <!-- input xml file name -->
741
743
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
742
744
  <xsl:param name="syntax-highlight">false</xsl:param> <!-- syntax highlighting feature, default - off -->
743
745
  <xsl:param name="add_math_as_text">true</xsl:param> <!-- add math in text behind svg formula, to copy-paste formula from PDF as text -->
@@ -790,6 +792,20 @@
790
792
  <xsl:call-template name="getLang"/>
791
793
  </xsl:variable>
792
794
 
795
+ <xsl:variable name="inputxml_filename_prefix">
796
+ <xsl:choose>
797
+ <xsl:when test="contains($inputxml_filename, '.presentation.xml')">
798
+ <xsl:value-of select="substring-before($inputxml_filename, '.presentation.xml')"/>
799
+ </xsl:when>
800
+ <xsl:when test="contains($inputxml_filename, '.xml')">
801
+ <xsl:value-of select="substring-before($inputxml_filename, '.xml')"/>
802
+ </xsl:when>
803
+ <xsl:otherwise>
804
+ <xsl:value-of select="$inputxml_filename"/>
805
+ </xsl:otherwise>
806
+ </xsl:choose>
807
+ </xsl:variable>
808
+
793
809
  <!-- Note 1: Each xslt has declated variable `namespace` that allows to set some properties, processing logic, etc. for concrete xslt.
794
810
  You can put such conditions by using xslt construction `xsl:if test="..."` or <xsl:choose><xsl:when test=""></xsl:when><xsl:otherwiste></xsl:otherwiste></xsl:choose>,
795
811
  BUT DON'T put any another conditions together with $namespace = '...' (such conditions will be ignored). For another conditions, please use nested xsl:if or xsl:choose -->
@@ -1696,6 +1712,10 @@
1696
1712
 
1697
1713
  </xsl:attribute-set>
1698
1714
 
1715
+ <xsl:template name="refine_figure-block-style">
1716
+
1717
+ </xsl:template>
1718
+
1699
1719
  <xsl:attribute-set name="figure-style">
1700
1720
 
1701
1721
  </xsl:attribute-set>
@@ -2606,7 +2626,7 @@
2606
2626
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)/*/tr[1]/td)"/>
2607
2627
 
2608
2628
  <xsl:variable name="colwidths">
2609
- <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
2629
+ <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col']) and not(@class = 'dl')">
2610
2630
  <xsl:call-template name="calculate-column-widths">
2611
2631
  <xsl:with-param name="cols-count" select="$cols-count"/>
2612
2632
  <xsl:with-param name="table" select="$simple-table"/>
@@ -2724,6 +2744,11 @@
2724
2744
  <fo:table-column column-width="{@width}"/>
2725
2745
  </xsl:for-each>
2726
2746
  </xsl:when>
2747
+ <xsl:when test="@class = 'dl'">
2748
+ <xsl:for-each select=".//*[local-name()='tr'][1]/*">
2749
+ <fo:table-column column-width="{@width}"/>
2750
+ </xsl:for-each>
2751
+ </xsl:when>
2727
2752
  <xsl:otherwise>
2728
2753
  <xsl:call-template name="insertTableColumnWidth">
2729
2754
  <xsl:with-param name="colwidths" select="$colwidths"/>
@@ -4000,6 +4025,7 @@
4000
4025
  <!-- ===================== -->
4001
4026
  <!-- Definition List -->
4002
4027
  <!-- ===================== -->
4028
+
4003
4029
  <xsl:template match="*[local-name()='dl']">
4004
4030
  <xsl:variable name="isAdded" select="@added"/>
4005
4031
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -4212,10 +4238,21 @@
4212
4238
  </xsl:variable>
4213
4239
 
4214
4240
  <xsl:variable name="colwidths">
4215
- <xsl:call-template name="calculate-column-widths">
4216
- <xsl:with-param name="cols-count" select="2"/>
4217
- <xsl:with-param name="table" select="$simple-table"/>
4218
- </xsl:call-template>
4241
+ <xsl:choose>
4242
+ <!-- dl from table[@class='dl'] -->
4243
+ <xsl:when test="*[local-name() = 'colgroup']">
4244
+ <autolayout/>
4245
+ <xsl:for-each select="*[local-name() = 'colgroup']/*[local-name() = 'col']">
4246
+ <column><xsl:value-of select="translate(@width,'%m','')"/></column>
4247
+ </xsl:for-each>
4248
+ </xsl:when>
4249
+ <xsl:otherwise>
4250
+ <xsl:call-template name="calculate-column-widths">
4251
+ <xsl:with-param name="cols-count" select="2"/>
4252
+ <xsl:with-param name="table" select="$simple-table"/>
4253
+ </xsl:call-template>
4254
+ </xsl:otherwise>
4255
+ </xsl:choose>
4219
4256
  </xsl:variable>
4220
4257
 
4221
4258
  <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
@@ -4941,7 +4978,8 @@
4941
4978
  </xsl:template>
4942
4979
 
4943
4980
  <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
4944
- <xsl:variable name="text" select="normalize-space(.)"/>
4981
+ <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
4982
+ <xsl:variable name="text" select="."/>
4945
4983
  <fo:inline font-size="75%" role="SKIP">
4946
4984
  <xsl:if test="string-length($text) &gt; 0">
4947
4985
  <xsl:variable name="smallCapsText">
@@ -6309,6 +6347,12 @@
6309
6347
  <xsl:when test="@updatetype = 'true'">
6310
6348
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
6311
6349
  </xsl:when>
6350
+ <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
6351
+ <!-- link to the PDF attachment -->
6352
+ <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
6353
+ <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
6354
+ <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
6355
+ </xsl:when>
6312
6356
  <xsl:otherwise>
6313
6357
  <xsl:value-of select="normalize-space(@target)"/>
6314
6358
  </xsl:otherwise>
@@ -6727,6 +6771,7 @@
6727
6771
  <xsl:variable name="isAdded" select="@added"/>
6728
6772
  <xsl:variable name="isDeleted" select="@deleted"/>
6729
6773
  <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
6774
+ <xsl:call-template name="refine_figure-block-style"/>
6730
6775
 
6731
6776
  <xsl:call-template name="setTrackChangesStyles">
6732
6777
  <xsl:with-param name="isAdded" select="$isAdded"/>
@@ -7082,16 +7127,44 @@
7082
7127
  </xsl:choose>
7083
7128
 
7084
7129
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
7085
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
7086
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
7130
+ <xsl:variable name="svg_width_" select="xalan:nodeset($svg_content)/*/@width"/>
7131
+ <xsl:variable name="svg_width" select="number(translate($svg_width_, 'px', ''))"/>
7132
+ <xsl:variable name="svg_height_" select="xalan:nodeset($svg_content)/*/@height"/>
7133
+ <xsl:variable name="svg_height" select="number(translate($svg_height_, 'px', ''))"/>
7134
+
7135
+ <!-- Example: -->
7087
7136
  <!-- effective height 297 - 27.4 - 13 = 256.6 -->
7088
7137
  <!-- effective width 210 - 12.5 - 25 = 172.5 -->
7089
7138
  <!-- effective height / width = 1.48, 1.4 - with title -->
7090
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
7139
+
7140
+ <xsl:variable name="scale_x">
7141
+ <xsl:choose>
7142
+ <xsl:when test="$svg_width &gt; $width_effective_px">
7143
+ <xsl:value-of select="$width_effective_px div $svg_width"/>
7144
+ </xsl:when>
7145
+ <xsl:otherwise>1</xsl:otherwise>
7146
+ </xsl:choose>
7147
+ </xsl:variable>
7148
+ <xsl:variable name="scale_y">
7149
+ <xsl:choose>
7150
+ <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
7151
+ <xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
7152
+ </xsl:when>
7153
+ <xsl:otherwise>1</xsl:otherwise>
7154
+ </xsl:choose>
7155
+ </xsl:variable>
7156
+
7157
+ <!-- for images with big height -->
7158
+ <!-- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)">
7091
7159
  <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
7092
7160
  <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
7093
- </xsl:if>
7161
+ </xsl:if> -->
7094
7162
  <xsl:attribute name="scaling">uniform</xsl:attribute>
7163
+
7164
+ <xsl:if test="$scale_y != 1">
7165
+ <xsl:attribute name="content-height"><xsl:value-of select="round($scale_x * $scale_y * 100)"/>%</xsl:attribute>
7166
+ </xsl:if>
7167
+
7095
7168
  <xsl:copy-of select="$svg_content"/>
7096
7169
  </fo:instream-foreign-object>
7097
7170
  <!-- </fo:block> -->
@@ -7129,8 +7202,12 @@
7129
7202
  <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
7130
7203
  <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
7131
7204
 
7205
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[1][local-name() = 'image']/@width)"/>
7206
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[1][local-name() = 'image']/@height)"/>
7207
+
7132
7208
  <xsl:attribute name="width">
7133
7209
  <xsl:choose>
7210
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7134
7211
  <xsl:when test="$width != ''">
7135
7212
  <xsl:value-of select="round($width)"/>
7136
7213
  </xsl:when>
@@ -7139,6 +7216,7 @@
7139
7216
  </xsl:attribute>
7140
7217
  <xsl:attribute name="height">
7141
7218
  <xsl:choose>
7219
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7142
7220
  <xsl:when test="$height != ''">
7143
7221
  <xsl:value-of select="round($height)"/>
7144
7222
  </xsl:when>
@@ -7150,6 +7228,28 @@
7150
7228
  </xsl:copy>
7151
7229
  </xsl:template>
7152
7230
 
7231
+ <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
7232
+ <!-- image[@width]/svg -->
7233
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
7234
+ <xsl:attribute name="width">
7235
+ <xsl:choose>
7236
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7237
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7238
+ </xsl:choose>
7239
+ </xsl:attribute>
7240
+ </xsl:template>
7241
+
7242
+ <xsl:template match="*[local-name() = 'svg']/@height" mode="svg_update">
7243
+ <!-- image[@height]/svg -->
7244
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
7245
+ <xsl:attribute name="height">
7246
+ <xsl:choose>
7247
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7248
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7249
+ </xsl:choose>
7250
+ </xsl:attribute>
7251
+ </xsl:template>
7252
+
7153
7253
  <!-- regex for 'display: inline-block;' -->
7154
7254
  <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
7155
7255
  <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
@@ -9219,7 +9319,9 @@
9219
9319
  </xsl:template> <!-- sections_element_style -->
9220
9320
 
9221
9321
  <xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
9222
- <fo:block break-after="page"/>
9322
+
9323
+ <fo:block break-after="page"/>
9324
+
9223
9325
  <fo:block>
9224
9326
  <xsl:call-template name="setId"/>
9225
9327
  <xsl:apply-templates/>
@@ -9291,7 +9393,7 @@
9291
9393
  <xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
9292
9394
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9293
9395
  </xsl:when>
9294
- <xsl:when test="not(//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9396
+ <xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9295
9397
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9296
9398
  </xsl:when>
9297
9399
  </xsl:choose>
@@ -11074,10 +11176,10 @@
11074
11176
 
11075
11177
  <xsl:template name="addPDFUAmeta">
11076
11178
  <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
11077
- <pdf:dictionary type="normal" key="ViewerPreferences">
11078
- <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
11079
- </pdf:dictionary>
11080
- </pdf:catalog>
11179
+ <pdf:dictionary type="normal" key="ViewerPreferences">
11180
+ <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
11181
+ </pdf:dictionary>
11182
+ </pdf:catalog>
11081
11183
  <x:xmpmeta xmlns:x="adobe:ns:meta/">
11082
11184
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
11083
11185
  <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
@@ -11129,6 +11231,19 @@
11129
11231
  </rdf:Description>
11130
11232
  </rdf:RDF>
11131
11233
  </x:xmpmeta>
11234
+ <!-- add attachments -->
11235
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
11236
+ <xsl:choose>
11237
+ <xsl:when test="normalize-space() != ''">
11238
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{.}" filename="{@name}"/>
11239
+ </xsl:when>
11240
+ <xsl:otherwise>
11241
+ <!-- _{filename}_attachments -->
11242
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
11243
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
11244
+ </xsl:otherwise>
11245
+ </xsl:choose>
11246
+ </xsl:for-each>
11132
11247
  </xsl:template> <!-- addPDFUAmeta -->
11133
11248
 
11134
11249
  <xsl:template name="getId">
@@ -738,6 +738,8 @@
738
738
  <xsl:param name="svg_images"/> <!-- svg images array -->
739
739
  <xsl:variable name="images" select="document($svg_images)"/>
740
740
  <xsl:param name="basepath"/> <!-- base path for images -->
741
+ <xsl:param name="inputxml_basepath"/> <!-- input xml file path -->
742
+ <xsl:param name="inputxml_filename"/> <!-- input xml file name -->
741
743
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
742
744
  <xsl:param name="syntax-highlight">false</xsl:param> <!-- syntax highlighting feature, default - off -->
743
745
  <xsl:param name="add_math_as_text">true</xsl:param> <!-- add math in text behind svg formula, to copy-paste formula from PDF as text -->
@@ -790,6 +792,20 @@
790
792
  <xsl:call-template name="getLang"/>
791
793
  </xsl:variable>
792
794
 
795
+ <xsl:variable name="inputxml_filename_prefix">
796
+ <xsl:choose>
797
+ <xsl:when test="contains($inputxml_filename, '.presentation.xml')">
798
+ <xsl:value-of select="substring-before($inputxml_filename, '.presentation.xml')"/>
799
+ </xsl:when>
800
+ <xsl:when test="contains($inputxml_filename, '.xml')">
801
+ <xsl:value-of select="substring-before($inputxml_filename, '.xml')"/>
802
+ </xsl:when>
803
+ <xsl:otherwise>
804
+ <xsl:value-of select="$inputxml_filename"/>
805
+ </xsl:otherwise>
806
+ </xsl:choose>
807
+ </xsl:variable>
808
+
793
809
  <!-- Note 1: Each xslt has declated variable `namespace` that allows to set some properties, processing logic, etc. for concrete xslt.
794
810
  You can put such conditions by using xslt construction `xsl:if test="..."` or <xsl:choose><xsl:when test=""></xsl:when><xsl:otherwiste></xsl:otherwiste></xsl:choose>,
795
811
  BUT DON'T put any another conditions together with $namespace = '...' (such conditions will be ignored). For another conditions, please use nested xsl:if or xsl:choose -->
@@ -1696,6 +1712,10 @@
1696
1712
 
1697
1713
  </xsl:attribute-set>
1698
1714
 
1715
+ <xsl:template name="refine_figure-block-style">
1716
+
1717
+ </xsl:template>
1718
+
1699
1719
  <xsl:attribute-set name="figure-style">
1700
1720
 
1701
1721
  </xsl:attribute-set>
@@ -2606,7 +2626,7 @@
2606
2626
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)/*/tr[1]/td)"/>
2607
2627
 
2608
2628
  <xsl:variable name="colwidths">
2609
- <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
2629
+ <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col']) and not(@class = 'dl')">
2610
2630
  <xsl:call-template name="calculate-column-widths">
2611
2631
  <xsl:with-param name="cols-count" select="$cols-count"/>
2612
2632
  <xsl:with-param name="table" select="$simple-table"/>
@@ -2724,6 +2744,11 @@
2724
2744
  <fo:table-column column-width="{@width}"/>
2725
2745
  </xsl:for-each>
2726
2746
  </xsl:when>
2747
+ <xsl:when test="@class = 'dl'">
2748
+ <xsl:for-each select=".//*[local-name()='tr'][1]/*">
2749
+ <fo:table-column column-width="{@width}"/>
2750
+ </xsl:for-each>
2751
+ </xsl:when>
2727
2752
  <xsl:otherwise>
2728
2753
  <xsl:call-template name="insertTableColumnWidth">
2729
2754
  <xsl:with-param name="colwidths" select="$colwidths"/>
@@ -4000,6 +4025,7 @@
4000
4025
  <!-- ===================== -->
4001
4026
  <!-- Definition List -->
4002
4027
  <!-- ===================== -->
4028
+
4003
4029
  <xsl:template match="*[local-name()='dl']">
4004
4030
  <xsl:variable name="isAdded" select="@added"/>
4005
4031
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -4212,10 +4238,21 @@
4212
4238
  </xsl:variable>
4213
4239
 
4214
4240
  <xsl:variable name="colwidths">
4215
- <xsl:call-template name="calculate-column-widths">
4216
- <xsl:with-param name="cols-count" select="2"/>
4217
- <xsl:with-param name="table" select="$simple-table"/>
4218
- </xsl:call-template>
4241
+ <xsl:choose>
4242
+ <!-- dl from table[@class='dl'] -->
4243
+ <xsl:when test="*[local-name() = 'colgroup']">
4244
+ <autolayout/>
4245
+ <xsl:for-each select="*[local-name() = 'colgroup']/*[local-name() = 'col']">
4246
+ <column><xsl:value-of select="translate(@width,'%m','')"/></column>
4247
+ </xsl:for-each>
4248
+ </xsl:when>
4249
+ <xsl:otherwise>
4250
+ <xsl:call-template name="calculate-column-widths">
4251
+ <xsl:with-param name="cols-count" select="2"/>
4252
+ <xsl:with-param name="table" select="$simple-table"/>
4253
+ </xsl:call-template>
4254
+ </xsl:otherwise>
4255
+ </xsl:choose>
4219
4256
  </xsl:variable>
4220
4257
 
4221
4258
  <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
@@ -4941,7 +4978,8 @@
4941
4978
  </xsl:template>
4942
4979
 
4943
4980
  <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
4944
- <xsl:variable name="text" select="normalize-space(.)"/>
4981
+ <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
4982
+ <xsl:variable name="text" select="."/>
4945
4983
  <fo:inline font-size="75%" role="SKIP">
4946
4984
  <xsl:if test="string-length($text) &gt; 0">
4947
4985
  <xsl:variable name="smallCapsText">
@@ -6309,6 +6347,12 @@
6309
6347
  <xsl:when test="@updatetype = 'true'">
6310
6348
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
6311
6349
  </xsl:when>
6350
+ <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
6351
+ <!-- link to the PDF attachment -->
6352
+ <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
6353
+ <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
6354
+ <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
6355
+ </xsl:when>
6312
6356
  <xsl:otherwise>
6313
6357
  <xsl:value-of select="normalize-space(@target)"/>
6314
6358
  </xsl:otherwise>
@@ -6727,6 +6771,7 @@
6727
6771
  <xsl:variable name="isAdded" select="@added"/>
6728
6772
  <xsl:variable name="isDeleted" select="@deleted"/>
6729
6773
  <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
6774
+ <xsl:call-template name="refine_figure-block-style"/>
6730
6775
 
6731
6776
  <xsl:call-template name="setTrackChangesStyles">
6732
6777
  <xsl:with-param name="isAdded" select="$isAdded"/>
@@ -7082,16 +7127,44 @@
7082
7127
  </xsl:choose>
7083
7128
 
7084
7129
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
7085
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
7086
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
7130
+ <xsl:variable name="svg_width_" select="xalan:nodeset($svg_content)/*/@width"/>
7131
+ <xsl:variable name="svg_width" select="number(translate($svg_width_, 'px', ''))"/>
7132
+ <xsl:variable name="svg_height_" select="xalan:nodeset($svg_content)/*/@height"/>
7133
+ <xsl:variable name="svg_height" select="number(translate($svg_height_, 'px', ''))"/>
7134
+
7135
+ <!-- Example: -->
7087
7136
  <!-- effective height 297 - 27.4 - 13 = 256.6 -->
7088
7137
  <!-- effective width 210 - 12.5 - 25 = 172.5 -->
7089
7138
  <!-- effective height / width = 1.48, 1.4 - with title -->
7090
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
7139
+
7140
+ <xsl:variable name="scale_x">
7141
+ <xsl:choose>
7142
+ <xsl:when test="$svg_width &gt; $width_effective_px">
7143
+ <xsl:value-of select="$width_effective_px div $svg_width"/>
7144
+ </xsl:when>
7145
+ <xsl:otherwise>1</xsl:otherwise>
7146
+ </xsl:choose>
7147
+ </xsl:variable>
7148
+ <xsl:variable name="scale_y">
7149
+ <xsl:choose>
7150
+ <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
7151
+ <xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
7152
+ </xsl:when>
7153
+ <xsl:otherwise>1</xsl:otherwise>
7154
+ </xsl:choose>
7155
+ </xsl:variable>
7156
+
7157
+ <!-- for images with big height -->
7158
+ <!-- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)">
7091
7159
  <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
7092
7160
  <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
7093
- </xsl:if>
7161
+ </xsl:if> -->
7094
7162
  <xsl:attribute name="scaling">uniform</xsl:attribute>
7163
+
7164
+ <xsl:if test="$scale_y != 1">
7165
+ <xsl:attribute name="content-height"><xsl:value-of select="round($scale_x * $scale_y * 100)"/>%</xsl:attribute>
7166
+ </xsl:if>
7167
+
7095
7168
  <xsl:copy-of select="$svg_content"/>
7096
7169
  </fo:instream-foreign-object>
7097
7170
  <!-- </fo:block> -->
@@ -7129,8 +7202,12 @@
7129
7202
  <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
7130
7203
  <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
7131
7204
 
7205
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[1][local-name() = 'image']/@width)"/>
7206
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[1][local-name() = 'image']/@height)"/>
7207
+
7132
7208
  <xsl:attribute name="width">
7133
7209
  <xsl:choose>
7210
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7134
7211
  <xsl:when test="$width != ''">
7135
7212
  <xsl:value-of select="round($width)"/>
7136
7213
  </xsl:when>
@@ -7139,6 +7216,7 @@
7139
7216
  </xsl:attribute>
7140
7217
  <xsl:attribute name="height">
7141
7218
  <xsl:choose>
7219
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7142
7220
  <xsl:when test="$height != ''">
7143
7221
  <xsl:value-of select="round($height)"/>
7144
7222
  </xsl:when>
@@ -7150,6 +7228,28 @@
7150
7228
  </xsl:copy>
7151
7229
  </xsl:template>
7152
7230
 
7231
+ <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
7232
+ <!-- image[@width]/svg -->
7233
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
7234
+ <xsl:attribute name="width">
7235
+ <xsl:choose>
7236
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7237
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7238
+ </xsl:choose>
7239
+ </xsl:attribute>
7240
+ </xsl:template>
7241
+
7242
+ <xsl:template match="*[local-name() = 'svg']/@height" mode="svg_update">
7243
+ <!-- image[@height]/svg -->
7244
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
7245
+ <xsl:attribute name="height">
7246
+ <xsl:choose>
7247
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7248
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7249
+ </xsl:choose>
7250
+ </xsl:attribute>
7251
+ </xsl:template>
7252
+
7153
7253
  <!-- regex for 'display: inline-block;' -->
7154
7254
  <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
7155
7255
  <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
@@ -9219,7 +9319,9 @@
9219
9319
  </xsl:template> <!-- sections_element_style -->
9220
9320
 
9221
9321
  <xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
9222
- <fo:block break-after="page"/>
9322
+
9323
+ <fo:block break-after="page"/>
9324
+
9223
9325
  <fo:block>
9224
9326
  <xsl:call-template name="setId"/>
9225
9327
  <xsl:apply-templates/>
@@ -9291,7 +9393,7 @@
9291
9393
  <xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
9292
9394
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9293
9395
  </xsl:when>
9294
- <xsl:when test="not(//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9396
+ <xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9295
9397
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9296
9398
  </xsl:when>
9297
9399
  </xsl:choose>
@@ -11074,10 +11176,10 @@
11074
11176
 
11075
11177
  <xsl:template name="addPDFUAmeta">
11076
11178
  <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
11077
- <pdf:dictionary type="normal" key="ViewerPreferences">
11078
- <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
11079
- </pdf:dictionary>
11080
- </pdf:catalog>
11179
+ <pdf:dictionary type="normal" key="ViewerPreferences">
11180
+ <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
11181
+ </pdf:dictionary>
11182
+ </pdf:catalog>
11081
11183
  <x:xmpmeta xmlns:x="adobe:ns:meta/">
11082
11184
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
11083
11185
  <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
@@ -11129,6 +11231,19 @@
11129
11231
  </rdf:Description>
11130
11232
  </rdf:RDF>
11131
11233
  </x:xmpmeta>
11234
+ <!-- add attachments -->
11235
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
11236
+ <xsl:choose>
11237
+ <xsl:when test="normalize-space() != ''">
11238
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{.}" filename="{@name}"/>
11239
+ </xsl:when>
11240
+ <xsl:otherwise>
11241
+ <!-- _{filename}_attachments -->
11242
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
11243
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
11244
+ </xsl:otherwise>
11245
+ </xsl:choose>
11246
+ </xsl:for-each>
11132
11247
  </xsl:template> <!-- addPDFUAmeta -->
11133
11248
 
11134
11249
  <xsl:template name="getId">
@@ -844,6 +844,8 @@
844
844
  <xsl:param name="svg_images"/> <!-- svg images array -->
845
845
  <xsl:variable name="images" select="document($svg_images)"/>
846
846
  <xsl:param name="basepath"/> <!-- base path for images -->
847
+ <xsl:param name="inputxml_basepath"/> <!-- input xml file path -->
848
+ <xsl:param name="inputxml_filename"/> <!-- input xml file name -->
847
849
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
848
850
  <xsl:param name="syntax-highlight">false</xsl:param> <!-- syntax highlighting feature, default - off -->
849
851
  <xsl:param name="add_math_as_text">true</xsl:param> <!-- add math in text behind svg formula, to copy-paste formula from PDF as text -->
@@ -896,6 +898,20 @@
896
898
  <xsl:call-template name="getLang"/>
897
899
  </xsl:variable>
898
900
 
901
+ <xsl:variable name="inputxml_filename_prefix">
902
+ <xsl:choose>
903
+ <xsl:when test="contains($inputxml_filename, '.presentation.xml')">
904
+ <xsl:value-of select="substring-before($inputxml_filename, '.presentation.xml')"/>
905
+ </xsl:when>
906
+ <xsl:when test="contains($inputxml_filename, '.xml')">
907
+ <xsl:value-of select="substring-before($inputxml_filename, '.xml')"/>
908
+ </xsl:when>
909
+ <xsl:otherwise>
910
+ <xsl:value-of select="$inputxml_filename"/>
911
+ </xsl:otherwise>
912
+ </xsl:choose>
913
+ </xsl:variable>
914
+
899
915
  <!-- Note 1: Each xslt has declated variable `namespace` that allows to set some properties, processing logic, etc. for concrete xslt.
900
916
  You can put such conditions by using xslt construction `xsl:if test="..."` or <xsl:choose><xsl:when test=""></xsl:when><xsl:otherwiste></xsl:otherwiste></xsl:choose>,
901
917
  BUT DON'T put any another conditions together with $namespace = '...' (such conditions will be ignored). For another conditions, please use nested xsl:if or xsl:choose -->
@@ -1819,6 +1835,10 @@
1819
1835
 
1820
1836
  </xsl:attribute-set>
1821
1837
 
1838
+ <xsl:template name="refine_figure-block-style">
1839
+
1840
+ </xsl:template>
1841
+
1822
1842
  <xsl:attribute-set name="figure-style">
1823
1843
 
1824
1844
  </xsl:attribute-set>
@@ -2737,7 +2757,7 @@
2737
2757
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)/*/tr[1]/td)"/>
2738
2758
 
2739
2759
  <xsl:variable name="colwidths">
2740
- <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
2760
+ <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col']) and not(@class = 'dl')">
2741
2761
  <xsl:call-template name="calculate-column-widths">
2742
2762
  <xsl:with-param name="cols-count" select="$cols-count"/>
2743
2763
  <xsl:with-param name="table" select="$simple-table"/>
@@ -2855,6 +2875,11 @@
2855
2875
  <fo:table-column column-width="{@width}"/>
2856
2876
  </xsl:for-each>
2857
2877
  </xsl:when>
2878
+ <xsl:when test="@class = 'dl'">
2879
+ <xsl:for-each select=".//*[local-name()='tr'][1]/*">
2880
+ <fo:table-column column-width="{@width}"/>
2881
+ </xsl:for-each>
2882
+ </xsl:when>
2858
2883
  <xsl:otherwise>
2859
2884
  <xsl:call-template name="insertTableColumnWidth">
2860
2885
  <xsl:with-param name="colwidths" select="$colwidths"/>
@@ -4127,6 +4152,7 @@
4127
4152
  <!-- ===================== -->
4128
4153
  <!-- Definition List -->
4129
4154
  <!-- ===================== -->
4155
+
4130
4156
  <xsl:template match="*[local-name()='dl']">
4131
4157
  <xsl:variable name="isAdded" select="@added"/>
4132
4158
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -4339,10 +4365,21 @@
4339
4365
  </xsl:variable>
4340
4366
 
4341
4367
  <xsl:variable name="colwidths">
4342
- <xsl:call-template name="calculate-column-widths">
4343
- <xsl:with-param name="cols-count" select="2"/>
4344
- <xsl:with-param name="table" select="$simple-table"/>
4345
- </xsl:call-template>
4368
+ <xsl:choose>
4369
+ <!-- dl from table[@class='dl'] -->
4370
+ <xsl:when test="*[local-name() = 'colgroup']">
4371
+ <autolayout/>
4372
+ <xsl:for-each select="*[local-name() = 'colgroup']/*[local-name() = 'col']">
4373
+ <column><xsl:value-of select="translate(@width,'%m','')"/></column>
4374
+ </xsl:for-each>
4375
+ </xsl:when>
4376
+ <xsl:otherwise>
4377
+ <xsl:call-template name="calculate-column-widths">
4378
+ <xsl:with-param name="cols-count" select="2"/>
4379
+ <xsl:with-param name="table" select="$simple-table"/>
4380
+ </xsl:call-template>
4381
+ </xsl:otherwise>
4382
+ </xsl:choose>
4346
4383
  </xsl:variable>
4347
4384
 
4348
4385
  <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
@@ -5068,7 +5105,8 @@
5068
5105
  </xsl:template>
5069
5106
 
5070
5107
  <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
5071
- <xsl:variable name="text" select="normalize-space(.)"/>
5108
+ <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
5109
+ <xsl:variable name="text" select="."/>
5072
5110
  <fo:inline font-size="75%" role="SKIP">
5073
5111
  <xsl:if test="string-length($text) &gt; 0">
5074
5112
  <xsl:variable name="smallCapsText">
@@ -6436,6 +6474,12 @@
6436
6474
  <xsl:when test="@updatetype = 'true'">
6437
6475
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
6438
6476
  </xsl:when>
6477
+ <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
6478
+ <!-- link to the PDF attachment -->
6479
+ <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
6480
+ <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
6481
+ <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
6482
+ </xsl:when>
6439
6483
  <xsl:otherwise>
6440
6484
  <xsl:value-of select="normalize-space(@target)"/>
6441
6485
  </xsl:otherwise>
@@ -6854,6 +6898,7 @@
6854
6898
  <xsl:variable name="isAdded" select="@added"/>
6855
6899
  <xsl:variable name="isDeleted" select="@deleted"/>
6856
6900
  <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
6901
+ <xsl:call-template name="refine_figure-block-style"/>
6857
6902
 
6858
6903
  <xsl:call-template name="setTrackChangesStyles">
6859
6904
  <xsl:with-param name="isAdded" select="$isAdded"/>
@@ -7209,16 +7254,44 @@
7209
7254
  </xsl:choose>
7210
7255
 
7211
7256
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
7212
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
7213
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
7257
+ <xsl:variable name="svg_width_" select="xalan:nodeset($svg_content)/*/@width"/>
7258
+ <xsl:variable name="svg_width" select="number(translate($svg_width_, 'px', ''))"/>
7259
+ <xsl:variable name="svg_height_" select="xalan:nodeset($svg_content)/*/@height"/>
7260
+ <xsl:variable name="svg_height" select="number(translate($svg_height_, 'px', ''))"/>
7261
+
7262
+ <!-- Example: -->
7214
7263
  <!-- effective height 297 - 27.4 - 13 = 256.6 -->
7215
7264
  <!-- effective width 210 - 12.5 - 25 = 172.5 -->
7216
7265
  <!-- effective height / width = 1.48, 1.4 - with title -->
7217
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
7266
+
7267
+ <xsl:variable name="scale_x">
7268
+ <xsl:choose>
7269
+ <xsl:when test="$svg_width &gt; $width_effective_px">
7270
+ <xsl:value-of select="$width_effective_px div $svg_width"/>
7271
+ </xsl:when>
7272
+ <xsl:otherwise>1</xsl:otherwise>
7273
+ </xsl:choose>
7274
+ </xsl:variable>
7275
+ <xsl:variable name="scale_y">
7276
+ <xsl:choose>
7277
+ <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
7278
+ <xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
7279
+ </xsl:when>
7280
+ <xsl:otherwise>1</xsl:otherwise>
7281
+ </xsl:choose>
7282
+ </xsl:variable>
7283
+
7284
+ <!-- for images with big height -->
7285
+ <!-- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)">
7218
7286
  <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
7219
7287
  <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
7220
- </xsl:if>
7288
+ </xsl:if> -->
7221
7289
  <xsl:attribute name="scaling">uniform</xsl:attribute>
7290
+
7291
+ <xsl:if test="$scale_y != 1">
7292
+ <xsl:attribute name="content-height"><xsl:value-of select="round($scale_x * $scale_y * 100)"/>%</xsl:attribute>
7293
+ </xsl:if>
7294
+
7222
7295
  <xsl:copy-of select="$svg_content"/>
7223
7296
  </fo:instream-foreign-object>
7224
7297
  <!-- </fo:block> -->
@@ -7256,8 +7329,12 @@
7256
7329
  <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
7257
7330
  <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
7258
7331
 
7332
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[1][local-name() = 'image']/@width)"/>
7333
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[1][local-name() = 'image']/@height)"/>
7334
+
7259
7335
  <xsl:attribute name="width">
7260
7336
  <xsl:choose>
7337
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7261
7338
  <xsl:when test="$width != ''">
7262
7339
  <xsl:value-of select="round($width)"/>
7263
7340
  </xsl:when>
@@ -7266,6 +7343,7 @@
7266
7343
  </xsl:attribute>
7267
7344
  <xsl:attribute name="height">
7268
7345
  <xsl:choose>
7346
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7269
7347
  <xsl:when test="$height != ''">
7270
7348
  <xsl:value-of select="round($height)"/>
7271
7349
  </xsl:when>
@@ -7277,6 +7355,28 @@
7277
7355
  </xsl:copy>
7278
7356
  </xsl:template>
7279
7357
 
7358
+ <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
7359
+ <!-- image[@width]/svg -->
7360
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
7361
+ <xsl:attribute name="width">
7362
+ <xsl:choose>
7363
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7364
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7365
+ </xsl:choose>
7366
+ </xsl:attribute>
7367
+ </xsl:template>
7368
+
7369
+ <xsl:template match="*[local-name() = 'svg']/@height" mode="svg_update">
7370
+ <!-- image[@height]/svg -->
7371
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
7372
+ <xsl:attribute name="height">
7373
+ <xsl:choose>
7374
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7375
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7376
+ </xsl:choose>
7377
+ </xsl:attribute>
7378
+ </xsl:template>
7379
+
7280
7380
  <!-- regex for 'display: inline-block;' -->
7281
7381
  <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
7282
7382
  <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
@@ -9346,7 +9446,9 @@
9346
9446
  </xsl:template> <!-- sections_element_style -->
9347
9447
 
9348
9448
  <xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
9349
- <fo:block break-after="page"/>
9449
+
9450
+ <fo:block break-after="page"/>
9451
+
9350
9452
  <fo:block>
9351
9453
  <xsl:call-template name="setId"/>
9352
9454
  <xsl:apply-templates/>
@@ -9418,7 +9520,7 @@
9418
9520
  <xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
9419
9521
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9420
9522
  </xsl:when>
9421
- <xsl:when test="not(//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9523
+ <xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9422
9524
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9423
9525
  </xsl:when>
9424
9526
  </xsl:choose>
@@ -11202,10 +11304,10 @@
11202
11304
 
11203
11305
  <xsl:template name="addPDFUAmeta">
11204
11306
  <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
11205
- <pdf:dictionary type="normal" key="ViewerPreferences">
11206
- <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
11207
- </pdf:dictionary>
11208
- </pdf:catalog>
11307
+ <pdf:dictionary type="normal" key="ViewerPreferences">
11308
+ <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
11309
+ </pdf:dictionary>
11310
+ </pdf:catalog>
11209
11311
  <x:xmpmeta xmlns:x="adobe:ns:meta/">
11210
11312
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
11211
11313
  <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
@@ -11257,6 +11359,19 @@
11257
11359
  </rdf:Description>
11258
11360
  </rdf:RDF>
11259
11361
  </x:xmpmeta>
11362
+ <!-- add attachments -->
11363
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
11364
+ <xsl:choose>
11365
+ <xsl:when test="normalize-space() != ''">
11366
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{.}" filename="{@name}"/>
11367
+ </xsl:when>
11368
+ <xsl:otherwise>
11369
+ <!-- _{filename}_attachments -->
11370
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
11371
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
11372
+ </xsl:otherwise>
11373
+ </xsl:choose>
11374
+ </xsl:for-each>
11260
11375
  </xsl:template> <!-- addPDFUAmeta -->
11261
11376
 
11262
11377
  <xsl:template name="getId">
@@ -338,29 +338,32 @@
338
338
  </define>
339
339
  <define name="organization">
340
340
  <element name="organization">
341
- <oneOrMore>
342
- <ref name="orgname"/>
343
- </oneOrMore>
344
- <zeroOrMore>
345
- <ref name="subdivision"/>
346
- </zeroOrMore>
347
- <optional>
348
- <ref name="abbreviation"/>
349
- </optional>
350
- <zeroOrMore>
351
- <ref name="uri"/>
352
- </zeroOrMore>
353
- <zeroOrMore>
354
- <ref name="org-identifier"/>
355
- </zeroOrMore>
356
- <zeroOrMore>
357
- <ref name="contact"/>
358
- </zeroOrMore>
359
- <optional>
360
- <ref name="logo"/>
361
- </optional>
341
+ <ref name="OrganizationType"/>
362
342
  </element>
363
343
  </define>
344
+ <define name="OrganizationType">
345
+ <oneOrMore>
346
+ <ref name="orgname"/>
347
+ </oneOrMore>
348
+ <zeroOrMore>
349
+ <ref name="subdivision"/>
350
+ </zeroOrMore>
351
+ <optional>
352
+ <ref name="abbreviation"/>
353
+ </optional>
354
+ <zeroOrMore>
355
+ <ref name="uri"/>
356
+ </zeroOrMore>
357
+ <zeroOrMore>
358
+ <ref name="org-identifier"/>
359
+ </zeroOrMore>
360
+ <zeroOrMore>
361
+ <ref name="contact"/>
362
+ </zeroOrMore>
363
+ <optional>
364
+ <ref name="logo"/>
365
+ </optional>
366
+ </define>
364
367
  <define name="orgname">
365
368
  <element name="name">
366
369
  <choice>
@@ -371,10 +374,10 @@
371
374
  </define>
372
375
  <define name="subdivision">
373
376
  <element name="subdivision">
374
- <choice>
375
- <ref name="LocalizedString"/>
376
- <ref name="NameWithVariants"/>
377
- </choice>
377
+ <optional>
378
+ <attribute name="type"/>
379
+ </optional>
380
+ <ref name="OrganizationType"/>
378
381
  </element>
379
382
  </define>
380
383
  <define name="logo">
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module UN
3
- VERSION = "0.12.3".freeze
3
+ VERSION = "0.12.5".freeze
4
4
  end
5
5
  end
data/metanorma-un.gemspec CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "roman-numerals"
32
32
  spec.add_dependency "twitter_cldr"
33
33
 
34
- spec.add_dependency "metanorma-standoc", "~> 2.8.2"
34
+ spec.add_dependency "metanorma-standoc", "~> 2.8.4"
35
35
 
36
36
  spec.add_development_dependency "debug"
37
37
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-un
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.3
4
+ version: 0.12.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-19 00:00:00.000000000 Z
11
+ date: 2024-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iso-639
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.8.2
61
+ version: 2.8.4
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.8.2
68
+ version: 2.8.4
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: debug
71
71
  requirement: !ruby/object:Gem::Requirement