metanorma-ieee 0.0.7 → 0.1.0

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: ce71f154bdfaa827f1a337ada1d43e55c308bc06a188c458459bc61a5973016e
4
- data.tar.gz: d2d1ca8358e682e13d6dc590ddcd49a0f3948245ac31263dff040f9cda539e48
3
+ metadata.gz: 18c5077ed8c2107193a9183fd3b3832276f47fa92f60393df76cee4ac0762ab6
4
+ data.tar.gz: 2e048a76e6452e79e94b47ab97911cef4e8ead2fe72b8831f43d0d2727ef3ead
5
5
  SHA512:
6
- metadata.gz: 1c6f49824460407ffad065878704794d3669f5da4f6d7b2c385d46bdb63558f7c82332b937423fa8ba0adc12a2d37cdac08faba6649b0da780b6c8d02bd40a95
7
- data.tar.gz: a74afb17ed30afd997a4e4bc435222e3886671897b41035bb401e9d6762476094b7096a6688fe14da3e5144f8acce9d6a90ffcc5c69f87105e773b32990522fb
6
+ metadata.gz: 95929a3a72d3a3645ff048a014c607a03ec3357644c3e2118088ff0bdfa886cc080bd72afda136c50fec7c03a63862b158d1b8f81c885682c90d2a35bd73a4ff
7
+ data.tar.gz: 15ddaf907ebfcff60003841ea86aa9c5858010a59e054ace4914ce2d0ffae0591462b5233a91732521380b8ad7df04338636a58e5b768763429b60a7bed7b2b7
@@ -10587,7 +10587,7 @@
10587
10587
  <!-- ====== -->
10588
10588
  <!-- eref -->
10589
10589
  <!-- ====== -->
10590
- <xsl:template match="*[local-name() = 'eref']">
10590
+ <xsl:template match="*[local-name() = 'eref']" name="eref">
10591
10591
  <xsl:variable name="current_bibitemid" select="@bibitemid"/>
10592
10592
  <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
10593
10593
  <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
@@ -11098,21 +11098,29 @@
11098
11098
  </xsl:variable>
11099
11099
 
11100
11100
  <xsl:template match="@*|node()" mode="index_add_id">
11101
+ <xsl:param name="docid"/>
11101
11102
  <xsl:copy>
11102
- <xsl:apply-templates select="@*|node()" mode="index_add_id"/>
11103
+ <xsl:apply-templates select="@*|node()" mode="index_add_id">
11104
+ <xsl:with-param name="docid" select="$docid"/>
11105
+ </xsl:apply-templates>
11103
11106
  </xsl:copy>
11104
11107
  </xsl:template>
11105
11108
 
11106
11109
  <xsl:template match="*[local-name() = 'xref']" mode="index_add_id">
11110
+ <xsl:param name="docid"/>
11107
11111
  <xsl:variable name="id">
11108
- <xsl:call-template name="generateIndexXrefId"/>
11112
+ <xsl:call-template name="generateIndexXrefId">
11113
+ <xsl:with-param name="docid" select="$docid"/>
11114
+ </xsl:call-template>
11109
11115
  </xsl:variable>
11110
11116
  <xsl:copy> <!-- add id to xref -->
11111
11117
  <xsl:apply-templates select="@*" mode="index_add_id"/>
11112
11118
  <xsl:attribute name="id">
11113
11119
  <xsl:value-of select="$id"/>
11114
11120
  </xsl:attribute>
11115
- <xsl:apply-templates mode="index_add_id"/>
11121
+ <xsl:apply-templates mode="index_add_id">
11122
+ <xsl:with-param name="docid" select="$docid"/>
11123
+ </xsl:apply-templates>
11116
11124
  </xsl:copy>
11117
11125
  <!-- split <xref target="bm1" to="End" pagenumber="true"> to two xref:
11118
11126
  <xref target="bm1" pagenumber="true"> and <xref target="End" pagenumber="true"> -->
@@ -11124,7 +11132,9 @@
11124
11132
  <xsl:attribute name="id">
11125
11133
  <xsl:value-of select="$id"/><xsl:text>_to</xsl:text>
11126
11134
  </xsl:attribute>
