metanorma-cc 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: 9addb36ecc8d1ecba39442e834158ad429cd49fea376d5b8493898c1c5d2811a
4
- data.tar.gz: 299a019aaa48c9b41de0e09c5eaf9effe2da3b2f6712c010c1c54cfe86773d16
3
+ metadata.gz: 02500ebd02ebe65c4c1a840c9a57022da0f064f3da738a801811746d04b18cbd
4
+ data.tar.gz: 52ecdef573a1d9e59d3a4ee98bb5de87149badb22e2836e9397b43e2ebdcaea4
5
5
  SHA512:
6
- metadata.gz: 2cb26abbc7ca5b7539e5cefd4679a56d257438d1471d052a4ffc6c5d666f6f79cf7132ae96b03aa562e4a0611d08847314a506303e11bb3cc10ebb654f0467b7
7
- data.tar.gz: 73bacd9658eab6e13961d77b476fd021d37a3ac90cbf535684fa0d0031ea86e9ddde0d023e2bd55f3fe9e81b3f59e4b87cd5425e253d6f954337df1e24893d64
6
+ metadata.gz: 0ec7d7f403145d1306fa3865c59fdaf8e1314b2e0d6abc1060b2a326b03b4703f05ad0aaa9cd0eba7528496c6e70d96f04065bf577f95d08e3272cee54cc431e
7
+ data.tar.gz: a7e0ee3a1dc9bf6ee378ad5ef6e3ebd372e2834f65c4a3ec3526c1fc569b8cc2015a78326f0bac59428247d18ee983a5652fe5818ba09bddeb8a460b51d7873c
@@ -586,6 +586,8 @@
586
586
  <xsl:param name="svg_images"/> <!-- svg images array -->
587
587
  <xsl:variable name="images" select="document($svg_images)"/>
588
588
  <xsl:param name="basepath"/> <!-- base path for images -->
589
+ <xsl:param name="inputxml_basepath"/> <!-- input xml file path -->
590
+ <xsl:param name="inputxml_filename"/> <!-- input xml file name -->
589
591
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
590
592
  <xsl:param name="syntax-highlight">false</xsl:param> <!-- syntax highlighting feature, default - off -->
591
593
  <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 -->
@@ -638,6 +640,20 @@
638
640
  <xsl:call-template name="getLang"/>
639
641
  </xsl:variable>
640
642
 
643
+ <xsl:variable name="inputxml_filename_prefix">
644
+ <xsl:choose>
645
+ <xsl:when test="contains($inputxml_filename, '.presentation.xml')">
646
+ <xsl:value-of select="substring-before($inputxml_filename, '.presentation.xml')"/>
647
+ </xsl:when>
648
+ <xsl:when test="contains($inputxml_filename, '.xml')">
649
+ <xsl:value-of select="substring-before($inputxml_filename, '.xml')"/>
650
+ </xsl:when>
651
+ <xsl:otherwise>
652
+ <xsl:value-of select="$inputxml_filename"/>
653
+ </xsl:otherwise>
654
+ </xsl:choose>
655
+ </xsl:variable>
656
+
641
657
  <!-- Note 1: Each xslt has declated variable `namespace` that allows to set some properties, processing logic, etc. for concrete xslt.
642
658
  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>,
643
659
  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 -->
@@ -1535,6 +1551,10 @@
1535
1551
 
1536
1552
  </xsl:attribute-set>
1537
1553
 
1554
+ <xsl:template name="refine_figure-block-style">
1555
+
1556
+ </xsl:template>
1557
+
1538
1558
  <xsl:attribute-set name="figure-style">
1539
1559
 
1540
1560
  </xsl:attribute-set>
