metanorma-csa 2.4.2 → 2.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5bef565529ba8c3d376a169c0593757f0be8e0f51a876ef8043aa08127728df
4
- data.tar.gz: 47c1ae2636d2c8d0a954694480afe9f998d08afce3eb0626ae9e6f423e583ec4
3
+ metadata.gz: 22d4bfa3220b5d6efd0a74f14bc170f7bc5c2bedfa74a4b983a7199221722bd0
4
+ data.tar.gz: 44e0c583faa3763e6cb12b246a67cbedacdf316e90fb670e56c203a2aad13ee5
5
5
  SHA512:
6
- metadata.gz: 83bcf0f50b66cf1893a1de62f51e1fbcbe77a3703f6071d7be60d7968e6fdc28b772551062a781e3e1b9231aa6e16f190a00137765e60fd83dec2712c5d5e2dd
7
- data.tar.gz: 8d50516c5236e27df948c97cf6e7c36a9182df9e1d51c9fbf382fd1a7c8392978425de3d210d825edf2268976af3c0edc4e35bc3528045f5b821b2fd69addbb7
6
+ metadata.gz: 3c13778cd5fef2c2e7297a2f817cdf3d3fff5df5d070ce8b816000d90dd3587b928b634612a1166469984e0629e2c67abb14d594fef7211a7bfcd4bce0022567
7
+ data.tar.gz: b6754ebcd7ce19a17be4548857980f2fd672fdbcf73d65630f862f96003e130f9c9b75ddc89918f1094c82097da45ad7dd9a4325463abe3dca3e4608480f7e07
@@ -583,6 +583,8 @@
583
583
  <xsl:param name="svg_images"/> <!-- svg images array -->
584
584
  <xsl:variable name="images" select="document($svg_images)"/>
585
585
  <xsl:param name="basepath"/> <!-- base path for images -->
586
+ <xsl:param name="inputxml_basepath"/> <!-- input xml file path -->
587
+ <xsl:param name="inputxml_filename"/> <!-- input xml file name -->
586
588
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
587
589
  <xsl:param name="syntax-highlight">false</xsl:param> <!-- syntax highlighting feature, default - off -->
588
590
  <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 -->
@@ -635,6 +637,20 @@
635
637
  <xsl:call-template name="getLang"/>
636
638
  </xsl:variable>
637
639
 
640
+ <xsl:variable name="inputxml_filename_prefix">
641
+ <xsl:choose>
642
+ <xsl:when test="contains($inputxml_filename, '.presentation.xml')">
643
+ <xsl:value-of select="substring-before($inputxml_filename, '.presentation.xml')"/>
644
+ </xsl:when>
645
+ <xsl:when test="contains($inputxml_filename, '.xml')">
646
+ <xsl:value-of select="substring-before($inputxml_filename, '.xml')"/>
647
+ </xsl:when>
648
+ <xsl:otherwise>
649
+ <xsl:value-of select="$inputxml_filename"/>
650
+ </xsl:otherwise>
651
+ </xsl:choose>
652
+ </xsl:variable>
653
+
638
654
  <!-- Note 1: Each xslt has declated variable `namespace` that allows to set some properties, processing logic, etc. for concrete xslt.
639
655
  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>,
640
656
  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 -->
@@ -1526,6 +1542,10 @@
1526
1542
 
1527
1543
  </xsl:attribute-set>
1528
1544
 
1545
+ <xsl:template name="refine_figure-block-style">
1546
+
1547
+ </xsl:template>
1548
+
1529
1549
  <xsl:attribute-set name="figure-style">
1530
1550
 
1531
1551
  </xsl:attribute-set>