11127
- <xsl:apply-templates mode="index_add_id"/>
11135
+ <xsl:apply-templates mode="index_add_id">
11136
+ <xsl:with-param name="docid" select="$docid"/>
11137
+ </xsl:apply-templates>
11128
11138
  </xsl:copy>
11129
11139
  </xsl:if>
11130
11140
  </xsl:template>
@@ -11161,12 +11171,33 @@
11161
11171
  </xsl:when>
11162
11172
  <xsl:when test="self::* and local-name(.) = 'xref'">
11163
11173
  <xsl:variable name="id" select="@id"/>
11164
- <xsl:variable name="page" select="$index//item[@id = $id]"/>
11165
- <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
11166
- <xsl:variable name="page_next" select="$index//item[@id = $id_next]"/>
11167
11174
 
11175
+ <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
11168
11176
  <xsl:variable name="id_prev" select="preceding-sibling::*[local-name() = 'xref'][1]/@id"/>
11169
- <xsl:variable name="page_prev" select="$index//item[@id = $id_prev]"/>
11177
+
11178
+ <xsl:variable name="pages_">
11179
+ <xsl:for-each select="$index/index/item[@id = $id or @id = $id_next or @id = $id_prev]">
11180
+ <xsl:choose>
11181
+ <xsl:when test="@id = $id">
11182
+ <page><xsl:value-of select="."/></page>
11183
+ </xsl:when>
11184
+ <xsl:when test="@id = $id_next">
11185
+ <page_next><xsl:value-of select="."/></page_next>
11186
+ </xsl:when>
11187
+ <xsl:when test="@id = $id_prev">
11188
+ <page_prev><xsl:value-of select="."/></page_prev>
11189
+ </xsl:when>
11190
+ </xsl:choose>
11191
+ </xsl:for-each>
11192
+ </xsl:variable>
11193
+ <xsl:variable name="pages" select="xalan:nodeset($pages_)"/>
11194
+
11195
+ <!-- <xsl:variable name="page" select="$index/index/item[@id = $id]"/> -->
11196
+ <xsl:variable name="page" select="$pages/page"/>
11197
+ <!-- <xsl:variable name="page_next" select="$index/index/item[@id = $id_next]"/> -->
11198
+ <xsl:variable name="page_next" select="$pages/page_next"/>
11199
+ <!-- <xsl:variable name="page_prev" select="$index/index/item[@id = $id_prev]"/> -->
11200
+ <xsl:variable name="page_prev" select="$pages/page_prev"/>
11170
11201
 
11171
11202
  <xsl:choose>
11172
11203
  <!-- 2nd pass -->
@@ -11226,16 +11257,20 @@
11226
11257
  </xsl:template>
11227
11258
 
11228
11259
  <xsl:template name="generateIndexXrefId">
11260
+ <xsl:param name="docid"/>
11261
+
11229
11262
  <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/>
11230
11263
 
11231
- <xsl:variable name="docid">
11232
- <xsl:call-template name="getDocumentId"/>
11264
+ <xsl:variable name="docid_curr">
11265
+ <xsl:value-of select="$docid"/>
11266
+ <xsl:if test="normalize-space($docid) = ''"><xsl:call-template name="getDocumentId"/></xsl:if>
11233
11267
  </xsl:variable>
11268
+
11234
11269
  <xsl:variable name="item_number">
11235
11270
  <xsl:number count="*[local-name() = 'li'][ancestor::*[local-name() = 'indexsect']]" level="any"/>
11236
11271
  </xsl:variable>
11237
11272
  <xsl:variable name="xref_number"><xsl:number count="*[local-name() = 'xref']"/></xsl:variable>
11238
- <xsl:value-of select="concat($docid, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
11273
+ <xsl:value-of select="concat($docid_curr, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
11239
11274
  </xsl:template>
11240
11275
 
11241
11276
  <xsl:template match="*[local-name() = 'indexsect']/*[local-name() = 'title']" priority="4">
@@ -10587,7 +10587,7 @@
10587
10587
  <!-- ====== -->
10588
10588
  <!-- eref -->
10589
10589
  <!-- ====== -->