@@ -2430,7 +2450,7 @@
2430
2450
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)/*/tr[1]/td)"/>
2431
2451
 
2432
2452
  <xsl:variable name="colwidths">
2433
- <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
2453
+ <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col']) and not(@class = 'dl')">
2434
2454
  <xsl:call-template name="calculate-column-widths">
2435
2455
  <xsl:with-param name="cols-count" select="$cols-count"/>
2436
2456
  <xsl:with-param name="table" select="$simple-table"/>
@@ -2542,6 +2562,11 @@
2542
2562
  <fo:table-column column-width="{@width}"/>
2543
2563
  </xsl:for-each>
2544
2564
  </xsl:when>
2565
+ <xsl:when test="@class = 'dl'">
2566
+ <xsl:for-each select=".//*[local-name()='tr'][1]/*">
2567
+ <fo:table-column column-width="{@width}"/>
2568
+ </xsl:for-each>
2569
+ </xsl:when>
2545
2570
  <xsl:otherwise>
2546
2571
  <xsl:call-template name="insertTableColumnWidth">
2547
2572
  <xsl:with-param name="colwidths" select="$colwidths"/>
@@ -3817,6 +3842,7 @@
3817
3842
  <!-- ===================== -->
3818
3843
  <!-- Definition List -->
3819
3844
  <!-- ===================== -->
3845
+
3820
3846
  <xsl:template match="*[local-name()='dl']">
3821
3847
  <xsl:variable name="isAdded" select="@added"/>
3822
3848
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -4029,10 +4055,21 @@
4029
4055
  </xsl:variable>
4030
4056
 
4031
4057
  <xsl:variable name="colwidths">
4032
- <xsl:call-template name="calculate-column-widths">
4033
- <xsl:with-param name="cols-count" select="2"/>
4034
- <xsl:with-param name="table" select="$simple-table"/>
4035
- </xsl:call-template>
4058
+ <xsl:choose>
4059
+ <!-- dl from table[@class='dl'] -->
4060
+ <xsl:when test="*[local-name() = 'colgroup']">
4061
+ <autolayout/>
4062
+ <xsl:for-each select="*[local-name() = 'colgroup']/*[local-name() = 'col']">
4063
+ <column><xsl:value-of select="translate(@width,'%m','')"/></column>
4064
+ </xsl:for-each>
4065
+ </xsl:when>
4066
+ <xsl:otherwise>
4067
+ <xsl:call-template name="calculate-column-widths">
4068
+ <xsl:with-param name="cols-count" select="2"/>
4069
+ <xsl:with-param name="table" select="$simple-table"/>
4070
+ </xsl:call-template>
4071
+ </xsl:otherwise>
4072
+ </xsl:choose>
4036
4073
  </xsl:variable>
4037
4074
 
4038
4075
  <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
@@ -4761,7 +4798,8 @@
4761
4798
  </xsl:template>
4762
4799
 
4763
4800
  <xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
4764
- <xsl:variable name="text" select="normalize-space(.)"/>
4801
+ <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 -->
4802
+ <xsl:variable name="text" select="."/>
4765
4803
  <fo:inline font-size="75%" role="SKIP">
4766
4804
  <xsl:if test="string-length($text) &gt; 0">
4767
4805
  <xsl:variable name="smallCapsText">
@@ -6129,6 +6167,12 @@
6129
6167
  <xsl:when test="@updatetype = 'true'">
6130
6168
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
6131
6169
  </xsl:when>
6170
+ <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
6171
+ <!-- link to the PDF attachment -->
6172
+ <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
6173
+ <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
6174
+ <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
6175
+ </xsl:when>
6132
6176
  <xsl:otherwise>
6133
6177
  <xsl:value-of select="normalize-space(@target)"/>
6134
6178
  </xsl:otherwise>
@@ -6534,6 +6578,7 @@
6534
6578
  <xsl:variable name="isAdded" select="@added"/>
6535
6579
  <xsl:variable name="isDeleted" select="@deleted"/>
6536
6580
  <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
6581
+ <xsl:call-template name="refine_figure-block-style"/>
6537
6582
 
6538
6583
  <xsl:call-template name="setTrackChangesStyles">
6539
6584
  <xsl:with-param name="isAdded" select="$isAdded"/>
@@ -6889,16 +6934,44 @@
6889
6934
  </xsl:choose>
6890
6935
 
6891
6936
  <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
6892
- <xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
6893
- <xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
6937
+ <xsl:variable name="svg_width_" select="xalan:nodeset($svg_content)/*/@width"/>
6938
+ <xsl:variable name="svg_width" select="number(translate($svg_width_, 'px', ''))"/>
6939
+ <xsl:variable name="svg_height_" select="xalan:nodeset($svg_content)/*/@height"/>
6940
+ <xsl:variable name="svg_height" select="number(translate($svg_height_, 'px', ''))"/>
6941
+
6942
+ <!-- Example: -->
6894
6943
  <!-- effective height 297 - 27.4 - 13 = 256.6 -->
6895
6944
  <!-- effective width 210 - 12.5 - 25 = 172.5 -->
6896
6945
  <!-- effective height / width = 1.48, 1.4 - with title -->
6897
- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->
6946
+
6947
+ <xsl:variable name="scale_x">
6948
+ <xsl:choose>
6949
+ <xsl:when test="$svg_width &gt; $width_effective_px">
6950
+ <xsl:value-of select="$width_effective_px div $svg_width"/>
6951
+ </xsl:when>
6952
+ <xsl:otherwise>1</xsl:otherwise>
6953
+ </xsl:choose>
6954
+ </xsl:variable>
6955
+ <xsl:variable name="scale_y">
6956
+ <xsl:choose>
6957
+ <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
6958
+ <xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
6959
+ </xsl:when>
6960
+ <xsl:otherwise>1</xsl:otherwise>
6961
+ </xsl:choose>
6962
+ </xsl:variable>
6963
+
6964
+ <!-- for images with big height -->
6965
+ <!-- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)">
6898
6966
  <xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
6899
6967
  <xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
