metanorma-ogc 2.3.8 → 2.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1407,6 +1407,7 @@
1407
1407
  </xsl:attribute-set>
1408
1408
 
1409
1409
  <xsl:attribute-set name="xref-style">
1410
+ <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
1410
1411
 
1411
1412
  <xsl:attribute name="color">blue</xsl:attribute>
1412
1413
  <xsl:attribute name="text-decoration">underline</xsl:attribute>
@@ -3452,9 +3453,13 @@
3452
3453
  <xsl:attribute name="padding-right">0.5mm</xsl:attribute>
3453
3454
  </xsl:if>
3454
3455
 
3455
- <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
3456
- <xsl:value-of select="$current_fn_number_text"/>
3457
- </fo:basic-link>
3456
+ <xsl:call-template name="insert_basic_link">
3457
+ <xsl:with-param name="element">
3458
+ <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}">
3459
+ <xsl:value-of select="$current_fn_number_text"/>
3460
+ </fo:basic-link>
3461
+ </xsl:with-param>
3462
+ </xsl:call-template>
3458
3463
  </fo:inline>
3459
3464
  </xsl:variable>
3460
3465
 
@@ -3798,8 +3803,10 @@
3798
3803
  <xsl:apply-templates select="preceding-sibling::*[1][local-name() = 'p' and @keep-with-next = 'true']/node()"/>
3799
3804
  <xsl:text> </xsl:text>
3800
3805
  <xsl:apply-templates select="*[local-name()='dt']/*"/>
3801
- <xsl:text/>
3802
- <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
3806
+ <xsl:if test="*[local-name()='dd']/node()[normalize-space() != ''][1][self::text()]">
3807
+ <xsl:text> </xsl:text>
3808
+ </xsl:if>
3809
+ <xsl:apply-templates select="*[local-name()='dd']/node()" mode="inline"/>
3803
3810
  </fo:block>
3804
3811
 
3805
3812
  </xsl:when> <!-- END: only one component -->
@@ -4286,8 +4293,18 @@
4286
4293
  </xsl:if>
4287
4294
  </xsl:template>
4288
4295
 
4289
- <xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
4290
- <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
4296
+ <xsl:template match="*[local-name()='dd']/*" mode="inline">
4297
+ <xsl:variable name="is_inline_element_after_where">
4298
+ <xsl:if test="(local-name() = 'p') and not(preceding-sibling::node()[normalize-space() != ''])">true</xsl:if>
4299
+ </xsl:variable>
4300
+ <xsl:choose>
4301
+ <xsl:when test="$is_inline_element_after_where = 'true'">
4302
+ <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
4303
+ </xsl:when>
4304
+ <xsl:otherwise>
4305
+ <xsl:apply-templates select="."/>
4306
+ </xsl:otherwise>
4307
+ </xsl:choose>
4291
4308
  </xsl:template>
4292
4309
 
4293
4310
  <!-- virtual html table for dl/[dt and dd] for IF (Intermediate Format) -->
@@ -5720,6 +5737,79 @@
5720
5737
  <xsl:value-of select="."/><xsl:value-of select="$zero_width_space"/>
5721
5738
  </xsl:template>
5722
5739
 
