metanorma-ogc 2.5.2 → 2.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -386,7 +386,7 @@
386
386
  <fo:inline font-weight="bold">
387
387
  <!-- Editor: -->
388
388
  <xsl:call-template name="getLocalizedString">
389
- <xsl:with-param name="key">editor</xsl:with-param>
389
+ <xsl:with-param name="key">editor_full</xsl:with-param>
390
390
  </xsl:call-template><xsl:text>: </xsl:text>
391
391
  </fo:inline>
392
392
  <xsl:for-each select="/ogc:ogc-standard/ogc:bibdata/ogc:contributor[ogc:role/@type='editor']/ogc:person/ogc:name/ogc:completename">
@@ -1577,6 +1577,8 @@
1577
1577
  <xsl:param name="svg_images"/> <!-- svg images array -->
1578
1578
  <xsl:variable name="images" select="document($svg_images)"/>
1579
1579
  <xsl:param name="basepath"/> <!-- base path for images -->
1580
+ <xsl:param name="inputxml_basepath"/> <!-- input xml file path -->
1581
+ <xsl:param name="inputxml_filename"/> <!-- input xml file name -->
1580
1582
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
1581
1583
  <xsl:param name="syntax-highlight">false</xsl:param> <!-- syntax highlighting feature, default - off -->
1582
1584
  <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 -->
@@ -1629,6 +1631,20 @@
1629
1631
  <xsl:call-template name="getLang"/>
1630
1632
  </xsl:variable>
1631
1633
 
1634
+ <xsl:variable name="inputxml_filename_prefix">
1635
+ <xsl:choose>
1636
+ <xsl:when test="contains($inputxml_filename, '.presentation.xml')">
1637
+ <xsl:value-of select="substring-before($inputxml_filename, '.presentation.xml')"/>
1638
+ </xsl:when>
1639
+ <xsl:when test="contains($inputxml_filename, '.xml')">
1640
+ <xsl:value-of select="substring-before($inputxml_filename, '.xml')"/>
1641
+ </xsl:when>
1642
+ <xsl:otherwise>
1643
+ <xsl:value-of select="$inputxml_filename"/>
1644
+ </xsl:otherwise>
1645
+ </xsl:choose>
1646
+ </xsl:variable>
1647
+
1632
1648
  <!-- Note 1: Each xslt has declated variable `namespace` that allows to set some properties, processing logic, etc. for concrete xslt.
1633
1649
  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>,
1634
1650
  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 -->
@@ -2657,6 +2673,10 @@
2657
2673
 
2658
2674
  </xsl:attribute-set>
2659
2675
 
2676
+ <xsl:template name="refine_figure-block-style">
2677
+
2678
+ </xsl:template>
2679
+
2660
2680
  <xsl:attribute-set name="figure-style">
2661
2681
 
2662
2682
  </xsl:attribute-set>
