metanorma-iho 0.9.2 → 0.9.4

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: 0240fc0c1d870d0b31ef54d36f29b6bfa56de1874540d7f1d5987dd032a665eb
4
- data.tar.gz: c229c3681aa0630c8ac3304ec54314652640465f1d3acaf532bc72d393b0bd2f
3
+ metadata.gz: cb6946f10c3caf2a5be78ad05de574a12f0631def9348c00a3bffc91227b59e2
4
+ data.tar.gz: 7b43557687b137ab71d9e2694c620c3925b45b0e83bebd2f7e60573df3bdfaf6
5
5
  SHA512:
6
- metadata.gz: d919916a3e7cca4b9a074e55b2d43e58e19d7f24ead704468a8e76761ab3d1a72ac303354019acd3868cf6a1b1e8ddd9290e62e747f390681544bd7aa915dfcf
7
- data.tar.gz: 0ae84f1f4b86f685cf504be996c72add22eba009a10b199c97f28515ae197f0010b9bb26fc0bc836326dfd0f0c3be351b2a7fcfbe257e55fd6eb426e85f354ca
6
+ metadata.gz: c6d684c1dc5de2a59f50f297f5865e25b3cfaaf7b4241396ef030d188aafa4ea3c5a1f5ad7e8cbf2a7f72f673091caea18d01101925ba7e1486be3d70c852b28
7
+ data.tar.gz: 7340cdc0e5f4cd5edac28ca4864f7f6bd7acd07441ecc5723f710eea3a66cb10882a547903f77a195232bee26810e7907ec82b4f790e227b7414ac477f7458e7
@@ -847,6 +847,8 @@
847
847
  <xsl:param name="svg_images"/> <!-- svg images array -->
848
848
  <xsl:variable name="images" select="document($svg_images)"/>
849
849
  <xsl:param name="basepath"/> <!-- base path for images -->
850
+ <xsl:param name="inputxml_basepath"/> <!-- input xml file path -->
851
+ <xsl:param name="inputxml_filename"/> <!-- input xml file name -->
850
852
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
851
853
  <xsl:param name="syntax-highlight">false</xsl:param> <!-- syntax highlighting feature, default - off -->
852
854
  <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 -->
@@ -899,6 +901,20 @@
899
901
  <xsl:call-template name="getLang"/>
900
902
  </xsl:variable>
901
903
 
904
+ <xsl:variable name="inputxml_filename_prefix">
905
+ <xsl:choose>
906
+ <xsl:when test="contains($inputxml_filename, '.presentation.xml')">
907
+ <xsl:value-of select="substring-before($inputxml_filename, '.presentation.xml')"/>
908
+ </xsl:when>
909
+ <xsl:when test="contains($inputxml_filename, '.xml')">
910
+ <xsl:value-of select="substring-before($inputxml_filename, '.xml')"/>
911
+ </xsl:when>
912
+ <xsl:otherwise>
913
+ <xsl:value-of select="$inputxml_filename"/>
914
+ </xsl:otherwise>
915
+ </xsl:choose>
916
+ </xsl:variable>
917
+
902
918
  <!-- Note 1: Each xslt has declated variable `namespace` that allows to set some properties, processing logic, etc. for concrete xslt.
903
919
  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>,
904
920
  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 -->
@@ -1828,6 +1844,10 @@
1828
1844
 
1829
1845
  </xsl:attribute-set>
1830
1846
 
1847
+ <xsl:template name="refine_figure-block-style">
1848
+
1849
+ </xsl:template>
1850
+
1831
1851
  <xsl:attribute-set name="figure-style">
1832
1852
 
1833
1853
  </xsl:attribute-set>
