metanorma-jis 0.2.2 → 0.2.3

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: 51d33b08d2336531fafeb2cd92258ecd7f4d2ecc22789d688840fff5e3b9f4b4
4
- data.tar.gz: 20d1c0ad57701d3cd632c1cc33964528a5e34aa646a0290af52f841081fa54a1
3
+ metadata.gz: a064f0e798e321317671b5e491d584734b5c6348cce7a3b4724a6bc1f71460bf
4
+ data.tar.gz: d7f98949f0e67fa152423525138a0c203e544c102160c25b4852ddeee8dfde31
5
5
  SHA512:
6
- metadata.gz: fc470c9a97b273a3c4989add0df8b28d87173bcca11ca7e1ac2abb46111bf89864db95b23f441970a35b7b6156929109e7b7c7ddd649017aae2ad1551bf1720a
7
- data.tar.gz: e3192bb844ec32eab702e75891b7165b04c802e7acc3c8bc2a277a3d47e2e911427c36716559db01cbd1c81c4ba0f6f93c2bf6611655b95468513b30943022fc
6
+ metadata.gz: 47436176727b7d79fcf56ef5dae063d8235f4e238cee743b88f0da622f0babbe9dfc5d7c1b477f919c23990b0e75f4bd27f98a07dd7903e4aa11122acdcf7be5
7
+ data.tar.gz: 30fd069624c832d3527736d35f56d8f0ff52225579121f299f91d54b106b8584c2483d98ecac608583cd74323798fbbf6f2a60d9cdf89ec470d4943758ab7743
@@ -54,6 +54,39 @@ module IsoDoc
54
54
  end
55
55
  end
56
56
  end
57
+
58
+ def table_parse(node, out)
59
+ cols = table_cols_count(node)
60
+ name = node.at(ns("./name"))
61
+ thead = table_thead_pt(node, name)
62
+ table_name(name, thead, cols)
63
+ super
64
+ end
65
+
66
+ def table_thead_pt(node, name)
67
+ node.at(ns("./thead")) ||
68
+ name&.after("<thead> </thead>")&.next ||
69
+ node.elements.first.before("<thead> </thead>").previous
70
+ end
71
+
72
+ def table_cols_count(node)
73
+ cols = 0
74
+ node.at(ns(".//tr")).xpath(ns("./td | ./th")).each do |x|
75
+ cols += x["colspan"]&.to_i || 1
76
+ end
77
+ cols
78
+ end
79
+
80
+ def full_row(cols, elem)
81
+ "<tr><td border='0' colspan='#{cols}'>#{elem}</td></tr>"
82
+ end
83
+
84
+ def table_name(name, thead, cols)
85
+ name or return
86
+ thead.children.first.previous =
87
+ full_row(cols, "<p class='TableTitle' style='text-align:center;'> " \
88
+ "#{name.remove.children.to_xml}</p>")
89
+ end
57
90
  end
58
91
  end
59
92
  end
@@ -1620,6 +1620,8 @@
1620
1620
  <xsl:param name="svg_images"/> <!-- svg images array -->
1621
1621
  <xsl:variable name="images" select="document($svg_images)"/>
1622
1622
  <xsl:param name="basepath"/> <!-- base path for images -->
1623
+ <xsl:param name="inputxml_basepath"/> <!-- input xml file path -->
1624
+ <xsl:param name="inputxml_filename"/> <!-- input xml file name -->
1623
1625
  <xsl:param name="external_index"/><!-- path to index xml, generated on 1st pass, based on FOP Intermediate Format -->
1624
1626
  <xsl:param name="syntax-highlight">false</xsl:param> <!-- syntax highlighting feature, default - off -->
1625
1627
  <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 -->
@@ -1672,6 +1674,20 @@
1672
1674
  <xsl:call-template name="getLang"/>
1673
1675
  </xsl:variable>
1674
1676
 