@@ -3609,7 +3629,7 @@
3609
3629
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)/*/tr[1]/td)"/>
3610
3630
 
3611
3631
  <xsl:variable name="colwidths">
3612
- <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
3632
+ <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col']) and not(@class = 'dl')">
3613
3633
  <xsl:call-template name="calculate-column-widths">
3614
3634
  <xsl:with-param name="cols-count" select="$cols-count"/>
3615
3635
  <xsl:with-param name="table" select="$simple-table"/>
@@ -3727,6 +3747,11 @@
3727
3747
  <fo:table-column column-width="{@width}"/>
3728
3748
  </xsl:for-each>
3729
3749
  </xsl:when>
3750
+ <xsl:when test="@class = 'dl'">
3751
+ <xsl:for-each select=".//*[local-name()='tr'][1]/*">
3752
+ <fo:table-column column-width="{@width}"/>
3753
+ </xsl:for-each>
3754
+ </xsl:when>
3730
3755
  <xsl:otherwise>
3731
3756
  <xsl:call-template name="insertTableColumnWidth">
3732
3757
  <xsl:with-param name="colwidths" select="$colwidths"/>
@@ -5010,6 +5035,7 @@
5010
5035
  <!-- ===================== -->
5011
5036
  <!-- Definition List -->
5012
5037
  <!-- ===================== -->
5038
+
5013
5039
  <xsl:template match="*[local-name()='dl']">
5014
5040
  <xsl:variable name="isAdded" select="@added"/>
5015
5041
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -5222,10 +5248,21 @@
5222
5248
  </xsl:variable>
5223
5249
 
5224
5250
  <xsl:variable name="colwidths">
5225
- <xsl:call-template name="calculate-column-widths">
5226
- <xsl:with-param name="cols-count" select="2"/>
5227
- <xsl:with-param name="table" select="$simple-table"/>
5228
- </xsl:call-template>
5251
+ <xsl:choose>
5252
+ <!-- dl from table[@class='dl'] -->
5253
+ <xsl:when test="*[local-name() = 'colgroup']">
5254
+ <autolayout/>
5255
+ <xsl:for-each select="*[local-name() = 'colgroup']/*[local-name() = 'col']">
5256
+ <column><xsl:value-of select="translate(@width,'%m','')"/></column>
5257
+ </xsl:for-each>
5258
+ </xsl:when>
5259
+ <xsl:otherwise>
5260
+ <xsl:call-template name="calculate-column-widths">
5261
+ <xsl:with-param name="cols-count" select="2"/>
5262
+ <xsl:with-param name="table" select="$simple-table"/>
5263
+ </xsl:call-template>
5264
+ </xsl:otherwise>
5265
+ </xsl:choose>
5229
5266
  </xsl:variable>
5230
5267
 
5231
5268
  <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
@@ -5963,7 +6000,8 @@
5963
6000
  </xsl:template>
5964
6001
 
5965
6002
  <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
5966
- <xsl:variable name="text" select="normalize-space(.)"/>
6003
+ <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
6004
+ <xsl:variable name="text" select="."/>
5967
6005
  <fo:inline font-size="75%" role="SKIP">
5968
6006
  <xsl:if test="string-length($text) &gt; 0">
5969
6007
  <xsl:variable name="smallCapsText">
@@ -7331,6 +7369,12 @@
7331
7369
  <xsl:when test="@updatetype = 'true'">
7332
7370
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
7333
7371
  </xsl:when>
7372
+ <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
7373
+ <!-- link to the PDF attachment -->
7374
+ <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
7375
+ <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
7376
+ <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
7377
+ </xsl:when>
7334
7378
  <xsl:otherwise>
7335
7379
  <xsl:value-of select="normalize-space(@target)"/>
7336
7380
  </xsl:otherwise>
@@ -7744,6 +7788,7 @@
7744
7788
  <xsl:variable name="isAdded" select="@added"/>
7745
7789
  <xsl:variable name="isDeleted" select="@deleted"/>
7746
7790
  <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
7791
+ <xsl:call-template name="refine_figure-block-style"/>
7747
7792
 
7748
7793
  <xsl:call-template name="setTrackChangesStyles">
7749
7794
  <xsl:with-param name="isAdded" select="$isAdded"/>
@@ -8099,16 +8144,44 @@
8099
8144
  </xsl:choose>
8100
8145
 
8101
8146
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
8102
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
8103
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
8147
+ <xsl:variable name="svg_width_" select="xalan:nodeset($svg_content)/*/@width"/>
8148
+ <xsl:variable name="svg_width" select="number(translate($svg_width_, 'px', ''))"/>
8149
+ <xsl:variable name="svg_height_" select="xalan:nodeset($svg_content)/*/@height"/>
8150
+ <xsl:variable name="svg_height" select="number(translate($svg_height_, 'px', ''))"/>
8151
+
8152
+ <!-- Example: -->
8104
8153
  <!-- effective height 297 - 27.4 - 13 = 256.6 -->