@@ -2741,7 +2761,7 @@
2741
2761
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)/*/tr[1]/td)"/>
2742
2762
 
2743
2763
  <xsl:variable name="colwidths">
2744
- <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
2764
+ <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col']) and not(@class = 'dl')">
2745
2765
  <xsl:call-template name="calculate-column-widths">
2746
2766
  <xsl:with-param name="cols-count" select="$cols-count"/>
2747
2767
  <xsl:with-param name="table" select="$simple-table"/>
@@ -2853,6 +2873,11 @@
2853
2873
  <fo:table-column column-width="{@width}"/>
2854
2874
  </xsl:for-each>
2855
2875
  </xsl:when>
2876
+ <xsl:when test="@class = 'dl'">
2877
+ <xsl:for-each select=".//*[local-name()='tr'][1]/*">
2878
+ <fo:table-column column-width="{@width}"/>
2879
+ </xsl:for-each>
2880
+ </xsl:when>
2856
2881
  <xsl:otherwise>
2857
2882
  <xsl:call-template name="insertTableColumnWidth">
2858
2883
  <xsl:with-param name="colwidths" select="$colwidths"/>
@@ -4128,6 +4153,7 @@
4128
4153
  <!-- ===================== -->
4129
4154
  <!-- Definition List -->
4130
4155
  <!-- ===================== -->
4156
+
4131
4157
  <xsl:template match="*[local-name()='dl']">
4132
4158
  <xsl:variable name="isAdded" select="@added"/>
4133
4159
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -4342,10 +4368,21 @@
4342
4368
  </xsl:variable>
4343
4369
 
4344
4370
  <xsl:variable name="colwidths">
4345
- <xsl:call-template name="calculate-column-widths">
4346
- <xsl:with-param name="cols-count" select="2"/>
4347
- <xsl:with-param name="table" select="$simple-table"/>
4348
- </xsl:call-template>
4371
+ <xsl:choose>
4372
+ <!-- dl from table[@class='dl'] -->
4373
+ <xsl:when test="*[local-name() = 'colgroup']">
4374
+ <autolayout/>
4375
+ <xsl:for-each select="*[local-name() = 'colgroup']/*[local-name() = 'col']">
4376
+ <column><xsl:value-of select="translate(@width,'%m','')"/></column>
4377
+ </xsl:for-each>
4378
+ </xsl:when>
4379
+ <xsl:otherwise>
4380
+ <xsl:call-template name="calculate-column-widths">
4381
+ <xsl:with-param name="cols-count" select="2"/>
4382
+ <xsl:with-param name="table" select="$simple-table"/>
4383
+ </xsl:call-template>
4384
+ </xsl:otherwise>
4385
+ </xsl:choose>
4349
4386
  </xsl:variable>
4350
4387
 
4351
4388
  <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
@@ -5076,7 +5113,8 @@
5076
5113
  </xsl:template>
5077
5114
 
5078
5115
  <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
5079
- <xsl:variable name="text" select="normalize-space(.)"/>
5116
+ <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
5117
+ <xsl:variable name="text" select="."/>
5080
5118
  <fo:inline font-size="75%" role="SKIP">
5081
5119
  <xsl:if test="string-length($text) &gt; 0">
5082
5120
  <xsl:variable name="smallCapsText">
@@ -6515,6 +6553,12 @@
6515
6553
  <xsl:when test="@updatetype = 'true'">
6516
6554
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
6517
6555
  </xsl:when>
6556
+ <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
6557
+ <!-- link to the PDF attachment -->
6558
+ <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
6559
+ <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
6560
+ <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
6561
+ </xsl:when>
6518
6562
  <xsl:otherwise>
6519
6563
  <xsl:value-of select="normalize-space(@target)"/>
6520
6564
  </xsl:otherwise>
@@ -6922,6 +6966,7 @@
6922
6966
  <xsl:variable name="isAdded" select="@added"/>
6923
6967
  <xsl:variable name="isDeleted" select="@deleted"/>
6924
6968
  <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
6969
+ <xsl:call-template name="refine_figure-block-style"/>
6925
6970
 
6926
6971
  <xsl:call-template name="setTrackChangesStyles">
6927
6972
  <xsl:with-param name="isAdded" select="$isAdded"/>
@@ -7277,16 +7322,44 @@
7277
7322
  </xsl:choose>
7278
7323
 
7279
7324
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
7280
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
7281
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
7325
+ <xsl:variable name="svg_width_" select="xalan:nodeset($svg_content)/*/@width"/>
7326
+ <xsl:variable name="svg_width" select="number(translate($svg_width_, 'px', ''))"/>
7327
+ <xsl:variable name="svg_height_" select="xalan:nodeset($svg_content)/*/@height"/>
7328
+ <xsl:variable name="svg_height" select="number(translate($svg_height_, 'px', ''))"/>
7329
+
7330
+ <!-- Example: -->
7282
7331
  <!-- effective height 297 - 27.4 - 13 = 256.6 -->