1677
+ <xsl:variable name="inputxml_filename_prefix">
1678
+ <xsl:choose>
1679
+ <xsl:when test="contains($inputxml_filename, '.presentation.xml')">
1680
+ <xsl:value-of select="substring-before($inputxml_filename, '.presentation.xml')"/>
1681
+ </xsl:when>
1682
+ <xsl:when test="contains($inputxml_filename, '.xml')">
1683
+ <xsl:value-of select="substring-before($inputxml_filename, '.xml')"/>
1684
+ </xsl:when>
1685
+ <xsl:otherwise>
1686
+ <xsl:value-of select="$inputxml_filename"/>
1687
+ </xsl:otherwise>
1688
+ </xsl:choose>
1689
+ </xsl:variable>
1690
+
1675
1691
  <!-- Note 1: Each xslt has declated variable `namespace` that allows to set some properties, processing logic, etc. for concrete xslt.
1676
1692
  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>,
1677
1693
  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 -->
@@ -2596,6 +2612,10 @@
2596
2612
 
2597
2613
  </xsl:attribute-set>
2598
2614
 
2615
+ <xsl:template name="refine_figure-block-style">
2616
+
2617
+ </xsl:template>
2618
+
2599
2619
  <xsl:attribute-set name="figure-style">
2600
2620
 
2601
2621
  </xsl:attribute-set>