8105
8154
  <!-- effective width 210 - 12.5 - 25 = 172.5 -->
8106
8155
  <!-- effective height / width = 1.48, 1.4 - with title -->
8107
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
8156
+
8157
+ <xsl:variable name="scale_x">
8158
+ <xsl:choose>
8159
+ <xsl:when test="$svg_width &gt; $width_effective_px">
8160
+ <xsl:value-of select="$width_effective_px div $svg_width"/>
8161
+ </xsl:when>
8162
+ <xsl:otherwise>1</xsl:otherwise>
8163
+ </xsl:choose>
8164
+ </xsl:variable>
8165
+ <xsl:variable name="scale_y">
8166
+ <xsl:choose>
8167
+ <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
8168
+ <xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
8169
+ </xsl:when>
8170
+ <xsl:otherwise>1</xsl:otherwise>
8171
+ </xsl:choose>
8172
+ </xsl:variable>
8173
+
8174
+ <!-- for images with big height -->
8175
+ <!-- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)">
8108
8176
  <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
8109
8177
  <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
8110
- </xsl:if>
8178
+ </xsl:if> -->
8111
8179
  <xsl:attribute name="scaling">uniform</xsl:attribute>
8180
+
8181
+ <xsl:if test="$scale_y != 1">
8182
+ <xsl:attribute name="content-height"><xsl:value-of select="round($scale_x * $scale_y * 100)"/>%</xsl:attribute>
8183
+ </xsl:if>
8184
+
8112
8185
  <xsl:copy-of select="$svg_content"/>
8113
8186
  </fo:instream-foreign-object>
8114
8187
  <!-- </fo:block> -->
@@ -8146,8 +8219,12 @@
8146
8219
  <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
8147
8220
  <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
8148
8221
 
8222
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[1][local-name() = 'image']/@width)"/>
8223
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[1][local-name() = 'image']/@height)"/>
8224
+
8149
8225
  <xsl:attribute name="width">
8150
8226
  <xsl:choose>
8227
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
8151
8228
  <xsl:when test="$width != ''">
8152
8229
  <xsl:value-of select="round($width)"/>
8153
8230
  </xsl:when>
@@ -8156,6 +8233,7 @@
8156
8233
  </xsl:attribute>
8157
8234
  <xsl:attribute name="height">
8158
8235
  <xsl:choose>
8236
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
8159
8237
  <xsl:when test="$height != ''">
8160
8238
  <xsl:value-of select="round($height)"/>
8161
8239
  </xsl:when>
@@ -8167,6 +8245,28 @@
8167
8245
  </xsl:copy>
8168
8246
  </xsl:template>
8169
8247
 
8248
+ <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
8249
+ <!-- image[@width]/svg -->
8250
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
8251
+ <xsl:attribute name="width">
8252
+ <xsl:choose>
8253
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
8254
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
8255
+ </xsl:choose>
8256
+ </xsl:attribute>
8257
+ </xsl:template>
8258
+
8259
+ <xsl:template match="*[local-name() = 'svg']/@height" mode="svg_update">
8260
+ <!-- image[@height]/svg -->
8261
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
8262
+ <xsl:attribute name="height">
8263
+ <xsl:choose>
8264
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
8265
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
8266
+ </xsl:choose>
8267
+ </xsl:attribute>
8268
+ </xsl:template>
8269
+
8170
8270
  <!-- regex for 'display: inline-block;' -->
8171
8271
  <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
8172
8272
  <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
@@ -10287,7 +10387,9 @@
10287
10387
  </xsl:template> <!-- sections_element_style -->
10288
10388
 
10289
10389
  <xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
10290
- <fo:block break-after="page"/>
10390
+
10391
+ <fo:block break-after="page"/>
10392
+
10291
10393
  <fo:block>
10292
10394
  <xsl:call-template name="setId"/>