5740
+ <!-- special case for:
5741
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
5742
+ <mstyle displaystyle="true">
5743
+ <msup>
5744
+ <mi color="#00000000">C</mi>
5745
+ <mtext>R</mtext>
5746
+ </msup>
5747
+ <msubsup>
5748
+ <mtext>C</mtext>
5749
+ <mi>n</mi>
5750
+ <mi>k</mi>
5751
+ </msubsup>
5752
+ </mstyle>
5753
+ </math>
5754
+ -->
5755
+ <xsl:template match="mathml:msup/mathml:mi[. = '‌' or . = ''][not(preceding-sibling::*)][following-sibling::mathml:mtext]" mode="mathml">
5756
+ <xsl:copy>
5757
+ <xsl:copy-of select="@*"/>
5758
+ <xsl:variable name="next_mtext" select="ancestor::mathml:msup/following-sibling::*[1][self::mathml:msubsup or self::mathml:msub or self::mathml:msup]/mathml:mtext"/>
5759
+ <xsl:if test="string-length($next_mtext) != ''">
5760
+ <xsl:attribute name="color">#00000000</xsl:attribute>
5761
+ </xsl:if>
5762
+ <xsl:apply-templates/>
5763
+ <xsl:value-of select="$next_mtext"/>
5764
+ </xsl:copy>
5765
+ </xsl:template>
5766
+
5767
+ <!-- special case for:
5768
+ <msup>
5769
+ <mtext/>
5770
+ <mn>1</mn>
5771
+ </msup>
5772
+ convert to (add mspace after mtext and enclose them into mrow):
5773
+ <msup>
5774
+ <mrow>
5775
+ <mtext/>
5776
+ <mspace height="1.47ex"/>
5777
+ </mrow>
5778
+ <mn>1</mn>
5779
+ </msup>
5780
+ -->
5781
+ <xsl:template match="mathml:msup/mathml:mtext[not(preceding-sibling::*)]" mode="mathml">
5782
+ <mathml:mrow>
5783
+ <xsl:copy-of select="."/>
5784
+ <mathml:mspace height="1.47ex"/>
5785
+ </mathml:mrow>
5786
+ </xsl:template>
5787
+
5788
+ <!-- add space around vertical line -->
5789
+ <xsl:template match="mathml:mo[normalize-space(text()) = '|']" mode="mathml">
5790
+ <xsl:copy>
5791
+ <xsl:apply-templates select="@*" mode="mathml"/>
5792
+ <xsl:if test="not(@lspace)">
5793
+ <xsl:attribute name="lspace">0.4em</xsl:attribute>
5794
+ </xsl:if>
5795
+ <xsl:if test="not(@rspace)">
5796
+ <xsl:attribute name="rspace">0.4em</xsl:attribute>
5797
+ </xsl:if>
5798
+ <xsl:apply-templates mode="mathml"/>
5799
+ </xsl:copy>
5800
+ </xsl:template>
5801
+
5802
+ <!-- decrease fontsize for 'Circled Times' char -->
5803
+ <xsl:template match="mathml:mo[normalize-space(text()) = '⊗']" mode="mathml">
5804
+ <xsl:copy>
5805
+ <xsl:apply-templates select="@*" mode="mathml"/>
5806
+ <xsl:if test="not(@fontsize)">
5807
+ <xsl:attribute name="fontsize">55%</xsl:attribute>
5808
+ </xsl:if>
5809
+ <xsl:apply-templates mode="mathml"/>
5810
+ </xsl:copy>
5811
+ </xsl:template>
5812
+
5723
5813
  <!-- Examples:
5724
5814
  <stem type="AsciiMath">x = 1</stem>
5725
5815
  <stem type="AsciiMath"><asciimath>x = 1</asciimath></stem>
@@ -5777,19 +5867,23 @@
5777
5867
  <xsl:apply-templates/>
5778
5868
  </xsl:when>
5779
5869
  <xsl:otherwise>
5780
- <fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
5781
- <xsl:choose>
5782
- <xsl:when test="normalize-space(.) = ''">
5783
- <xsl:call-template name="add-zero-spaces-link-java">
5784
- <xsl:with-param name="text" select="$target_text"/>
5785
- </xsl:call-template>
5786
- </xsl:when>
5787
- <xsl:otherwise>
5788
- <!-- output text from <link>text</link> -->
5789
- <xsl:apply-templates/>
5790
- </xsl:otherwise>
5791
- </xsl:choose>
5792
- </fo:basic-link>
5870
+ <xsl:call-template name="insert_basic_link">
5871
+ <xsl:with-param name="element">
5872
+ <fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
5873
+ <xsl:choose>
5874
+ <xsl:when test="normalize-space(.) = ''">
5875
+ <xsl:call-template name="add-zero-spaces-link-java">
5876
+ <xsl:with-param name="text" select="$target_text"/>
5877
+ </xsl:call-template>
5878
+ </xsl:when>
5879
+ <xsl:otherwise>
5880
+ <!-- output text from <link>text</link> -->
5881
+ <xsl:apply-templates/>
5882
+ </xsl:otherwise>
5883
+ </xsl:choose>
5884
+ </fo:basic-link>
5885
+ </xsl:with-param>
5886
+ </xsl:call-template>
5793
5887
  </xsl:otherwise>
5794
5888
  </xsl:choose>