10590
- <xsl:template match="*[local-name() = 'eref']">
10590
+ <xsl:template match="*[local-name() = 'eref']" name="eref">
10591
10591
  <xsl:variable name="current_bibitemid" select="@bibitemid"/>
10592
10592
  <!-- <xsl:variable name="external-destination" select="normalize-space(key('bibitems', $current_bibitemid)/*[local-name() = 'uri'][@type = 'citation'])"/> -->
10593
10593
  <xsl:variable name="external-destination" select="normalize-space($bibitems/*[local-name() ='bibitem'][@id = $current_bibitemid]/*[local-name() = 'uri'][@type = 'citation'])"/>
@@ -11098,21 +11098,29 @@
11098
11098
  </xsl:variable>
11099
11099
 
11100
11100
  <xsl:template match="@*|node()" mode="index_add_id">
11101
+ <xsl:param name="docid"/>
11101
11102
  <xsl:copy>
11102
- <xsl:apply-templates select="@*|node()" mode="index_add_id"/>
11103
+ <xsl:apply-templates select="@*|node()" mode="index_add_id">
11104
+ <xsl:with-param name="docid" select="$docid"/>
11105
+ </xsl:apply-templates>
11103
11106
  </xsl:copy>
11104
11107
  </xsl:template>
11105
11108
 
11106
11109
  <xsl:template match="*[local-name() = 'xref']" mode="index_add_id">
11110
+ <xsl:param name="docid"/>
11107
11111
  <xsl:variable name="id">
11108
- <xsl:call-template name="generateIndexXrefId"/>
11112
+ <xsl:call-template name="generateIndexXrefId">
11113
+ <xsl:with-param name="docid" select="$docid"/>
11114
+ </xsl:call-template>
11109
11115
  </xsl:variable>
11110
11116
  <xsl:copy> <!-- add id to xref -->
11111
11117
  <xsl:apply-templates select="@*" mode="index_add_id"/>
11112
11118
  <xsl:attribute name="id">
11113
11119
  <xsl:value-of select="$id"/>
11114
11120
  </xsl:attribute>
11115
- <xsl:apply-templates mode="index_add_id"/>
11121
+ <xsl:apply-templates mode="index_add_id">
11122
+ <xsl:with-param name="docid" select="$docid"/>
11123
+ </xsl:apply-templates>
11116
11124
  </xsl:copy>
11117
11125
  <!-- split <xref target="bm1" to="End" pagenumber="true"> to two xref:
11118
11126
  <xref target="bm1" pagenumber="true"> and <xref target="End" pagenumber="true"> -->
@@ -11124,7 +11132,9 @@
11124
11132
  <xsl:attribute name="id">
11125
11133
  <xsl:value-of select="$id"/><xsl:text>_to</xsl:text>
11126
11134
  </xsl:attribute>
11127
- <xsl:apply-templates mode="index_add_id"/>
11135
+ <xsl:apply-templates mode="index_add_id">
11136
+ <xsl:with-param name="docid" select="$docid"/>
11137
+ </xsl:apply-templates>
11128
11138
  </xsl:copy>
11129
11139
  </xsl:if>
11130
11140
  </xsl:template>
@@ -11161,12 +11171,33 @@
11161
11171
  </xsl:when>
11162
11172
  <xsl:when test="self::* and local-name(.) = 'xref'">
11163
11173
  <xsl:variable name="id" select="@id"/>
11164
- <xsl:variable name="page" select="$index//item[@id = $id]"/>
11165
- <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
11166
- <xsl:variable name="page_next" select="$index//item[@id = $id_next]"/>
11167
11174
 
11175
+ <xsl:variable name="id_next" select="following-sibling::*[local-name() = 'xref'][1]/@id"/>
11168
11176
  <xsl:variable name="id_prev" select="preceding-sibling::*[local-name() = 'xref'][1]/@id"/>