7283
7332
  <!-- effective width 210 - 12.5 - 25 = 172.5 -->
7284
7333
  <!-- effective height / width = 1.48, 1.4 - with title -->
7285
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
7334
+
7335
+ <xsl:variable name="scale_x">
7336
+ <xsl:choose>
7337
+ <xsl:when test="$svg_width &gt; $width_effective_px">
7338
+ <xsl:value-of select="$width_effective_px div $svg_width"/>
7339
+ </xsl:when>
7340
+ <xsl:otherwise>1</xsl:otherwise>
7341
+ </xsl:choose>
7342
+ </xsl:variable>
7343
+ <xsl:variable name="scale_y">
7344
+ <xsl:choose>
7345
+ <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
7346
+ <xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
7347
+ </xsl:when>
7348
+ <xsl:otherwise>1</xsl:otherwise>
7349
+ </xsl:choose>
7350
+ </xsl:variable>
7351
+
7352
+ <!-- for images with big height -->
7353
+ <!-- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)">
7286
7354
  <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
7287
7355
  <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
7288
- </xsl:if>
7356
+ </xsl:if> -->
7289
7357
  <xsl:attribute name="scaling">uniform</xsl:attribute>
7358
+
7359
+ <xsl:if test="$scale_y != 1">
7360
+ <xsl:attribute name="content-height"><xsl:value-of select="round($scale_x * $scale_y * 100)"/>%</xsl:attribute>
7361
+ </xsl:if>
7362
+
7290
7363
  <xsl:copy-of select="$svg_content"/>
7291
7364
  </fo:instream-foreign-object>
7292
7365
  <!-- </fo:block> -->
@@ -7324,8 +7397,12 @@
7324
7397
  <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
7325
7398
  <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
7326
7399
 
7400
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[1][local-name() = 'image']/@width)"/>
7401
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[1][local-name() = 'image']/@height)"/>
7402
+
7327
7403
  <xsl:attribute name="width">
7328
7404
  <xsl:choose>
7405
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7329
7406
  <xsl:when test="$width != ''">
7330
7407
  <xsl:value-of select="round($width)"/>
7331
7408
  </xsl:when>
@@ -7334,6 +7411,7 @@
7334
7411
  </xsl:attribute>
7335
7412
  <xsl:attribute name="height">
7336
7413
  <xsl:choose>
7414
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7337
7415
  <xsl:when test="$height != ''">
7338
7416
  <xsl:value-of select="round($height)"/>
7339
7417
  </xsl:when>
@@ -7345,6 +7423,28 @@
7345
7423
  </xsl:copy>
7346
7424
  </xsl:template>
7347
7425
 
7426
+ <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
7427
+ <!-- image[@width]/svg -->
7428
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
7429
+ <xsl:attribute name="width">
7430
+ <xsl:choose>
7431
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7432
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7433
+ </xsl:choose>
7434
+ </xsl:attribute>
7435
+ </xsl:template>
7436
+
7437
+ <xsl:template match="*[local-name() = 'svg']/@height" mode="svg_update">
7438
+ <!-- image[@height]/svg -->
7439
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
7440
+ <xsl:attribute name="height">
7441
+ <xsl:choose>
7442
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7443
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7444
+ </xsl:choose>
7445
+ </xsl:attribute>
7446
+ </xsl:template>
7447
+
7348
7448
  <!-- regex for 'display: inline-block;' -->
7349
7449
  <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
7350
7450
  <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
@@ -9411,7 +9511,9 @@
9411
9511
  </xsl:template> <!-- sections_element_style -->
9412
9512
 
9413
9513
  <xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
9414
- <fo:block break-after="page"/>
9514
+
9515
+ <fo:block break-after="page"/>
9516
+
9415
9517
  <fo:block>