10293
10395
  <xsl:apply-templates/>
@@ -10354,7 +10456,7 @@
10354
10456
  <xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
10355
10457
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
10356
10458
  </xsl:when>
10357
- <xsl:when test="not(//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
10459
+ <xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
10358
10460
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
10359
10461
  </xsl:when>
10360
10462
  </xsl:choose>
@@ -12150,10 +12252,10 @@
12150
12252
 
12151
12253
  <xsl:template name="addPDFUAmeta">
12152
12254
  <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
12153
- <pdf:dictionary type="normal" key="ViewerPreferences">
12154
- <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
12155
- </pdf:dictionary>
12156
- </pdf:catalog>
12255
+ <pdf:dictionary type="normal" key="ViewerPreferences">
12256
+ <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
12257
+ </pdf:dictionary>
12258
+ </pdf:catalog>
12157
12259
  <x:xmpmeta xmlns:x="adobe:ns:meta/">
12158
12260
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
12159
12261
  <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
@@ -12205,6 +12307,19 @@
12205
12307
  </rdf:Description>
12206
12308
  </rdf:RDF>
12207
12309
  </x:xmpmeta>
12310
+ <!-- add attachments -->
12311
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
12312
+ <xsl:choose>
12313
+ <xsl:when test="normalize-space() != ''">
12314
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{.}" filename="{@name}"/>
12315
+ </xsl:when>
12316
+ <xsl:otherwise>
12317
+ <!-- _{filename}_attachments -->
12318
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
12319
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
12320
+ </xsl:otherwise>
12321
+ </xsl:choose>
12322
+ </xsl:for-each>
12208
12323
  </xsl:template> <!-- addPDFUAmeta -->
12209
12324
 
12210
12325
  <xsl:template name="getId">
@@ -164,7 +164,12 @@
164
164
  </xsl:for-each>
165
165
  </xsl:variable>
166
166
  <xsl:if test="normalize-space($editors) != ''">
167
- <fo:block margin-top="6pt">Editor: <xsl:value-of select="$editors"/></fo:block>
167
+ <fo:block margin-top="6pt">
168
+ <!-- Editor: -->
169
+ <xsl:call-template name="getLocalizedString">
170
+ <xsl:with-param name="key">editor_full</xsl:with-param>
171
+ </xsl:call-template><xsl:text>: </xsl:text><xsl:value-of select="$editors"/>
172
+ </fo:block>
168
173
  </xsl:if>
169
174
  </fo:block>
170
175
 
@@ -648,6 +653,8 @@
648
653
  <xsl:param name="svg_images"/> <!-- svg images array -->
649
654
  <xsl:variable name="images" select="document($svg_images)"/>
650
655
  <xsl:param name="basepath"/> <!-- base path for images -->
656
+ <xsl:param name="inputxml_basepath"/> <!-- input xml file path -->
657
+ <xsl:param name="inputxml_filename"/> <!-- input xml file name -->
651
658
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
652
659
  <xsl:param name="syntax-highlight">false</xsl:param> <!-- syntax highlighting feature, default - off -->
653
660
  <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 -->
@@ -700,6 +707,20 @@
700
707
  <xsl:call-template name="getLang"/>
701
708
  </xsl:variable>
702
709
 
710
+ <xsl:variable name="inputxml_filename_prefix">
711
+ <xsl:choose>
712
+ <xsl:when test="contains($inputxml_filename, '.presentation.xml')">
713
+ <xsl:value-of select="substring-before($inputxml_filename, '.presentation.xml')"/>
714
+ </xsl:when>
715
+ <xsl:when test="contains($inputxml_filename, '.xml')">
716
+ <xsl:value-of select="substring-before($inputxml_filename, '.xml')"/>
717
+ </xsl:when>
718
+ <xsl:otherwise>
719
+ <xsl:value-of select="$inputxml_filename"/>
720
+ </xsl:otherwise>
721
+ </xsl:choose>
722
+ </xsl:variable>
723
+
703
724
  <!-- Note 1: Each xslt has declated variable `namespace` that allows to set some properties, processing logic, etc. for concrete xslt.