5795
5889
  </fo:inline>
@@ -5852,12 +5946,16 @@
5852
5946
  </xsl:template>
5853
5947
 
5854
5948
  <xsl:template match="*[local-name() = 'xref']">
5855
- <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
5856
- <xsl:if test="parent::*[local-name() = 'add']">
5857
- <xsl:call-template name="append_add-style"/>
5858
- </xsl:if>
5859
- <xsl:apply-templates/>
5860
- </fo:basic-link>
5949
+ <xsl:call-template name="insert_basic_link">
5950
+ <xsl:with-param name="element">
5951
+ <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
5952
+ <xsl:if test="parent::*[local-name() = 'add']">
5953
+ <xsl:call-template name="append_add-style"/>
5954
+ </xsl:if>
5955
+ <xsl:apply-templates/>
5956
+ </fo:basic-link>
5957
+ </xsl:with-param>
5958
+ </xsl:call-template>
5861
5959
  </xsl:template>
5862
5960
 
5863
5961
  <!-- ====== -->
@@ -6244,7 +6342,7 @@
6244
6342
  <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/>
6245
6343
  </xsl:when>
6246
6344
  <xsl:when test="not(starts-with(@src, 'data:'))">
6247
- <xsl:value-of select="concat('url(file:',$basepath, @src, ')')"/>
6345
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
6248
6346
  </xsl:when>
6249
6347
  <xsl:otherwise>
6250
6348
  <xsl:value-of select="@src"/>
@@ -6266,7 +6364,7 @@
6266
6364
  </xsl:when>
6267
6365
  <xsl:when test="not(starts-with(@src, 'data:'))">
6268
6366
  <xsl:variable name="src">
6269
- <xsl:value-of select="concat('url(file:',$basepath, @src, ')')"/>
6367
+ <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
6270
6368
  </xsl:variable>
6271
6369
  <xsl:variable name="file" select="java:java.io.File.new(@src)"/>
6272
6370
  <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/>
@@ -6652,15 +6750,19 @@
6652
6750
  <xsl:param name="dest"/>
6653
6751
  <fo:block-container position="absolute" left="{$left}px" top="{$top}px" width="{$width}px" height="{$height}px">
6654
6752
  <fo:block font-size="1pt">
6655
- <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
6656
- <fo:inline-container inline-progression-dimension="100%">
6657
- <fo:block-container height="{$height - 1}px" width="100%">
6658
- <!-- DEBUG <xsl:if test="local-name()='polygon'">
6659
- <xsl:attribute name="background-color">magenta</xsl:attribute>
6660
- </xsl:if> -->
6661
- <fo:block> </fo:block></fo:block-container>
6662
- </fo:inline-container>
6663
- </fo:basic-link>
6753
+ <xsl:call-template name="insert_basic_link">
6754
+ <xsl:with-param name="element">
6755
+ <fo:basic-link internal-destination="{$dest}" fox:alt-text="svg link">
6756
+ <fo:inline-container inline-progression-dimension="100%">
6757
+ <fo:block-container height="{$height - 1}px" width="100%">
6758
+ <!-- DEBUG <xsl:if test="local-name()='polygon'">
6759
+ <xsl:attribute name="background-color">magenta</xsl:attribute>
6760
+ </xsl:if> -->
6761
+ <fo:block> </fo:block></fo:block-container>
6762
+ </fo:inline-container>
6763
+ </fo:basic-link>
6764
+ </xsl:with-param>
6765
+ </xsl:call-template>
6664
6766
  </fo:block>
6665
6767
  </fo:block-container>
6666
6768
  </xsl:template>
@@ -8226,14 +8328,18 @@
8226
8328
  </xsl:template>
8227
8329
 
8228
8330
  <xsl:template match="*[local-name() = 'origin']">
8229
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
8230
- <xsl:if test="normalize-space(@citeas) = ''">
8231
- <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
8232
- </xsl:if>
8233
- <fo:inline xsl:use-attribute-sets="origin-style">
8234
- <xsl:apply-templates/>
8235
- </fo:inline>
8236
- </fo:basic-link>
8331
+ <xsl:call-template name="insert_basic_link">
8332
+ <xsl:with-param name="element">
8333
+ <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
8334
+ <xsl:if test="normalize-space(@citeas) = ''">
8335
+ <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute>
8336
+ </xsl:if>
8337
+ <fo:inline xsl:use-attribute-sets="origin-style">
8338
+ <xsl:apply-templates/>
8339
+ </fo:inline>
8340
+ </fo:basic-link>
8341
+ </xsl:with-param>
8342
+ </xsl:call-template>
8237
8343
  </xsl:template>