6900
- </xsl:if>
6968
+ </xsl:if> -->
6901
6969
  <xsl:attribute name="scaling">uniform</xsl:attribute>
6970
+
6971
+ <xsl:if test="$scale_y != 1">
6972
+ <xsl:attribute name="content-height"><xsl:value-of select="round($scale_x * $scale_y * 100)"/>%</xsl:attribute>
6973
+ </xsl:if>
6974
+
6902
6975
  <xsl:copy-of select="$svg_content"/>
6903
6976
  </fo:instream-foreign-object>
6904
6977
  <!-- </fo:block> -->
@@ -6936,8 +7009,12 @@
6936
7009
  <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/>
6937
7010
  <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/>
6938
7011
 
7012
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[1][local-name() = 'image']/@width)"/>
7013
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[1][local-name() = 'image']/@height)"/>
7014
+
6939
7015
  <xsl:attribute name="width">
6940
7016
  <xsl:choose>
7017
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
6941
7018
  <xsl:when test="$width != ''">
6942
7019
  <xsl:value-of select="round($width)"/>
6943
7020
  </xsl:when>
@@ -6946,6 +7023,7 @@
6946
7023
  </xsl:attribute>
6947
7024
  <xsl:attribute name="height">
6948
7025
  <xsl:choose>
7026
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
6949
7027
  <xsl:when test="$height != ''">
6950
7028
  <xsl:value-of select="round($height)"/>
6951
7029
  </xsl:when>
@@ -6957,6 +7035,28 @@
6957
7035
  </xsl:copy>
6958
7036
  </xsl:template>
6959
7037
 
7038
+ <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update">
7039
+ <!-- image[@width]/svg -->
7040
+ <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/>
7041
+ <xsl:attribute name="width">
7042
+ <xsl:choose>
7043
+ <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when>
7044
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7045
+ </xsl:choose>
7046
+ </xsl:attribute>
7047
+ </xsl:template>
7048
+
7049
+ <xsl:template match="*[local-name() = 'svg']/@height" mode="svg_update">
7050
+ <!-- image[@height]/svg -->
7051
+ <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/>
7052
+ <xsl:attribute name="height">
7053
+ <xsl:choose>
7054
+ <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when>
7055
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
7056
+ </xsl:choose>
7057
+ </xsl:attribute>
7058
+ </xsl:template>
7059
+
6960
7060
  <!-- regex for 'display: inline-block;' -->
6961
7061
  <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable>
6962
7062
  <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update">
@@ -9035,7 +9135,9 @@
9035
9135
  </xsl:template> <!-- sections_element_style -->
9036
9136
 
9037
9137
  <xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
9038
- <fo:block break-after="page"/>
9138
+
9139
+ <fo:block break-after="page"/>
9140
+
9039
9141
  <fo:block>
9040
9142
  <xsl:call-template name="setId"/>
9041
9143
  <xsl:apply-templates/>
@@ -9102,7 +9204,7 @@
9102
9204
  <xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
9103
9205
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9104
9206
  </xsl:when>
9105
- <xsl:when test="not(//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9207
+ <xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
9106
9208
  <fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
9107
9209
  </xsl:when>
9108
9210
  </xsl:choose>
@@ -10902,10 +11004,10 @@
10902
11004
 
10903
11005
  <xsl:template name="addPDFUAmeta">
10904
11006
  <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
10905
- <pdf:dictionary type="normal" key="ViewerPreferences">
10906
- <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
10907
- </pdf:dictionary>
10908
- </pdf:catalog>
11007
+ <pdf:dictionary type="normal" key="ViewerPreferences">
11008
+ <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
11009
+ </pdf:dictionary>
11010
+ </pdf:catalog>
10909
11011
  <x:xmpmeta xmlns:x="adobe:ns:meta/">
10910
11012
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
10911
11013
  <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about="">
@@ -10957,6 +11059,19 @@
10957
11059
  </rdf:Description>
10958
11060
  </rdf:RDF>
10959
11061
  </x:xmpmeta>
11062
+ <!-- add attachments -->
11063
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
11064
+ <xsl:choose>
11065
+ <xsl:when test="normalize-space() != ''">
11066
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{.}" filename="{@name}"/>
11067
+ </xsl:when>
11068
+ <xsl:otherwise>
11069
+ <!-- _{filename}_attachments -->
11070
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
11071
+ <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/>
11072
+ </xsl:otherwise>
11073
+ </xsl:choose>
11074
+ </xsl:for-each>
10960
11075
  </xsl:template> <!-- addPDFUAmeta -->
10961
11076
 
10962
11077
  <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 CC
3
- VERSION = "2.4.2".freeze
3
+ VERSION = "2.4.4".freeze
4
4
  end
5
5
  end
data/metanorma-cc.gemspec CHANGED
@@ -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.0"
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-cc
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.0
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.0
26
+ version: 2.6.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: debug
29
29
  requirement: !ruby/object:Gem::Requirement