704
725
  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>,
705
726
  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 -->
@@ -1686,6 +1707,10 @@
1686
1707
 
1687
1708
  </xsl:attribute-set>
1688
1709
 
1710
+ <xsl:template name="refine_figure-block-style">
1711
+
1712
+ </xsl:template>
1713
+
1689
1714
  <xsl:attribute-set name="figure-style">
1690
1715
 
1691
1716
  </xsl:attribute-set>
@@ -2646,7 +2671,7 @@
2646
2671
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)/*/tr[1]/td)"/>
2647
2672
 
2648
2673
  <xsl:variable name="colwidths">
2649
- <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
2674
+ <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col']) and not(@class = 'dl')">
2650
2675
  <xsl:call-template name="calculate-column-widths">
2651
2676
  <xsl:with-param name="cols-count" select="$cols-count"/>
2652
2677
  <xsl:with-param name="table" select="$simple-table"/>
@@ -2764,6 +2789,11 @@
2764
2789
  <fo:table-column column-width="{@width}"/>
2765
2790
  </xsl:for-each>
2766
2791
  </xsl:when>
2792
+ <xsl:when test="@class = 'dl'">
2793
+ <xsl:for-each select=".//*[local-name()='tr'][1]/*">
2794
+ <fo:table-column column-width="{@width}"/>
2795
+ </xsl:for-each>
2796
+ </xsl:when>
2767
2797
  <xsl:otherwise>
2768
2798
  <xsl:call-template name="insertTableColumnWidth">
2769
2799
  <xsl:with-param name="colwidths" select="$colwidths"/>
@@ -4049,6 +4079,7 @@
4049
4079
  <!-- ===================== -->
4050
4080
  <!-- Definition List -->
4051
4081
  <!-- ===================== -->
4082
+
4052
4083
  <xsl:template match="*[local-name()='dl']">
4053
4084
  <xsl:variable name="isAdded" select="@added"/>
4054
4085
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -4261,10 +4292,21 @@
4261
4292
  </xsl:variable>
4262
4293
 
4263
4294
  <xsl:variable name="colwidths">
4264
- <xsl:call-template name="calculate-column-widths">
4265
- <xsl:with-param name="cols-count" select="2"/>
4266
- <xsl:with-param name="table" select="$simple-table"/>
4267
- </xsl:call-template>
4295
+ <xsl:choose>
4296
+ <!-- dl from table[@class='dl'] -->
4297
+ <xsl:when test="*[local-name() = 'colgroup']">
4298
+ <autolayout/>
4299
+ <xsl:for-each select="*[local-name() = 'colgroup']/*[local-name() = 'col']">
4300
+ <column><xsl:value-of select="translate(@width,'%m','')"/></column>
4301
+ </xsl:for-each>
4302
+ </xsl:when>
4303
+ <xsl:otherwise>
4304
+ <xsl:call-template name="calculate-column-widths">
4305
+ <xsl:with-param name="cols-count" select="2"/>
4306
+ <xsl:with-param name="table" select="$simple-table"/>
4307
+ </xsl:call-template>
4308
+ </xsl:otherwise>
4309
+ </xsl:choose>
4268
4310
  </xsl:variable>
4269
4311
 
4270
4312
  <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
@@ -4995,7 +5037,8 @@
4995
5037
  </xsl:template>
4996
5038
 
4997
5039
  <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
4998
- <xsl:variable name="text" select="normalize-space(.)"/>
5040
+ <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
5041
+ <xsl:variable name="text" select="."/>
4999
5042
  <fo:inline font-size="75%" role="SKIP">
5000
5043
  <xsl:if test="string-length($text) &gt; 0">
5001
5044
  <xsl:variable name="smallCapsText">
@@ -6363,6 +6406,12 @@
6363
6406
  <xsl:when test="@updatetype = 'true'">
6364
6407
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
6365
6408
  </xsl:when>
6409
+ <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
6410
+ <!-- link to the PDF attachment -->
6411
+ <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
6412
+ <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
6413
+ <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
6414
+ </xsl:when>
6366
6415
  <xsl:otherwise>
6367
6416
  <xsl:value-of select="normalize-space(@target)"/>
6368
6417
  </xsl:otherwise>
@@ -6770,6 +6819,7 @@
6770
6819
  <xsl:variable name="isAdded" select="@added"/>
6771
6820
  <xsl:variable name="isDeleted" select="@deleted"/>
6772
6821
  <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
6822
+ <xsl:call-template name="refine_figure-block-style"/>
6773
6823
 
6774
6824
  <xsl:call-template name="setTrackChangesStyles">
6775
6825
  <xsl:with-param name="isAdded" select="$isAdded"/>
@@ -7125,16 +7175,44 @@
7125
7175
  </xsl:choose>
7126
7176
 
7127
7177
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
7128
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
7129
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
7178
+ <xsl:variable name="svg_width_" select="xalan:nodeset($svg_content)/*/@width"/>
7179
+ <xsl:variable name="svg_width" select="number(translate($svg_width_, 'px', ''))"/>
7180
+ <xsl:variable name="svg_height_" select="xalan:nodeset($svg_content)/*/@height"/>
7181
+ <xsl:variable name="svg_height" select="number(translate($svg_height_, 'px', ''))"/>
7182
+
7183
+ <!-- Example: -->
7130
7184
  <!-- effective height 297 - 27.4 - 13 = 256.6 -->