@@ -2444,7 +2464,7 @@
2444
2464
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)/*/tr[1]/td)"/>
2445
2465
 
2446
2466
  <xsl:variable name="colwidths">
2447
- <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
2467
+ <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col']) and not(@class = 'dl')">
2448
2468
  <xsl:call-template name="calculate-column-widths">
2449
2469
  <xsl:with-param name="cols-count" select="$cols-count"/>
2450
2470
  <xsl:with-param name="table" select="$simple-table"/>
@@ -2556,6 +2576,11 @@
2556
2576
  <fo:table-column column-width="{@width}"/>
2557
2577
  </xsl:for-each>
2558
2578
  </xsl:when>
2579
+ <xsl:when test="@class = 'dl'">
2580
+ <xsl:for-each select=".//*[local-name()='tr'][1]/*">
2581
+ <fo:table-column column-width="{@width}"/>
2582
+ </xsl:for-each>
2583
+ </xsl:when>
2559
2584
  <xsl:otherwise>
2560
2585
  <xsl:call-template name="insertTableColumnWidth">
2561
2586
  <xsl:with-param name="colwidths" select="$colwidths"/>
@@ -3831,6 +3856,7 @@
3831
3856
  <!-- ===================== -->
3832
3857
  <!-- Definition List -->
3833
3858
  <!-- ===================== -->
3859
+
3834
3860
  <xsl:template match="*[local-name()='dl']">
3835
3861
  <xsl:variable name="isAdded" select="@added"/>
3836
3862
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -4043,10 +4069,21 @@
4043
4069
  </xsl:variable>
4044
4070
 
4045
4071
  <xsl:variable name="colwidths">
4046
- <xsl:call-template name="calculate-column-widths">
4047
- <xsl:with-param name="cols-count" select="2"/>
4048
- <xsl:with-param name="table" select="$simple-table"/>
4049
- </xsl:call-template>
4072
+ <xsl:choose>
4073
+ <!-- dl from table[@class='dl'] -->
4074
+ <xsl:when test="*[local-name() = 'colgroup']">
4075
+ <autolayout/>
4076
+ <xsl:for-each select="*[local-name() = 'colgroup']/*[local-name() = 'col']">
4077
+ <column><xsl:value-of select="translate(@width,'%m','')"/></column>
4078
+ </xsl:for-each>
4079
+ </xsl:when>
4080
+ <xsl:otherwise>
4081
+ <xsl:call-template name="calculate-column-widths">
4082
+ <xsl:with-param name="cols-count" select="2"/>
4083
+ <xsl:with-param name="table" select="$simple-table"/>
4084
+ </xsl:call-template>
4085
+ </xsl:otherwise>
4086
+ </xsl:choose>
4050
4087
  </xsl:variable>
4051
4088
 
4052
4089
  <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
@@ -4774,7 +4811,8 @@
4774
4811
  </xsl:template>
4775
4812
 
4776
4813
  <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
4777
- <xsl:variable name="text" select="normalize-space(.)"/>
4814
+ <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
4815
+ <xsl:variable name="text" select="."/>
4778
4816
  <fo:inline font-size="75%" role="SKIP">
4779
4817
  <xsl:if test="string-length($text) &gt; 0">
4780
4818
  <xsl:variable name="smallCapsText">
@@ -6142,6 +6180,12 @@
6142
6180
  <xsl:when test="@updatetype = 'true'">
6143
6181
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
6144
6182
  </xsl:when>
6183
+ <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
6184
+ <!-- link to the PDF attachment -->
6185
+ <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
6186
+ <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
6187
+ <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
6188
+ </xsl:when>
6145
6189
  <xsl:otherwise>
6146
6190
  <xsl:value-of select="normalize-space(@target)"/>
6147
6191
  </xsl:otherwise>
@@ -6551,6 +6595,7 @@
6551
6595
  <xsl:variable name="isAdded" select="@added"/>
6552
6596
  <xsl:variable name="isDeleted" select="@deleted"/>
6553
6597
  <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
6598
+ <xsl:call-template name="refine_figure-block-style"/>
6554
6599
 
6555
6600
  <xsl:call-template name="setTrackChangesStyles">
6556
6601
  <xsl:with-param name="isAdded" select="$isAdded"/>
@@ -6906,16 +6951,44 @@
6906
6951
  </xsl:choose>
6907
6952
 
6908
6953
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6909
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
6910
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
6954
+ <xsl:variable name="svg_width_" select="xalan:nodeset($svg_content)/*/@width"/>
6955
+ <xsl:variable name="svg_width" select="number(translate($svg_width_, 'px', ''))"/>
6956
+ <xsl:variable name="svg_height_" select="xalan:nodeset($svg_content)/*/@height"/>
6957
+ <xsl:variable name="svg_height" select="number(translate($svg_height_, 'px', ''))"/>
6958
+
6959
+ <!-- Example: -->
6911
6960
  <!-- effective height 297 - 27.4 - 13 = 256.6 -->
6912
6961
  <!-- effective width 210 - 12.5 - 25 = 172.5 -->
6913
6962
  <!-- effective height / width = 1.48, 1.4 - with title -->
6914
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
6963
+
6964
+ <xsl:variable name="scale_x">
6965
+ <xsl:choose>
6966
+ <xsl:when test="$svg_width &gt; $width_effective_px">
6967
+ <xsl:value-of select="$width_effective_px div $svg_width"/>
6968
+ </xsl:when>
6969
+ <xsl:otherwise>1</xsl:otherwise>
6970
+ </xsl:choose>
6971
+ </xsl:variable>
6972
+ <xsl:variable name="scale_y">
6973
+ <xsl:choose>
6974
+ <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
6975
+ <xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
6976
+ </xsl:when>
6977
+ <xsl:otherwise>1</xsl:otherwise>
6978
+ </xsl:choose>
6979
+ </xsl:variable>
6980
+
6981
+ <!-- for images with big height -->
6982
+ <!-- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)">
6915
6983
  <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
6916
6984
  <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
6917
- </xsl:if>
6985
+ </xsl:if> -->
6918
6986
  <xsl:attribute name="scaling">uniform</xsl:attribute>