9416
9518
  <xsl:call-template name="setId"/>
9417
9519
  <xsl:apply-templates/>
@@ -9478,7 +9580,7 @@
9478
9580
  <xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
9479
9581
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9480
9582
  </xsl:when>
9481
- <xsl:when test="not(//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9583
+ <xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9482
9584
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9483
9585
  </xsl:when>
9484
9586
  </xsl:choose>
@@ -11280,10 +11382,10 @@
11280
11382
 
11281
11383
  <xsl:template name="addPDFUAmeta">
11282
11384
  <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
11283
- <pdf:dictionary type="normal" key="ViewerPreferences">
11284
- <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
11285
- </pdf:dictionary>
11286
- </pdf:catalog>
11385
+ <pdf:dictionary type="normal" key="ViewerPreferences">
11386
+ <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
11387
+ </pdf:dictionary>
11388
+ </pdf:catalog>
11287
11389
  <x:xmpmeta xmlns:x="adobe:ns:meta/">
11288
11390
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
11289
11391
  <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
@@ -11335,6 +11437,19 @@
11335
11437
  </rdf:Description>
11336
11438
  </rdf:RDF>
11337
11439
  </x:xmpmeta>
11440
+ <!-- add attachments -->
11441
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
11442
+ <xsl:choose>
11443
+ <xsl:when test="normalize-space() != ''">
11444
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{.}" filename="{@name}"/>
11445
+ </xsl:when>
11446
+ <xsl:otherwise>
11447
+ <!-- _{filename}_attachments -->
11448
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
11449
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
11450
+ </xsl:otherwise>
11451
+ </xsl:choose>
11452
+ </xsl:for-each>
11338
11453
  </xsl:template> <!-- addPDFUAmeta -->
11339
11454
 
11340
11455
  <xsl:template name="getId">
@@ -847,6 +847,8 @@
847
847
  <xsl:param name="svg_images"/> <!-- svg images array -->
848
848
  <xsl:variable name="images" select="document($svg_images)"/>
849
849
  <xsl:param name="basepath"/> <!-- base path for images -->
850
+ <xsl:param name="inputxml_basepath"/> <!-- input xml file path -->
851
+ <xsl:param name="inputxml_filename"/> <!-- input xml file name -->
850
852
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
851
853
  <xsl:param name="syntax-highlight">false</xsl:param> <!-- syntax highlighting feature, default - off -->
852
854
  <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 -->
@@ -899,6 +901,20 @@
899
901
  <xsl:call-template name="getLang"/>
900
902
  </xsl:variable>
901
903
 
904
+ <xsl:variable name="inputxml_filename_prefix">
905
+ <xsl:choose>
906
+ <xsl:when test="contains($inputxml_filename, '.presentation.xml')">
907
+ <xsl:value-of select="substring-before($inputxml_filename, '.presentation.xml')"/>
908
+ </xsl:when>
909
+ <xsl:when test="contains($inputxml_filename, '.xml')">
910
+ <xsl:value-of select="substring-before($inputxml_filename, '.xml')"/>
911
+ </xsl:when>
912
+ <xsl:otherwise>
913
+ <xsl:value-of select="$inputxml_filename"/>
914
+ </xsl:otherwise>
915
+ </xsl:choose>
916
+ </xsl:variable>
917
+
902
918
  <!-- Note 1: Each xslt has declated variable `namespace` that allows to set some properties, processing logic, etc. for concrete xslt.
903
919
  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>,
904
920
  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 -->
@@ -1828,6 +1844,10 @@
1828
1844
 
1829
1845
  </xsl:attribute-set>
1830
1846
 
1847
+ <xsl:template name="refine_figure-block-style">
1848
+
1849
+ </xsl:template>
1850
+
1831
1851
  <xsl:attribute-set name="figure-style">
1832
1852
 
1833
1853
  </xsl:attribute-set>