7131
7185
  <!-- effective width 210 - 12.5 - 25 = 172.5 -->
7132
7186
  <!-- effective height / width = 1.48, 1.4 - with title -->
7133
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
7187
+
7188
+ <xsl:variable name="scale_x">
7189
+ <xsl:choose>
7190
+ <xsl:when test="$svg_width &gt; $width_effective_px">
7191
+ <xsl:value-of select="$width_effective_px div $svg_width"/>
7192
+ </xsl:when>
7193
+ <xsl:otherwise>1</xsl:otherwise>
7194
+ </xsl:choose>
7195
+ </xsl:variable>
7196
+ <xsl:variable name="scale_y">
7197
+ <xsl:choose>
7198
+ <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
7199
+ <xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
7200
+ </xsl:when>
7201
+ <xsl:otherwise>1</xsl:otherwise>
7202
+ </xsl:choose>
7203
+ </xsl:variable>
7204
+
7205
+ <!-- for images with big height -->
7206
+ <!-- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)">
7134
7207
  <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
7135
7208
  <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
7136
- </xsl:if>
7209
+ </xsl:if> -->
7137
7210
  <xsl:attribute name="scaling">uniform</xsl:attribute>
7211
+
7212
+ <xsl:if test="$scale_y != 1">
7213
+ <xsl:attribute name="content-height"><xsl:value-of select="round($scale_x * $scale_y * 100)"/>%</xsl:attribute>
7214
+ </xsl:if>
7215
+
7138
7216
  <xsl:copy-of select="$svg_content"/>
7139
7217
  </fo:instream-foreign-object>
7140
7218
  <!-- </fo:block> -->
@@ -7172,8 +7250,12 @@
7172
7250
  <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
7173
7251
  <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
7174
7252
 
7253
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[1][local-name() = 'image']/@width)"/>
7254
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[1][local-name() = 'image']/@height)"/>
7255
+
7175
7256
  <xsl:attribute name="width">
7176
7257
  <xsl:choose>
7258
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7177
7259
  <xsl:when test="$width != ''">
7178
7260
  <xsl:value-of select="round($width)"/>
7179
7261
  </xsl:when>