11169
- <xsl:variable name="page_prev" select="$index//item[@id = $id_prev]"/>
11177
+
11178
+ <xsl:variable name="pages_">
11179
+ <xsl:for-each select="$index/index/item[@id = $id or @id = $id_next or @id = $id_prev]">
11180
+ <xsl:choose>
11181
+ <xsl:when test="@id = $id">
11182
+ <page><xsl:value-of select="."/></page>
11183
+ </xsl:when>
11184
+ <xsl:when test="@id = $id_next">
11185
+ <page_next><xsl:value-of select="."/></page_next>
11186
+ </xsl:when>
11187
+ <xsl:when test="@id = $id_prev">
11188
+ <page_prev><xsl:value-of select="."/></page_prev>
11189
+ </xsl:when>
11190
+ </xsl:choose>
11191
+ </xsl:for-each>
11192
+ </xsl:variable>
11193
+ <xsl:variable name="pages" select="xalan:nodeset($pages_)"/>
11194
+
11195
+ <!-- <xsl:variable name="page" select="$index/index/item[@id = $id]"/> -->
11196
+ <xsl:variable name="page" select="$pages/page"/>
11197
+ <!-- <xsl:variable name="page_next" select="$index/index/item[@id = $id_next]"/> -->
11198
+ <xsl:variable name="page_next" select="$pages/page_next"/>
11199
+ <!-- <xsl:variable name="page_prev" select="$index/index/item[@id = $id_prev]"/> -->
11200
+ <xsl:variable name="page_prev" select="$pages/page_prev"/>
11170
11201
 
11171
11202
  <xsl:choose>
11172
11203
  <!-- 2nd pass -->
@@ -11226,16 +11257,20 @@
11226
11257
  </xsl:template>
11227
11258
 
11228
11259
  <xsl:template name="generateIndexXrefId">
11260
+ <xsl:param name="docid"/>
11261
+
11229
11262
  <xsl:variable name="level" select="count(ancestor::*[local-name() = 'ul'])"/>
11230
11263
 
11231
- <xsl:variable name="docid">
11232
- <xsl:call-template name="getDocumentId"/>
11264
+ <xsl:variable name="docid_curr">
11265
+ <xsl:value-of select="$docid"/>
11266
+ <xsl:if test="normalize-space($docid) = ''"><xsl:call-template name="getDocumentId"/></xsl:if>
11233
11267
  </xsl:variable>
11268
+
11234
11269
  <xsl:variable name="item_number">
11235
11270
  <xsl:number count="*[local-name() = 'li'][ancestor::*[local-name() = 'indexsect']]" level="any"/>
11236
11271
  </xsl:variable>
11237
11272
  <xsl:variable name="xref_number"><xsl:number count="*[local-name() = 'xref']"/></xsl:variable>
11238
- <xsl:value-of select="concat($docid, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
11273
+ <xsl:value-of select="concat($docid_curr, '_', $item_number, '_', $xref_number)"/> <!-- $level, '_', -->
11239
11274
  </xsl:template>
11240
11275
 
11241
11276
  <xsl:template match="*[local-name() = 'indexsect']/*[local-name() = 'title']" priority="4">
@@ -0,0 +1,36 @@
1
+ require "isodoc"
2
+ require "mnconvert"
3
+
4
+ module IsoDoc
5
+ module IEEE
6
+ class IEEEXMLConvert < IsoDoc::XslfoPdfConvert
7
+ def initialize(options) # rubocop:disable Lint/MissingSuper
8
+ @libdir = File.dirname(__FILE__)
9
+ @format = :ieee
10
+ @suffix = "ieee.xml"
11
+ @ieeedtd = options[:ieeedtd]
12
+ end
13
+
14
+ def inputfile(in_fname, filename)
15
+ /\.xml$/.match?(in_fname) or
16
+ in_fname = Tempfile.open([filename, ".xml"], encoding: "utf-8") do |f|
17
+ f.write file
18
+ f.path
19
+ end
20
+ in_fname
21
+ end
22
+
23
+ def convert(in_fname, file = nil, debug = false, out_fname = nil)
24
+ file = File.read(in_fname, encoding: "utf-8") if file.nil?
25
+ _docxml, filename, dir = convert_init(file, in_fname, debug)
26
+ in_fname = inputfile(in_fname, filename)
27
+ FileUtils.rm_rf dir
28
+ opt = { input_format: MnConvert::InputFormat::MN,
29
+ output_file: out_fname || "#{filename}.#{@suffix}",
30
+ output_format: :ieee }
31
+ @ieeedtd and opt.merge!(validation_against: @ieeedtd)
32
+ MnConvert.convert(in_fname, opt)
33
+ end
34
+ end
35
+ end
36
+ end
data/lib/isodoc/ieee.rb CHANGED
@@ -4,6 +4,7 @@ require "isodoc/ieee/html_convert"
4
4
  require "isodoc/ieee/pdf_convert"