8238
8344
 
8239
8345
  <!-- not using, see https://github.com/glossarist/iev-document/issues/23 -->
@@ -8307,9 +8413,13 @@
8307
8413
  <xsl:if test="../*[local-name() = 'author']">
8308
8414
  <xsl:text>, </xsl:text>
8309
8415
  </xsl:if>
8310
- <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
8311
- <xsl:apply-templates/>
8312
- </fo:basic-link>
8416
+ <xsl:call-template name="insert_basic_link">
8417
+ <xsl:with-param name="element">
8418
+ <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
8419
+ <xsl:apply-templates/>
8420
+ </fo:basic-link>
8421
+ </xsl:with-param>
8422
+ </xsl:call-template>
8313
8423
  </xsl:template>
8314
8424
 
8315
8425
  <xsl:template match="*[local-name() = 'author']">
@@ -8358,28 +8468,32 @@
8358
8468
  <xsl:variable name="citeas" select="java:replaceAll(java:java.lang.String.new(@citeas),'^\[?(.+?)\]?$','$1')"/> <!-- remove leading and trailing brackets -->
8359
8469
  <xsl:variable name="text" select="normalize-space()"/>
8360
8470
 
8361
- <fo:basic-link fox:alt-text="{@citeas}">
8362
- <xsl:if test="normalize-space(@citeas) = ''">
8363
- <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
8364
- </xsl:if>
8365
- <xsl:if test="@type = 'inline'">
8471
+ <xsl:call-template name="insert_basic_link">
8472
+ <xsl:with-param name="element">
8473
+ <fo:basic-link fox:alt-text="{@citeas}">
8474
+ <xsl:if test="normalize-space(@citeas) = ''">
8475
+ <xsl:attribute name="fox:alt-text"><xsl:value-of select="."/></xsl:attribute>
8476
+ </xsl:if>
8477
+ <xsl:if test="@type = 'inline'">
8366
8478
 
8367
- <xsl:attribute name="color">blue</xsl:attribute>
8368
- <xsl:attribute name="text-decoration">underline</xsl:attribute>
8479
+ <xsl:attribute name="color">blue</xsl:attribute>
8480
+ <xsl:attribute name="text-decoration">underline</xsl:attribute>
8369
8481
 
8370
- </xsl:if>
8482
+ </xsl:if>
8371
8483
 
8372
- <xsl:choose>
8373
- <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
8374
- <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
8375
- </xsl:when>
8376
- <xsl:otherwise>
8377
- <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
8378
- </xsl:otherwise>
8379
- </xsl:choose>
8484
+ <xsl:choose>
8485
+ <xsl:when test="$external-destination != ''"> <!-- external hyperlink -->
8486
+ <xsl:attribute name="external-destination"><xsl:value-of select="$external-destination"/></xsl:attribute>
8487
+ </xsl:when>
8488
+ <xsl:otherwise>
8489
+ <xsl:attribute name="internal-destination"><xsl:value-of select="@bibitemid"/></xsl:attribute>
8490
+ </xsl:otherwise>
8491
+ </xsl:choose>
8380
8492
 
8381
- <xsl:apply-templates/>
8382
- </fo:basic-link>
8493
+ <xsl:apply-templates/>
8494
+ </fo:basic-link>
8495
+ </xsl:with-param>
8496
+ </xsl:call-template>
8383
8497
 
8384
8498
  </fo:inline>
8385
8499
  </xsl:when>
@@ -8629,7 +8743,10 @@
8629
8743
  <xsl:variable name="ul_labels" select="xalan:nodeset($ul_labels_)"/>
8630
8744
 
8631
8745
  <xsl:template name="setULLabel">