@@ -7182,6 +7264,7 @@
7182
7264
  </xsl:attribute>
7183
7265
  <xsl:attribute name="height">
7184
7266
  <xsl:choose>
7267
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7185
7268
  <xsl:when test="$height != ''">
7186
7269
  <xsl:value-of select="round($height)"/>
7187
7270
  </xsl:when>
@@ -7193,6 +7276,28 @@
7193
7276
  </xsl:copy>
7194
7277
  </xsl:template>
7195
7278
 
7279
+ <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
7280
+ <!-- image[@width]/svg -->
7281
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
7282
+ <xsl:attribute name="width">
7283
+ <xsl:choose>
7284
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7285
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7286
+ </xsl:choose>
7287
+ </xsl:attribute>
7288
+ </xsl:template>
7289
+
7290
+ <xsl:template match="*[local-name() = 'svg']/@height" mode="svg_update">
7291
+ <!-- image[@height]/svg -->
7292
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
7293
+ <xsl:attribute name="height">
7294
+ <xsl:choose>
7295
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7296
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7297
+ </xsl:choose>
7298
+ </xsl:attribute>
7299
+ </xsl:template>
7300
+
7196
7301
  <!-- regex for 'display: inline-block;' -->
7197
7302
  <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
7198
7303
  <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
@@ -9294,7 +9399,9 @@
9294
9399
  </xsl:template> <!-- sections_element_style -->
9295
9400
 
9296
9401
  <xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
9297
- <fo:block break-after="page"/>
9402
+
9403
+ <fo:block break-after="page"/>
9404
+
9298
9405
  <fo:block>
9299
9406
  <xsl:call-template name="setId"/>
9300
9407
  <xsl:apply-templates/>
@@ -9361,7 +9468,7 @@
9361
9468
  <xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
9362
9469
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9363
9470
  </xsl:when>
9364
- <xsl:when test="not(//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9471
+ <xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9365
9472
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9366
9473
  </xsl:when>
9367
9474
  </xsl:choose>
@@ -11157,10 +11264,10 @@
11157
11264
 
11158
11265
  <xsl:template name="addPDFUAmeta">
11159
11266
  <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
11160
- <pdf:dictionary type="normal" key="ViewerPreferences">
11161
- <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
11162
- </pdf:dictionary>
11163
- </pdf:catalog>
11267
+ <pdf:dictionary type="normal" key="ViewerPreferences">
11268
+ <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
11269
+ </pdf:dictionary>
11270
+ </pdf:catalog>
11164
11271
  <x:xmpmeta xmlns:x="adobe:ns:meta/">
11165
11272
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
11166
11273
  <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
@@ -11212,6 +11319,19 @@
11212
11319
  </rdf:Description>
11213
11320
  </rdf:RDF>
11214
11321
  </x:xmpmeta>
11322
+ <!-- add attachments -->
11323
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
11324
+ <xsl:choose>
11325
+ <xsl:when test="normalize-space() != ''">
11326
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{.}" filename="{@name}"/>
11327
+ </xsl:when>
11328
+ <xsl:otherwise>
11329
+ <!-- _{filename}_attachments -->
11330
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
11331
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
11332
+ </xsl:otherwise>
11333
+ </xsl:choose>
11334
+ </xsl:for-each>
11215
11335
  </xsl:template> <!-- addPDFUAmeta -->
11216
11336
 
11217
11337
  <xsl:template name="getId">
@@ -157,10 +157,6 @@ module IsoDoc
157
157
  bibitem["hidden"] == "true" || bibitem.parent["hidden"] == "true"
158
158
  end
159
159
 
160
- def bibrenderer
161
- ::Relaton::Render::Ogc::General.new(language: @lang)
162
- end
163
-
164
160
  def bibrender_formattedref(formattedref, xml); end
165
161
 
166
162
  def bibrender_relaton(xml, renderings)
@@ -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">