@@ -2741,7 +2761,7 @@
2741
2761
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)/*/tr[1]/td)"/>
2742
2762
 
2743
2763
  <xsl:variable name="colwidths">
2744
- <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
2764
+ <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col']) and not(@class = 'dl')">
2745
2765
  <xsl:call-template name="calculate-column-widths">
2746
2766
  <xsl:with-param name="cols-count" select="$cols-count"/>
2747
2767
  <xsl:with-param name="table" select="$simple-table"/>
@@ -2853,6 +2873,11 @@
2853
2873
  <fo:table-column column-width="{@width}"/>
2854
2874
  </xsl:for-each>
2855
2875
  </xsl:when>
2876
+ <xsl:when test="@class = 'dl'">
2877
+ <xsl:for-each select=".//*[local-name()='tr'][1]/*">
2878
+ <fo:table-column column-width="{@width}"/>
2879
+ </xsl:for-each>
2880
+ </xsl:when>
2856
2881
  <xsl:otherwise>
2857
2882
  <xsl:call-template name="insertTableColumnWidth">
2858
2883
  <xsl:with-param name="colwidths" select="$colwidths"/>
@@ -4128,6 +4153,7 @@
4128
4153
  <!-- ===================== -->
4129
4154
  <!-- Definition List -->
4130
4155
  <!-- ===================== -->
4156
+
4131
4157
  <xsl:template match="*[local-name()='dl']">
4132
4158
  <xsl:variable name="isAdded" select="@added"/>
4133
4159
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -4342,10 +4368,21 @@
4342
4368
  </xsl:variable>
4343
4369
 
4344
4370
  <xsl:variable name="colwidths">
4345
- <xsl:call-template name="calculate-column-widths">
4346
- <xsl:with-param name="cols-count" select="2"/>
4347
- <xsl:with-param name="table" select="$simple-table"/>
4348
- </xsl:call-template>
4371
+ <xsl:choose>
4372
+ <!-- dl from table[@class='dl'] -->
4373
+ <xsl:when test="*[local-name() = 'colgroup']">
4374
+ <autolayout/>
4375
+ <xsl:for-each select="*[local-name() = 'colgroup']/*[local-name() = 'col']">
4376
+ <column><xsl:value-of select="translate(@width,'%m','')"/></column>
4377
+ </xsl:for-each>
4378
+ </xsl:when>
4379
+ <xsl:otherwise>
4380
+ <xsl:call-template name="calculate-column-widths">
4381
+ <xsl:with-param name="cols-count" select="2"/>
4382
+ <xsl:with-param name="table" select="$simple-table"/>
4383
+ </xsl:call-template>
4384
+ </xsl:otherwise>
4385
+ </xsl:choose>
4349
4386
  </xsl:variable>
4350
4387
 
4351
4388
  <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
@@ -5076,7 +5113,8 @@
5076
5113
  </xsl:template>
5077
5114
 
5078
5115
  <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
5079
- <xsl:variable name="text" select="normalize-space(.)"/>
5116
+ <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
5117
+ <xsl:variable name="text" select="."/>
5080
5118
  <fo:inline font-size="75%" role="SKIP">
5081
5119
  <xsl:if test="string-length($text) &gt; 0">
5082
5120
  <xsl:variable name="smallCapsText">
@@ -6515,6 +6553,12 @@
6515
6553
  <xsl:when test="@updatetype = 'true'">
6516
6554
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
6517
6555
  </xsl:when>
6556
+ <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
6557
+ <!-- link to the PDF attachment -->
6558
+ <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
6559
+ <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
6560
+ <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
6561
+ </xsl:when>
6518
6562
  <xsl:otherwise>
6519
6563
  <xsl:value-of select="normalize-space(@target)"/>
6520
6564
  </xsl:otherwise>
@@ -6922,6 +6966,7 @@
6922
6966
  <xsl:variable name="isAdded" select="@added"/>
6923
6967
  <xsl:variable name="isDeleted" select="@deleted"/>
6924
6968
  <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
6969
+ <xsl:call-template name="refine_figure-block-style"/>
6925
6970
 
6926
6971
  <xsl:call-template name="setTrackChangesStyles">
6927
6972
  <xsl:with-param name="isAdded" select="$isAdded"/>
@@ -7277,16 +7322,44 @@
7277
7322
  </xsl:choose>
7278
7323
 
7279
7324
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
7280
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
7281
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
7325
+ <xsl:variable name="svg_width_" select="xalan:nodeset($svg_content)/*/@width"/>
7326
+ <xsl:variable name="svg_width" select="number(translate($svg_width_, 'px', ''))"/>
7327
+ <xsl:variable name="svg_height_" select="xalan:nodeset($svg_content)/*/@height"/>
7328
+ <xsl:variable name="svg_height" select="number(translate($svg_height_, 'px', ''))"/>
7329
+
7330
+ <!-- Example: -->
7282
7331
  <!-- effective height 297 - 27.4 - 13 = 256.6 -->