8632
- <xsl:variable name="list_level_" select="count(ancestor::*[local-name() = 'ul']) + count(ancestor::*[local-name() = 'ol'])"/>
8746
+ <xsl:variable name="list_level__">
8747
+ <xsl:value-of select="count(ancestor::*[local-name() = 'ul']) + count(ancestor::*[local-name() = 'ol'])"/>
8748
+ </xsl:variable>
8749
+ <xsl:variable name="list_level_" select="number($list_level__)"/>
8633
8750
  <xsl:variable name="list_level">
8634
8751
  <xsl:choose>
8635
8752
  <xsl:when test="$list_level_ &lt;= 3"><xsl:value-of select="$list_level_"/></xsl:when>
@@ -8762,9 +8879,11 @@
8762
8879
  </fo:block-container>
8763
8880
  </xsl:when>
8764
8881
  <xsl:otherwise>
8765
- <fo:block>
8766
- <xsl:apply-templates select="." mode="list"/>
8767
- </fo:block>
8882
+
8883
+ <fo:block>
8884
+ <xsl:apply-templates select="." mode="list"/>
8885
+ </fo:block>
8886
+
8768
8887
  </xsl:otherwise>
8769
8888
  </xsl:choose>
8770
8889
  </xsl:template>
@@ -9448,24 +9567,32 @@
9448
9567
  <xsl:for-each select="*[local-name() = 'tab']">
9449
9568
  <xsl:variable name="current_id" select="generate-id()"/>
9450
9569
  <fo:table-cell>
9451
- <fo:block>
9452
- <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
9453
- <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
9454
- <xsl:choose>
9455
- <xsl:when test="self::text()"><xsl:value-of select="."/></xsl:when>
9456
- <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
9457
- </xsl:choose>
9458
- </xsl:for-each>
9459
- </fo:basic-link>
9570
+ <fo:block line-height-shift-adjustment="disregard-shifts">
9571
+ <xsl:call-template name="insert_basic_link">
9572
+ <xsl:with-param name="element">
9573
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
9574
+ <xsl:for-each select="following-sibling::node()[not(self::*[local-name() = 'tab']) and preceding-sibling::*[local-name() = 'tab'][1][generate-id() = $current_id]]">
9575
+ <xsl:choose>
9576
+ <xsl:when test="self::text()"><xsl:value-of select="."/></xsl:when>
9577
+ <xsl:otherwise><xsl:apply-templates select="."/></xsl:otherwise>
9578
+ </xsl:choose>
9579
+ </xsl:for-each>
9580
+ </fo:basic-link>
9581
+ </xsl:with-param>
9582
+ </xsl:call-template>
9460
9583
  </fo:block>
9461
9584
  </fo:table-cell>
9462
9585
  </xsl:for-each>
9463
9586
  <!-- last column - for page numbers -->
9464
9587
  <fo:table-cell text-align="right" font-size="10pt" font-weight="bold" font-family="Arial">
9465
9588
  <fo:block>
9466
- <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
9467
- <fo:page-number-citation ref-id="{$target}"/>
9468
- </fo:basic-link>
9589
+ <xsl:call-template name="insert_basic_link">
9590
+ <xsl:with-param name="element">
9591
+ <fo:basic-link internal-destination="{$target}" fox:alt-text="{.}">
9592
+ <fo:page-number-citation ref-id="{$target}"/>
9593
+ </fo:basic-link>
9594
+ </xsl:with-param>
9595
+ </xsl:call-template>
9469
9596
  </fo:block>
9470
9597
  </fo:table-cell>
9471
9598
  </xsl:template>
@@ -9507,6 +9634,27 @@
9507
9634
  <!-- End Table of Contents (ToC) processing -->
9508
9635
  <!-- =================== -->
9509
9636
 