5
5
  require "isodoc/ieee/word_convert"
6
6
  require "isodoc/ieee/presentation_xml_convert"
7
+ require "isodoc/ieee/ieee_xml_convert"
7
8
 
8
9
  module IsoDoc
9
10
  module IEEE
@@ -60,7 +60,8 @@ module Metanorma
60
60
 
61
61
  def html_extract_attributes(node)
62
62
  super.merge(hierarchical_assets:
63
- node.attr("hierarchical-object-numbering"))
63
+ node.attr("hierarchical-object-numbering"),
64
+ ieeedtd: node.attr("ieee-dtd"))
64
65
  end
65
66
 
66
67
  def doc_extract_attributes(node)
@@ -78,12 +79,20 @@ module Metanorma
78
79
  end
79
80
 
80
81
  def pdf_converter(node)
82
+ return nil if node.attr("no-pdf")
83
+
81
84
  IsoDoc::IEEE::PdfConvert.new(pdf_extract_attributes(node))
82
85
  end
83
86
 
84
87
  def doc_converter(node)
85
88
  IsoDoc::IEEE::WordConvert.new(doc_extract_attributes(node))
86
89
  end
90
+
91
+ def ieee_xml_converter(node)
92
+ return nil if node.attr("no-pdf")
93
+
94
+ IsoDoc::Iso::IEEEXMLConvert.new(html_extract_attributes(node))
95
+ end
87
96
  end
88
97
  end
89
98
  end
@@ -205,6 +205,15 @@
205
205
  <data type="boolean"/>
206
206
  </attribute>
207
207
  </optional>
208
+ <optional>
209
+ <attribute name="style">
210
+ <choice>
211
+ <value>basic</value>
212
+ <value>full</value>
213
+ <value>short</value>
214
+ </choice>
215
+ </attribute>
216
+ </optional>
208
217
  <ref name="XrefBody"/>
209
218
  </element>
210
219
  </define>
@@ -14,6 +14,7 @@ module Metanorma
14
14
  html: "html",
15
15
  doc: "doc",
16
16
  pdf: "pdf",
17
+ ieee: "ieee.xml",
17
18
  )
18
19
  end
19
20
 
@@ -47,6 +48,9 @@ module Metanorma
47
48
  IsoDoc::IEEE::PresentationXMLConvert.new(options).convert(
48
49
  inname, isodoc_node, nil, outname
49
50
  )
51
+ when :ieee
52
+ IsoDoc::IEEE::IEEEXMLConvert.new(options)
53
+ .convert(inname, isodoc_node, nil, outname)
50
54
  else
51
55
  super
52
56
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module IEEE
3
- VERSION = "0.0.7".freeze
3
+ VERSION = "0.1.0".freeze
4
4
  end
5
5
  end
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
26
26
 
27
27
  spec.add_dependency "metanorma-standoc", "~> 2.2.4"
28
+ spec.add_dependency "mnconvert", "~> 1.20"
28
29
 
29
30
  spec.add_development_dependency "debug"
30
31
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ieee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-26 00:00:00.000000000 Z
11
+ date: 2022-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.2.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: mnconvert
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.20'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.20'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: debug
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -238,6 +252,7 @@ files:
238
252
  - lib/isodoc/ieee/ieee.amendment.xsl
239
253
  - lib/isodoc/ieee/ieee.rb
240
254
  - lib/isodoc/ieee/ieee.standard.xsl
255
+ - lib/isodoc/ieee/ieee_xml_convert.rb
241
256
  - lib/isodoc/ieee/init.rb
242
257
  - lib/isodoc/ieee/metadata.rb
243
258
  - lib/isodoc/ieee/pdf_convert.rb