7283
7332
  <!-- effective width 210 - 12.5 - 25 = 172.5 -->
7284
7333
  <!-- effective height / width = 1.48, 1.4 - with title -->
7285
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
7334
+
7335
+ <xsl:variable name="scale_x">
7336
+ <xsl:choose>
7337
+ <xsl:when test="$svg_width &gt; $width_effective_px">
7338
+ <xsl:value-of select="$width_effective_px div $svg_width"/>
7339
+ </xsl:when>
7340
+ <xsl:otherwise>1</xsl:otherwise>
7341
+ </xsl:choose>
7342
+ </xsl:variable>
7343
+ <xsl:variable name="scale_y">
7344
+ <xsl:choose>
7345
+ <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
7346
+ <xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
7347
+ </xsl:when>
7348
+ <xsl:otherwise>1</xsl:otherwise>
7349
+ </xsl:choose>
7350
+ </xsl:variable>
7351
+
7352
+ <!-- for images with big height -->
7353
+ <!-- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)">
7286
7354
  <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
7287
7355
  <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
7288
- </xsl:if>
7356
+ </xsl:if> -->
7289
7357
  <xsl:attribute name="scaling">uniform</xsl:attribute>
7358
+
7359
+ <xsl:if test="$scale_y != 1">
7360
+ <xsl:attribute name="content-height"><xsl:value-of select="round($scale_x * $scale_y * 100)"/>%</xsl:attribute>
7361
+ </xsl:if>
7362
+
7290
7363
  <xsl:copy-of select="$svg_content"/>
7291
7364
  </fo:instream-foreign-object>
7292
7365
  <!-- </fo:block> -->
@@ -7324,8 +7397,12 @@
7324
7397
  <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
7325
7398
  <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
7326
7399
 
7400
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[1][local-name() = 'image']/@width)"/>
7401
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[1][local-name() = 'image']/@height)"/>
7402
+
7327
7403
  <xsl:attribute name="width">
7328
7404
  <xsl:choose>
7405
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7329
7406
  <xsl:when test="$width != ''">
7330
7407
  <xsl:value-of select="round($width)"/>
7331
7408
  </xsl:when>
@@ -7334,6 +7411,7 @@
7334
7411
  </xsl:attribute>
7335
7412
  <xsl:attribute name="height">
7336
7413
  <xsl:choose>
7414
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7337
7415
  <xsl:when test="$height != ''">
7338
7416
  <xsl:value-of select="round($height)"/>
7339
7417
  </xsl:when>
@@ -7345,6 +7423,28 @@
7345
7423
  </xsl:copy>
7346
7424
  </xsl:template>
7347
7425
 
7426
+ <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
7427
+ <!-- image[@width]/svg -->
7428
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
7429
+ <xsl:attribute name="width">
7430
+ <xsl:choose>
7431
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7432
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7433
+ </xsl:choose>
7434
+ </xsl:attribute>
7435
+ </xsl:template>
7436
+
7437
+ <xsl:template match="*[local-name() = 'svg']/@height" mode="svg_update">
7438
+ <!-- image[@height]/svg -->
7439
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
7440
+ <xsl:attribute name="height">
7441
+ <xsl:choose>
7442
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7443
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7444
+ </xsl:choose>
7445
+ </xsl:attribute>
7446
+ </xsl:template>
7447
+
7348
7448
  <!-- regex for 'display: inline-block;' -->
7349
7449
  <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
7350
7450
  <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
@@ -9411,7 +9511,9 @@
9411
9511
  </xsl:template> <!-- sections_element_style -->