9637
+ <!-- insert fo:basic-link, if external-destination or internal-destination is non-empty, otherwise insert fo:inline -->
9638
+ <xsl:template name="insert_basic_link">
9639
+ <xsl:param name="element"/>
9640
+ <xsl:variable name="element_node" select="xalan:nodeset($element)"/>
9641
+ <xsl:variable name="external-destination" select="normalize-space(count($element_node/fo:basic-link/@external-destination[. != '']) = 1)"/>
9642
+ <xsl:variable name="internal-destination" select="normalize-space(count($element_node/fo:basic-link/@internal-destination[. != '']) = 1)"/>
9643
+ <xsl:choose>
9644
+ <xsl:when test="$external-destination = 'true' or $internal-destination = 'true'">
9645
+ <xsl:copy-of select="$element_node"/>
9646
+ </xsl:when>
9647
+ <xsl:otherwise>
9648
+ <fo:inline>
9649
+ <xsl:for-each select="$element_node/fo:basic-link/@*[local-name() != 'external-destination' and local-name() != 'internal-destination' and local-name() != 'alt-text']">
9650
+ <xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>
9651
+ </xsl:for-each>
9652
+ <xsl:copy-of select="$element_node/fo:basic-link/node()"/>
9653
+ </fo:inline>
9654
+ </xsl:otherwise>
9655
+ </xsl:choose>
9656
+ </xsl:template>
9657
+
9510
9658
  <xsl:template match="*[local-name() = 'variant-title']"/> <!-- [@type = 'sub'] -->
9511
9659
  <xsl:template match="*[local-name() = 'variant-title'][@type = 'sub']" mode="subtitle">
9512
9660
  <fo:inline padding-right="5mm"> </fo:inline>
@@ -12,7 +12,6 @@ module IsoDoc
12
12
 
13
13
  def convert1(docxml, filename, dir)
14
14
  info docxml, nil
15
- insert_preface_sections(docxml)
16
15
  super
17
16
  end
18
17
 
@@ -20,6 +19,11 @@ module IsoDoc
20
19
  File.read(File.join(@libdir, "html", "rouge.css"))
21
20
  end
22
21
 
22
+ def preface_rearrange(doc)
23
+ super
24
+ insert_preface_sections(doc)
25
+ end
26
+
23
27
  def insert_preface_sections(doc)