6987
+
6988
+ <xsl:if test="$scale_y != 1">
6989
+ <xsl:attribute name="content-height"><xsl:value-of select="round($scale_x * $scale_y * 100)"/>%</xsl:attribute>
6990
+ </xsl:if>
6991
+
6919
6992
  <xsl:copy-of select="$svg_content"/>
6920
6993
  </fo:instream-foreign-object>
6921
6994
  <!-- </fo:block> -->
@@ -6953,8 +7026,12 @@
6953
7026
  <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
6954
7027
  <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
6955
7028
 
7029
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[1][local-name() = 'image']/@width)"/>
7030
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[1][local-name() = 'image']/@height)"/>
7031
+
6956
7032
  <xsl:attribute name="width">
6957
7033
  <xsl:choose>
7034
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
6958
7035
  <xsl:when test="$width != ''">
6959
7036
  <xsl:value-of select="round($width)"/>
6960
7037
  </xsl:when>
@@ -6963,6 +7040,7 @@
6963
7040
  </xsl:attribute>
6964
7041
  <xsl:attribute name="height">
6965
7042
  <xsl:choose>
7043
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
6966
7044
  <xsl:when test="$height != ''">
6967
7045
  <xsl:value-of select="round($height)"/>
6968
7046
  </xsl:when>
@@ -6974,6 +7052,28 @@
6974
7052
  </xsl:copy>
6975
7053
  </xsl:template>
6976
7054
 
7055
+ <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
7056
+ <!-- image[@width]/svg -->
7057
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
7058
+ <xsl:attribute name="width">
7059
+ <xsl:choose>
7060
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7061
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7062
+ </xsl:choose>
7063
+ </xsl:attribute>
7064
+ </xsl:template>
7065
+
7066
+ <xsl:template match="*[local-name() = 'svg']/@height" mode="svg_update">
7067
+ <!-- image[@height]/svg -->
7068
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
7069
+ <xsl:attribute name="height">
7070
+ <xsl:choose>
7071
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7072
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7073
+ </xsl:choose>
7074
+ </xsl:attribute>
7075
+ </xsl:template>
7076
+
6977
7077
  <!-- regex for 'display: inline-block;' -->
6978
7078
  <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
6979
7079
  <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
@@ -9044,7 +9144,9 @@
9044
9144
  </xsl:template> <!-- sections_element_style -->
9045
9145
 
9046
9146
  <xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
9047
- <fo:block break-after="page"/>
9147
+
9148
+ <fo:block break-after="page"/>
9149
+
9048
9150
  <fo:block>
9049
9151
  <xsl:call-template name="setId"/>
9050
9152
  <xsl:apply-templates/>
@@ -9111,7 +9213,7 @@
9111
9213
  <xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
9112
9214
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9113
9215
  </xsl:when>
9114
- <xsl:when test="not(//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9216
+ <xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9115
9217
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9116
9218
  </xsl:when>
9117
9219
  </xsl:choose>
@@ -10887,10 +10989,10 @@
10887
10989
 
10888
10990
  <xsl:template name="addPDFUAmeta">
10889
10991
  <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
10890
- <pdf:dictionary type="normal" key="ViewerPreferences">
10891
- <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
10892
- </pdf:dictionary>
10893
- </pdf:catalog>
10992
+ <pdf:dictionary type="normal" key="ViewerPreferences">
10993
+ <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
10994
+ </pdf:dictionary>
10995
+ </pdf:catalog>
10894
10996
  <x:xmpmeta xmlns:x="adobe:ns:meta/">
10895
10997
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
10896
10998
  <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
@@ -10942,6 +11044,19 @@
10942
11044
  </rdf:Description>
10943
11045
  </rdf:RDF>
10944
11046
  </x:xmpmeta>
11047
+ <!-- add attachments -->
11048
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
11049
+ <xsl:choose>
11050
+ <xsl:when test="normalize-space() != ''">
11051
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{.}" filename="{@name}"/>
11052
+ </xsl:when>
11053
+ <xsl:otherwise>
11054
+ <!-- _{filename}_attachments -->
11055
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
11056
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
11057
+ </xsl:otherwise>
11058
+ </xsl:choose>
11059
+ </xsl:for-each>
10945
11060
  </xsl:template> <!-- addPDFUAmeta -->
10946
11061
 
10947
11062
  <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 Csa
3
- VERSION = "2.4.2".freeze
3
+ VERSION = "2.4.4".freeze
4
4
  end
5
5
  end
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ["lib"]
30
30
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
31
31
 
32
- spec.add_dependency "metanorma-generic", "~> 2.6.1"
32
+ spec.add_dependency "metanorma-generic", "~> 2.6.2"
33
33
 
34
34
  spec.add_development_dependency "debug"
35
35
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-csa
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.2
4
+ version: 2.4.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