9412
9512
 
9413
9513
  <xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
9414
- <fo:block break-after="page"/>
9514
+
9515
+ <fo:block break-after="page"/>
9516
+
9415
9517
  <fo:block>
9416
9518
  <xsl:call-template name="setId"/>
9417
9519
  <xsl:apply-templates/>
@@ -9478,7 +9580,7 @@
9478
9580
  <xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
9479
9581
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9480
9582
  </xsl:when>
9481
- <xsl:when test="not(//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9583
+ <xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9482
9584
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9483
9585
  </xsl:when>
9484
9586
  </xsl:choose>
@@ -11280,10 +11382,10 @@
11280
11382
 
11281
11383
  <xsl:template name="addPDFUAmeta">
11282
11384
  <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
11283
- <pdf:dictionary type="normal" key="ViewerPreferences">
11284
- <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
11285
- </pdf:dictionary>
11286
- </pdf:catalog>
11385
+ <pdf:dictionary type="normal" key="ViewerPreferences">
11386
+ <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
11387
+ </pdf:dictionary>
11388
+ </pdf:catalog>
11287
11389
  <x:xmpmeta xmlns:x="adobe:ns:meta/">
11288
11390
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
11289
11391
  <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
@@ -11335,6 +11437,19 @@
11335
11437
  </rdf:Description>
11336
11438
  </rdf:RDF>
11337
11439
  </x:xmpmeta>
11440
+ <!-- add attachments -->
11441
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
11442
+ <xsl:choose>
11443
+ <xsl:when test="normalize-space() != ''">
11444
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{.}" filename="{@name}"/>
11445
+ </xsl:when>
11446
+ <xsl:otherwise>
11447
+ <!-- _{filename}_attachments -->
11448
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
11449
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
11450
+ </xsl:otherwise>
11451
+ </xsl:choose>
11452
+ </xsl:for-each>
11338
11453
  </xsl:template> <!-- addPDFUAmeta -->
11339
11454
 
11340
11455
  <xsl:template name="getId">
@@ -22,6 +22,11 @@ module IsoDoc
22
22
  )
23
23
  end
24
24
 
25
+ def bibrenderer(options = {})
26
+ ::Relaton::Render::IHO::General.new(options.merge(language: @lang,
27
+ i18nhash: @i18n.get))
28
+ end
29
+
25
30
  def info(isoxml, out)
26
31
  @meta.series isoxml, out
27
32
  super
@@ -6,10 +6,6 @@ require_relative "../../relaton/render/general"
6
6
  module IsoDoc
7
7
  module IHO
8
8
  class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
9
- def bibrenderer
10
- ::Relaton::Render::IHO::General.new(language: @lang)
11
- end
12
-
13
9
  def norm_ref_entry_code(ordinal, _idents, _ids, _standard, _datefn, _bib)
14
10
  "[#{ordinal}]<tab/>"
15
11
  end
@@ -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 IHO
3
- VERSION = "0.9.2".freeze
3
+ VERSION = "0.9.4".freeze
4
4
  end
5
5
  end
@@ -11,11 +11,7 @@ module Relaton
11
11
  end
12
12
 
13
13
  def klass_initialize(_options)
14
- @nametemplateklass = Relaton::Render::Template::Name
15
- @seriestemplateklass = Relaton::Render::Template::Series
16
- @extenttemplateklass = Relaton::Render::Template::Extent
17
- @sizetemplateklass = Relaton::Render::Template::Size
18
- @generaltemplateklass = Relaton::Render::Template::General
14
+ super
19
15
  @fieldsklass = Relaton::Render::IHO::Fields
20
16
  @parseklass = Relaton::Render::IHO::Parse
21
17
  end
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
29
29
 
30
- spec.add_dependency "metanorma-generic", "~> 2.6.1"
30
+ spec.add_dependency "metanorma-generic", "~> 2.6.2"
31
31
 
32
32
  spec.add_development_dependency "debug"
33
33
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.4
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: metanorma-generic
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.6.1
19
+ version: 2.6.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.6.1
26
+ version: 2.6.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: debug
29
29
  requirement: !ruby/object:Gem::Requirement