24
28
  preface_insert(doc.at(ns("//preface/clause" \
25
29
  "[@type = 'executivesummary']")),
@@ -39,8 +43,7 @@ module IsoDoc
39
43
  end
40
44
 
41
45
  def preface_insert(clause, after, docxml)
42
- return unless clause
43
-
46
+ clause or return
44
47
  clause.remove
45
48
  if after then after.next = clause
46
49
  else
@@ -126,9 +129,9 @@ module IsoDoc
126
129
  end
127
130
 
128
131
  def clause1(elem)
129
- return if elem.name == "terms" && elem.parent.name == "annex" &&
130
- elem.parent.xpath(ns("./terms")).size == 1
131
-
132
+ elem.name == "terms" && elem.parent.name == "annex" &&
133
+ elem.parent.xpath(ns("./terms")).size == 1 and return
134
+ elem.name == "clause" && elem["type"] == "toc" and return
132
135
  super
133
136
  end
134
137
 
@@ -1,70 +1,70 @@
1
1
  module IsoDoc
2
2
  module Ogc
3
3
  module BaseConvert
4
- def intro_clause(elem, out)
5
- out.div **{ class: "Section3", id: elem["id"] } do |div|
6
- clause_name(elem, elem&.at(ns("./title")), div, class: "IntroTitle")
7
- elem.elements.each { |e| parse(e, div) unless e.name == "title" }
4
+ def front(isoxml, out)
5
+ p = isoxml.at(ns("//preface")) or return
6
+ p.elements.each do |e|
7
+ if is_clause?(e.name)
8
+ case e.name
9
+ when "abstract" then abstract e, out
10
+ when "foreword" then foreword e, out
11
+ when "introduction" then introduction e, out
12
+ when "submitters" then intro_clause e, out
13
+ when "clause" then preface e, out
14
+ when "acknowledgements" then acknowledgements e, out
15
+ end
16
+ else
17
+ preface_block(e, out)
18
+ end
8
19
  end
9
20
  end
10
21
 
11
- def keywords(docxml, out)
12
- f = docxml.at(ns("//preface/clause[@type = 'keywords']")) || return
13
- intro_clause(f, out)
14
- end
15
-
16
- def submittingorgs(docxml, out)
17
- f = docxml.at(ns("//preface/clause[@type = 'submitting_orgs']")) or
18
- return
19
- intro_clause(f, out)
20
- end
21
-
22
- def security(docxml, out)
23
- f = docxml.at(ns("//preface/clause[@type = 'security']")) or return
24
- intro_clause(f, out)
25
- end
26
-
27
- def executivesummary(docxml, out)
28
- f = docxml.at(ns("//preface/clause[@type = 'executivesummary']")) or
29
- return
30
- intro_clause(f, out)
31
- end
32
-
33
- def submitters(docxml, out)
34
- f = docxml.at(ns("//submitters")) || return
35
- intro_clause(f, out)
22
+ def preface(clause, out)
23
+ case clause["type"]
24
+ when "toc"
25
+ table_of_contents(clause, out)
26
+ when "executivesummary", "security", "submitting_orgs",
27
+ "keywords"
28
+ intro_clause(clause, out)
29
+ else
30
+ intro_clause(clause, out)
31
+ end
36
32
  end
37
33
 
38
- def preface(isoxml, out)
39
- isoxml.xpath(ns("//preface/clause[not(@type = 'keywords' or "\
40
- "@type = 'submitting_orgs' or @type = 'security' or "\
41
- "@type = 'executivesummary')]"))
42
- .each do |f|
43
- intro_clause(f, out)
34
+ def intro_clause(elem, out)
35
+ out.div class: "Section3", id: elem["id"] do |div|
36
+ clause_name(elem, elem&.at(ns("./title")), div,
37
+ class: "IntroTitle")
38
+ elem.elements.each do |e|
39
+ parse(e, div) unless e.name == "title"
40
+ end
44
41
  end
45
42
  end
46
43
 
47
- def abstract(isoxml, out)
48
- f = isoxml.at(ns("//preface/abstract")) || return
44
+ def abstract(clause, out)
49
45
  page_break(out)
50
- out.div **attr_code(id: f["id"]) do |s|
51
- clause_name(f, f&.at(ns("./title")), s, class: "AbstractTitle")
52
- f.elements.each { |e| parse(e, s) unless e.name == "title" }
46
+ out.div **attr_code(id: clause["id"]) do |s|
47
+ clause_name(clause, clause.at(ns("./title")), s,
48
+ class: "AbstractTitle")
49
+ clause.elements.each do |e|
50
+ parse(e, s) unless e.name == "title"
51
+ end
53
52
  end
54
53
  end
55
54
 
56
- def foreword(isoxml, out)
57
- f = isoxml.at(ns("//foreword")) || return
55
+ def foreword(clause, out)
58
56
  page_break(out)
59
- out.div **attr_code(id: f["id"]) do |s|
60
- clause_name(f, f&.at(ns("./title")), s, class: "ForewordTitle")
61
- f.elements.each { |e| parse(e, s) unless e.name == "title" }
57
+ out.div **attr_code(id: clause["id"]) do |s|
58
+ clause_name(clause, clause&.at(ns("./title")), s,
59
+ class: "ForewordTitle")
60
+ clause.elements.each do |e|
61
+ parse(e, s) unless e.name == "title"
62
+ end
62
63
  end
63
64
  end
64
65
 
65
- def acknowledgements(isoxml, out)
66
- f = isoxml.at(ns("//acknowledgements")) || return
67
- intro_clause(f, out)
66
+ def acknowledgements(clause, out)
67
+ intro_clause(clause, out)
68
68
  end
69
69
 
70
70
  def conformance(isoxml, out, num)
@@ -91,6 +91,8 @@ module IsoDoc
91
91
  @prefacenum = 0
92
92
  info docxml, div2
93
93
  boilerplate docxml, div2
94
+ front docxml, div2
95
+ =begin
94
96
  preface_block docxml, div2
95
97
  abstract docxml, div2
96
98
  executivesummary docxml, div2
@@ -102,6 +104,7 @@ module IsoDoc
102
104
  submitters docxml, div2
103
105
  preface docxml, div2
104
106
  acknowledgements docxml, div2
107
+ =end
105
108
  div2.p { |p| p << "&#xA0;" } # placeholder
106
109
  end
107
110
  section_break(body)
@@ -31,7 +31,7 @@ module IsoDoc
31
31
  end
32
32
  doc.xpath(ns("//preface/clause[not(@type = 'keywords' or " \
33
33
  "@type = 'submitting_orgs' or @type = 'security' or " \
34
- "@type = 'executivesummary')]"))
34
+ "@type = 'executivesummary' or @type = 'toc')]"))
35
35
  .each { |c| preface_names_numbered(c) }
36
36
  preface_names_numbered(doc.at(ns("//acknowledgements")))
37
37
  sequential_asset_names(