@@ -3499,7 +3519,7 @@
3499
3519
  <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)/*/tr[1]/td)"/>
3500
3520
 
3501
3521
  <xsl:variable name="colwidths">
3502
- <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])">
3522
+ <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col']) and not(@class = 'dl')">
3503
3523
  <xsl:call-template name="calculate-column-widths">
3504
3524
  <xsl:with-param name="cols-count" select="$cols-count"/>
3505
3525
  <xsl:with-param name="table" select="$simple-table"/>
@@ -3611,6 +3631,11 @@
3611
3631
  <fo:table-column column-width="{@width}"/>
3612
3632
  </xsl:for-each>
3613
3633
  </xsl:when>
3634
+ <xsl:when test="@class = 'dl'">
3635
+ <xsl:for-each select=".//*[local-name()='tr'][1]/*">
3636
+ <fo:table-column column-width="{@width}"/>
3637
+ </xsl:for-each>
3638
+ </xsl:when>
3614
3639
  <xsl:otherwise>
3615
3640
  <xsl:call-template name="insertTableColumnWidth">
3616
3641
  <xsl:with-param name="colwidths" select="$colwidths"/>
@@ -4878,6 +4903,7 @@
4878
4903
  <!-- ===================== -->
4879
4904
  <!-- Definition List -->
4880
4905
  <!-- ===================== -->
4906
+
4881
4907
  <xsl:template match="*[local-name()='dl']">
4882
4908
  <xsl:variable name="isAdded" select="@added"/>
4883
4909
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -5090,10 +5116,21 @@
5090
5116
  </xsl:variable>
5091
5117
 
5092
5118
  <xsl:variable name="colwidths">
5093
- <xsl:call-template name="calculate-column-widths">
5094
- <xsl:with-param name="cols-count" select="2"/>
5095
- <xsl:with-param name="table" select="$simple-table"/>
5096
- </xsl:call-template>
5119
+ <xsl:choose>
5120
+ <!-- dl from table[@class='dl'] -->
5121
+ <xsl:when test="*[local-name() = 'colgroup']">
5122
+ <autolayout/>
5123
+ <xsl:for-each select="*[local-name() = 'colgroup']/*[local-name() = 'col']">
5124
+ <column><xsl:value-of select="translate(@width,'%m','')"/></column>
5125
+ </xsl:for-each>
5126
+ </xsl:when>
5127
+ <xsl:otherwise>
5128
+ <xsl:call-template name="calculate-column-widths">
5129
+ <xsl:with-param name="cols-count" select="2"/>
5130
+ <xsl:with-param name="table" select="$simple-table"/>
5131
+ </xsl:call-template>
5132
+ </xsl:otherwise>
5133
+ </xsl:choose>
5097
5134
  </xsl:variable>
5098
5135
 
5099
5136
  <!-- <xsl:text disable-output-escaping="yes">&lt;!- -</xsl:text>
@@ -7193,6 +7230,12 @@
7193
7230
  <xsl:when test="@updatetype = 'true'">
7194
7231
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
7195
7232
  </xsl:when>
7233
+ <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
7234
+ <!-- link to the PDF attachment -->
7235
+ <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
7236
+ <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
7237
+ <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
7238
+ </xsl:when>
7196
7239
  <xsl:otherwise>
7197
7240
  <xsl:value-of select="normalize-space(@target)"/>
7198
7241
  </xsl:otherwise>
@@ -7593,6 +7636,7 @@
7593
7636
  <xsl:variable name="isAdded" select="@added"/>
7594
7637
  <xsl:variable name="isDeleted" select="@deleted"/>
7595
7638
  <fo:block-container id="{@id}" xsl:use-attribute-sets="figure-block-style">
7639
+ <xsl:call-template name="refine_figure-block-style"/>
7596
7640
 
7597
7641
  <xsl:call-template name="setTrackChangesStyles">
7598
7642
  <xsl:with-param name="isAdded" select="$isAdded"/>
@@ -12067,10 +12111,10 @@
12067
12111
 
12068
12112
  <xsl:template name="addPDFUAmeta">
12069
12113
  <pdf:catalog>
12070
- <pdf:dictionary type="normal" key="ViewerPreferences">
12071
- <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
12072
- </pdf:dictionary>
12073
- </pdf:catalog>
12114
+ <pdf:dictionary type="normal" key="ViewerPreferences">
12115
+ <pdf:boolean key="DisplayDocTitle">true</pdf:boolean>
12116
+ </pdf:dictionary>
12117
+ </pdf:catalog>
12074
12118
  <x:xmpmeta xmlns:x="adobe:ns:meta/">
12075
12119
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
12076
12120
  <rdf:Description xmlns:pdf="http://ns.adobe.com/pdf/1.3/" xmlns:dc="http://purl.org/dc/elements/1.1/" rdf:about="">
@@ -12122,6 +12166,19 @@
12122
12166
  </rdf:Description>
12123
12167
  </rdf:RDF>
12124
12168
  </x:xmpmeta>
12169
+ <!-- add attachments -->
12170
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
12171
+ <xsl:choose>
12172
+ <xsl:when test="normalize-space() != ''">
12173
+ <pdf:embedded-file src="{.}" filename="{@name}"/>
12174
+ </xsl:when>
12175
+ <xsl:otherwise>
12176
+ <!-- _{filename}_attachments -->
12177
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
12178
+ <pdf:embedded-file src="{$url}" filename="{@name}"/>
12179
+ </xsl:otherwise>
12180
+ </xsl:choose>
12181
+ </xsl:for-each>
12125
12182
  </xsl:template> <!-- addPDFUAmeta -->
12126
12183
 
12127
12184
  <xsl:template name="getId">
@@ -102,7 +102,6 @@ module IsoDoc
102
102
  name = node.at(ns("./name"))
103
103
  thead = table_thead_pt(node, name)
104
104
  table_unit_note(node, thead, cols)
105
- table_name(name, thead, cols)
106
105
  end
107
106
 
108
107
  def table_thead_pt(node, name)
@@ -124,13 +123,6 @@ module IsoDoc
124
123
  thead.children.first.previous = full_row(cols, unit_note.remove.to_xml)
125
124
  end
126
125
 
127
- def table_name(name, thead, cols)
128
- name or return
129
- thead.children.first.previous =
130
- full_row(cols, "<p class='TableTitle' style='text-align:center;'> " \
131
- "#{name.remove.children.to_xml}</p>")
132
- end
133
-
134
126
  def full_row(cols, elem)
135
127
  "<tr><td border='0' colspan='#{cols}'>#{elem}</td></tr>"
136
128
  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,6 +1,6 @@
1
1
  module Metanorma
2
2
  module JIS
3
- VERSION = "0.2.2".freeze
3
+ VERSION = "0.2.3".freeze
4
4
  end
5
5
  end
6
6
 
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
32
32
 
33
33
  spec.add_dependency "japanese_calendar", "~> 0"
34
- spec.add_dependency "metanorma-iso", "~> 2.7.2"
34
+ spec.add_dependency "metanorma-iso", "~> 2.7.3"
35
35
  spec.add_dependency "pubid-jis"
36
36
 
37
37
  spec.add_development_dependency "debug"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-jis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-19 00:00:00.000000000 Z
11
+ date: 2024-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: japanese_calendar
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.7.2
33
+ version: 2.7.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.7.2
40
+ version: 2.7.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pubid-jis
43
43
  requirement: !ruby/object:Gem::Requirement