metanorma-ogc 2.6.2 → 2.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -5246,6 +5246,7 @@
5246
5246
 
5247
5247
  <fo:block role="SKIP">
5248
5248
  <xsl:apply-templates/>
5249
+ <xsl:if test="$isGenerateTableIF = 'false' and count(node()) = 0"> </xsl:if>
5249
5250
  </fo:block>
5250
5251
  </fo:table-cell>
5251
5252
  </xsl:template> <!-- cell in table header row - 'th' -->
@@ -5309,6 +5310,8 @@
5309
5310
 
5310
5311
  <xsl:if test="$isGenerateTableIF = 'true'"> <fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> -->
5311
5312
 
5313
+ <xsl:if test="$isGenerateTableIF = 'false' and count(node()) = 0"> </xsl:if>
5314
+
5312
5315
  </fo:block>
5313
5316
  </fo:table-cell>
5314
5317
  </xsl:template> <!-- td -->
@@ -8115,14 +8118,16 @@
8115
8118
  <xsl:template match="*[local-name()='link']" name="link">
8116
8119
  <xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
8117
8120
  <xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
8121
+ <xsl:variable name="isLinkToEmbeddedFile" select="normalize-space(@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target])"/>
8118
8122
  <xsl:variable name="target">
8119
8123
  <xsl:choose>
8120
8124
  <xsl:when test="@updatetype = 'true'">
8121
8125
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
8122
8126
  </xsl:when>
8123
8127
  <!-- link to the PDF attachment -->
8124
- <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
8125
- <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
8128
+ <xsl:when test="$isLinkToEmbeddedFile = 'true'">
8129
+ <xsl:variable name="target_file" select="java:org.metanorma.fop.Util.getFilenameFromPath(@target)"/>
8130
+ <xsl:value-of select="concat('url(embedded-file:', $target_file, ')')"/>
8126
8131
  </xsl:when>
8127
8132
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
8128
8133
  <xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
@@ -8153,6 +8158,11 @@
8153
8158
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
8154
8159
  </xsl:if>
8155
8160
 
8161
+ <xsl:if test="$isLinkToEmbeddedFile = 'true'">
8162
+ <xsl:attribute name="color">inherit</xsl:attribute>
8163
+ <xsl:attribute name="text-decoration">none</xsl:attribute>
8164
+ </xsl:if>
8165
+
8156
8166
  <xsl:call-template name="refine_link-style"/>
8157
8167
 
8158
8168
  <xsl:choose>
@@ -8163,6 +8173,9 @@
8163
8173
  <xsl:call-template name="insert_basic_link">
8164
8174
  <xsl:with-param name="element">
8165
8175
  <fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
8176
+ <xsl:if test="$isLinkToEmbeddedFile = 'true'">
8177
+ <xsl:attribute name="role">Annot</xsl:attribute>
8178
+ </xsl:if>
8166
8179
  <xsl:choose>
8167
8180
  <xsl:when test="normalize-space(.) = ''">
8168
8181
  <xsl:call-template name="add-zero-spaces-link-java">
@@ -8175,6 +8188,10 @@
8175
8188
  </xsl:otherwise>
8176
8189
  </xsl:choose>
8177
8190
  </fo:basic-link>
8191
+ <xsl:if test="$isLinkToEmbeddedFile = 'true'">
8192
+ <!-- reserve space at right for PaperClip icon -->
8193
+ <fo:inline keep-with-previous.within-line="always">        </fo:inline>
8194
+ </xsl:if>
8178
8195
  </xsl:with-param>
8179
8196
  </xsl:call-template>
8180
8197
  </xsl:otherwise>
@@ -13745,9 +13762,14 @@
13745
13762
  </x:xmpmeta>
13746
13763
  <!-- add attachments -->
13747
13764
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
13748
- <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
13749
-
13750
- <pdf:embedded-file filename="{@name}">
13765
+ <xsl:variable name="bibitem_attachment_" select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]"/>
13766
+ <xsl:variable name="bibitem_attachment" select="xalan:nodeset($bibitem_attachment_)"/>
13767
+ <xsl:variable name="description" select="normalize-space($bibitem_attachment/*[local-name() = 'formattedref'])"/>
13768
+ <xsl:variable name="filename" select="java:org.metanorma.fop.Util.getFilenameFromPath(@name)"/>
13769
+ <!-- Todo: need update -->
13770
+ <xsl:variable name="afrelationship" select="normalize-space($bibitem_attachment//*[local-name() = 'span'][@class = 'pdf-AFRelationship'])"/>
13771
+
13772
+ <pdf:embedded-file filename="{$filename}" link-as-file-annotation="true">
13751
13773
  <xsl:attribute name="src">
13752
13774
  <xsl:choose>
13753
13775
  <xsl:when test="normalize-space() != ''">
@@ -13763,18 +13785,27 @@
13763
13785
  <xsl:if test="$description != ''">
13764
13786
  <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13765
13787
  </xsl:if>
13788
+ <xsl:if test="$afrelationship != ''">
13789
+ <xsl:attribute name="afrelationship"><xsl:value-of select="$afrelationship"/></xsl:attribute>
13790
+ </xsl:if>
13766
13791
  </pdf:embedded-file>
13767
13792
  </xsl:for-each>
13768
13793
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
13769
13794
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
13770
13795
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
13771
13796
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
13797
+ <xsl:variable name="attachment_name" select="java:org.metanorma.fop.Util.getFilenameFromPath($attachment_path)"/>
13772
13798
  <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
13773
13799
  <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
13774
- <pdf:embedded-file src="{$url}" filename="{$attachment_path}">
13800
+ <!-- Todo: need update -->
13801
+ <xsl:variable name="afrelationship" select="normalize-space(.//*[local-name() = 'span'][@class = 'pdf-AFRelationship'])"/>
13802
+ <pdf:embedded-file src="{$url}" filename="{$attachment_name}" link-as-file-annotation="true">
13775
13803
  <xsl:if test="$description != ''">
13776
13804
  <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13777
13805
  </xsl:if>
13806
+ <xsl:if test="$afrelationship != ''">
13807
+ <xsl:attribute name="afrelationship"><xsl:value-of select="$afrelationship"/></xsl:attribute>
13808
+ </xsl:if>
13778
13809
  </pdf:embedded-file>
13779
13810
  </xsl:for-each>
13780
13811
  </xsl:if>
@@ -13794,6 +13825,12 @@
13794
13825
  <!-- Get or calculate depth of the element -->
13795
13826
  <xsl:template name="getLevel">
13796
13827
  <xsl:param name="depth"/>
13828
+ <!-- <xsl:message>
13829
+ <xsl:choose>
13830
+ <xsl:when test="local-name() = 'title'">title=<xsl:value-of select="."/></xsl:when>
13831
+ <xsl:when test="local-name() = 'clause'">clause/title=<xsl:value-of select="*[local-name() = 'title']"/></xsl:when>
13832
+ </xsl:choose>
13833
+ </xsl:message> -->
13797
13834
  <xsl:choose>
13798
13835
  <xsl:when test="normalize-space(@depth) != ''">
13799
13836
  <xsl:value-of select="@depth"/>
@@ -13814,8 +13851,27 @@
13814
13851
  <xsl:when test="ancestor::*[local-name() = 'preface']">
13815
13852
  <xsl:value-of select="$level_total - 2"/>
13816
13853
  </xsl:when>
13854
+ <xsl:when test="ancestor::*[local-name() = 'sections'] and self::*[local-name() = 'title']">
13855
+ <xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/>
13856
+ <xsl:choose>
13857
+ <xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
13858
+ <xsl:value-of select="number($upper_clause_depth + 1)"/>
13859
+ </xsl:when>
13860
+ <xsl:otherwise>
13861
+ <xsl:value-of select="$level_total - 2"/>
13862
+ </xsl:otherwise>
13863
+ </xsl:choose>
13864
+ </xsl:when>
13817
13865
  <xsl:when test="ancestor::*[local-name() = 'sections']">
13818
- <xsl:value-of select="$level_total - 1"/>
13866
+ <xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][1]/*[local-name() = 'title']/@depth)"/>
13867
+ <xsl:choose>
13868
+ <xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
13869
+ <xsl:value-of select="number($upper_clause_depth + 1)"/>
13870
+ </xsl:when>
13871
+ <xsl:otherwise>
13872
+ <xsl:value-of select="$level_total - 1"/>
13873
+ </xsl:otherwise>
13874
+ </xsl:choose>
13819
13875
  </xsl:when>
13820
13876
  <xsl:when test="ancestor::*[local-name() = 'bibliography']">
13821
13877
  <xsl:value-of select="$level_total - 1"/>
@@ -13823,6 +13879,17 @@
13823
13879
  <xsl:when test="parent::*[local-name() = 'annex']">
13824
13880
  <xsl:value-of select="$level_total - 1"/>
13825
13881
  </xsl:when>
13882
+ <xsl:when test="ancestor::*[local-name() = 'annex'] and self::*[local-name() = 'title']">
13883
+ <xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/>
13884
+ <xsl:choose>
13885
+ <xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
13886
+ <xsl:value-of select="number($upper_clause_depth + 1)"/>
13887
+ </xsl:when>
13888
+ <xsl:otherwise>
13889
+ <xsl:value-of select="$level_total - 1"/>
13890
+ </xsl:otherwise>
13891
+ </xsl:choose>
13892
+ </xsl:when>
13826
13893
  <xsl:when test="ancestor::*[local-name() = 'annex']">
13827
13894
  <xsl:value-of select="$level_total"/>
13828
13895
  </xsl:when>
@@ -14181,6 +14248,20 @@
14181
14248
 
14182
14249
  <!-- END: insert cover page image -->
14183
14250
 
14251
+ <xsl:template name="insertVerticalChar">
14252
+ <xsl:param name="str"/>
14253
+ <xsl:if test="string-length($str) &gt; 0">
14254
+ <fo:inline-container writing-mode="lr-tb" text-align="center" alignment-baseline="central" reference-orientation="90" width="1em" margin="0" padding="0" text-indent="0mm" last-line-end-indent="0mm" start-indent="0mm" end-indent="0mm">
14255
+ <fo:block-container width="1em">
14256
+ <fo:block line-height="1em"><xsl:value-of select="substring($str,1,1)"/></fo:block>
14257
+ </fo:block-container>
14258
+ </fo:inline-container>
14259
+ <xsl:call-template name="insertVerticalChar">
14260
+ <xsl:with-param name="str" select="substring($str, 2)"/>
14261
+ </xsl:call-template>
14262
+ </xsl:if>
14263
+ </xsl:template>
14264
+
14184
14265
  <xsl:template name="number-to-words">
14185
14266
  <xsl:param name="number"/>
14186
14267
  <xsl:param name="first"/>
@@ -14468,4 +14549,18 @@
14468
14549
  </xsl:if>
14469
14550
  </xsl:template>
14470
14551
 
14552
+ <xsl:template match="@*|node()" mode="set_table_role_skip">
14553
+ <xsl:copy>
14554
+ <xsl:apply-templates select="@*|node()" mode="set_table_role_skip"/>
14555
+ </xsl:copy>
14556
+ </xsl:template>
14557
+
14558
+ <xsl:template match="*[starts-with(local-name(), 'table')]" mode="set_table_role_skip">
14559
+ <xsl:copy>
14560
+ <xsl:apply-templates select="@*" mode="set_table_role_skip"/>
14561
+ <xsl:attribute name="role">SKIP</xsl:attribute>
14562
+ <xsl:apply-templates select="node()" mode="set_table_role_skip"/>
14563
+ </xsl:copy>
14564
+ </xsl:template>
14565
+
14471
14566
  </xsl:stylesheet>
@@ -5246,6 +5246,7 @@
5246
5246
 
5247
5247
  <fo:block role="SKIP">
5248
5248
  <xsl:apply-templates/>
5249
+ <xsl:if test="$isGenerateTableIF = 'false' and count(node()) = 0"> </xsl:if>
5249
5250
  </fo:block>
5250
5251
  </fo:table-cell>
5251
5252
  </xsl:template> <!-- cell in table header row - 'th' -->
@@ -5309,6 +5310,8 @@
5309
5310
 
5310
5311
  <xsl:if test="$isGenerateTableIF = 'true'"> <fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> -->
5311
5312
 
5313
+ <xsl:if test="$isGenerateTableIF = 'false' and count(node()) = 0"> </xsl:if>
5314
+
5312
5315
  </fo:block>
5313
5316
  </fo:table-cell>
5314
5317
  </xsl:template> <!-- td -->
@@ -8115,14 +8118,16 @@
8115
8118
  <xsl:template match="*[local-name()='link']" name="link">
8116
8119
  <xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
8117
8120
  <xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
8121
+ <xsl:variable name="isLinkToEmbeddedFile" select="normalize-space(@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target])"/>
8118
8122
  <xsl:variable name="target">
8119
8123
  <xsl:choose>
8120
8124
  <xsl:when test="@updatetype = 'true'">
8121
8125
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
8122
8126
  </xsl:when>
8123
8127
  <!-- link to the PDF attachment -->
8124
- <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
8125
- <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
8128
+ <xsl:when test="$isLinkToEmbeddedFile = 'true'">
8129
+ <xsl:variable name="target_file" select="java:org.metanorma.fop.Util.getFilenameFromPath(@target)"/>
8130
+ <xsl:value-of select="concat('url(embedded-file:', $target_file, ')')"/>
8126
8131
  </xsl:when>
8127
8132
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
8128
8133
  <xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
@@ -8153,6 +8158,11 @@
8153
8158
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
8154
8159
  </xsl:if>
8155
8160
 
8161
+ <xsl:if test="$isLinkToEmbeddedFile = 'true'">
8162
+ <xsl:attribute name="color">inherit</xsl:attribute>
8163
+ <xsl:attribute name="text-decoration">none</xsl:attribute>
8164
+ </xsl:if>
8165
+
8156
8166
  <xsl:call-template name="refine_link-style"/>
8157
8167
 
8158
8168
  <xsl:choose>
@@ -8163,6 +8173,9 @@
8163
8173
  <xsl:call-template name="insert_basic_link">
8164
8174
  <xsl:with-param name="element">
8165
8175
  <fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
8176
+ <xsl:if test="$isLinkToEmbeddedFile = 'true'">
8177
+ <xsl:attribute name="role">Annot</xsl:attribute>
8178
+ </xsl:if>
8166
8179
  <xsl:choose>
8167
8180
  <xsl:when test="normalize-space(.) = ''">
8168
8181
  <xsl:call-template name="add-zero-spaces-link-java">
@@ -8175,6 +8188,10 @@
8175
8188
  </xsl:otherwise>
8176
8189
  </xsl:choose>
8177
8190
  </fo:basic-link>
8191
+ <xsl:if test="$isLinkToEmbeddedFile = 'true'">
8192
+ <!-- reserve space at right for PaperClip icon -->
8193
+ <fo:inline keep-with-previous.within-line="always">        </fo:inline>
8194
+ </xsl:if>
8178
8195
  </xsl:with-param>
8179
8196
  </xsl:call-template>
8180
8197
  </xsl:otherwise>
@@ -13745,9 +13762,14 @@
13745
13762
  </x:xmpmeta>
13746
13763
  <!-- add attachments -->
13747
13764
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
13748
- <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
13749
-
13750
- <pdf:embedded-file filename="{@name}">
13765
+ <xsl:variable name="bibitem_attachment_" select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]"/>
13766
+ <xsl:variable name="bibitem_attachment" select="xalan:nodeset($bibitem_attachment_)"/>
13767
+ <xsl:variable name="description" select="normalize-space($bibitem_attachment/*[local-name() = 'formattedref'])"/>
13768
+ <xsl:variable name="filename" select="java:org.metanorma.fop.Util.getFilenameFromPath(@name)"/>
13769
+ <!-- Todo: need update -->
13770
+ <xsl:variable name="afrelationship" select="normalize-space($bibitem_attachment//*[local-name() = 'span'][@class = 'pdf-AFRelationship'])"/>
13771
+
13772
+ <pdf:embedded-file filename="{$filename}" link-as-file-annotation="true">
13751
13773
  <xsl:attribute name="src">
13752
13774
  <xsl:choose>
13753
13775
  <xsl:when test="normalize-space() != ''">
@@ -13763,18 +13785,27 @@
13763
13785
  <xsl:if test="$description != ''">
13764
13786
  <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13765
13787
  </xsl:if>
13788
+ <xsl:if test="$afrelationship != ''">
13789
+ <xsl:attribute name="afrelationship"><xsl:value-of select="$afrelationship"/></xsl:attribute>
13790
+ </xsl:if>
13766
13791
  </pdf:embedded-file>
13767
13792
  </xsl:for-each>
13768
13793
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
13769
13794
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
13770
13795
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
13771
13796
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
13797
+ <xsl:variable name="attachment_name" select="java:org.metanorma.fop.Util.getFilenameFromPath($attachment_path)"/>
13772
13798
  <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
13773
13799
  <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
13774
- <pdf:embedded-file src="{$url}" filename="{$attachment_path}">
13800
+ <!-- Todo: need update -->
13801
+ <xsl:variable name="afrelationship" select="normalize-space(.//*[local-name() = 'span'][@class = 'pdf-AFRelationship'])"/>
13802
+ <pdf:embedded-file src="{$url}" filename="{$attachment_name}" link-as-file-annotation="true">
13775
13803
  <xsl:if test="$description != ''">
13776
13804
  <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13777
13805
  </xsl:if>
13806
+ <xsl:if test="$afrelationship != ''">
13807
+ <xsl:attribute name="afrelationship"><xsl:value-of select="$afrelationship"/></xsl:attribute>
13808
+ </xsl:if>
13778
13809
  </pdf:embedded-file>
13779
13810
  </xsl:for-each>
13780
13811
  </xsl:if>
@@ -13794,6 +13825,12 @@
13794
13825
  <!-- Get or calculate depth of the element -->
13795
13826
  <xsl:template name="getLevel">
13796
13827
  <xsl:param name="depth"/>
13828
+ <!-- <xsl:message>
13829
+ <xsl:choose>
13830
+ <xsl:when test="local-name() = 'title'">title=<xsl:value-of select="."/></xsl:when>
13831
+ <xsl:when test="local-name() = 'clause'">clause/title=<xsl:value-of select="*[local-name() = 'title']"/></xsl:when>
13832
+ </xsl:choose>
13833
+ </xsl:message> -->
13797
13834
  <xsl:choose>
13798
13835
  <xsl:when test="normalize-space(@depth) != ''">
13799
13836
  <xsl:value-of select="@depth"/>
@@ -13814,8 +13851,27 @@
13814
13851
  <xsl:when test="ancestor::*[local-name() = 'preface']">
13815
13852
  <xsl:value-of select="$level_total - 2"/>
13816
13853
  </xsl:when>
13854
+ <xsl:when test="ancestor::*[local-name() = 'sections'] and self::*[local-name() = 'title']">
13855
+ <xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/>
13856
+ <xsl:choose>
13857
+ <xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
13858
+ <xsl:value-of select="number($upper_clause_depth + 1)"/>
13859
+ </xsl:when>
13860
+ <xsl:otherwise>
13861
+ <xsl:value-of select="$level_total - 2"/>
13862
+ </xsl:otherwise>
13863
+ </xsl:choose>
13864
+ </xsl:when>
13817
13865
  <xsl:when test="ancestor::*[local-name() = 'sections']">
13818
- <xsl:value-of select="$level_total - 1"/>
13866
+ <xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][1]/*[local-name() = 'title']/@depth)"/>
13867
+ <xsl:choose>
13868
+ <xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
13869
+ <xsl:value-of select="number($upper_clause_depth + 1)"/>
13870
+ </xsl:when>
13871
+ <xsl:otherwise>
13872
+ <xsl:value-of select="$level_total - 1"/>
13873
+ </xsl:otherwise>
13874
+ </xsl:choose>
13819
13875
  </xsl:when>
13820
13876
  <xsl:when test="ancestor::*[local-name() = 'bibliography']">
13821
13877
  <xsl:value-of select="$level_total - 1"/>
@@ -13823,6 +13879,17 @@
13823
13879
  <xsl:when test="parent::*[local-name() = 'annex']">
13824
13880
  <xsl:value-of select="$level_total - 1"/>
13825
13881
  </xsl:when>
13882
+ <xsl:when test="ancestor::*[local-name() = 'annex'] and self::*[local-name() = 'title']">
13883
+ <xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/>
13884
+ <xsl:choose>
13885
+ <xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
13886
+ <xsl:value-of select="number($upper_clause_depth + 1)"/>
13887
+ </xsl:when>
13888
+ <xsl:otherwise>
13889
+ <xsl:value-of select="$level_total - 1"/>
13890
+ </xsl:otherwise>
13891
+ </xsl:choose>
13892
+ </xsl:when>
13826
13893
  <xsl:when test="ancestor::*[local-name() = 'annex']">
13827
13894
  <xsl:value-of select="$level_total"/>
13828
13895
  </xsl:when>
@@ -14181,6 +14248,20 @@
14181
14248
 
14182
14249
  <!-- END: insert cover page image -->
14183
14250
 
14251
+ <xsl:template name="insertVerticalChar">
14252
+ <xsl:param name="str"/>
14253
+ <xsl:if test="string-length($str) &gt; 0">
14254
+ <fo:inline-container writing-mode="lr-tb" text-align="center" alignment-baseline="central" reference-orientation="90" width="1em" margin="0" padding="0" text-indent="0mm" last-line-end-indent="0mm" start-indent="0mm" end-indent="0mm">
14255
+ <fo:block-container width="1em">
14256
+ <fo:block line-height="1em"><xsl:value-of select="substring($str,1,1)"/></fo:block>
14257
+ </fo:block-container>
14258
+ </fo:inline-container>
14259
+ <xsl:call-template name="insertVerticalChar">
14260
+ <xsl:with-param name="str" select="substring($str, 2)"/>
14261
+ </xsl:call-template>
14262
+ </xsl:if>
14263
+ </xsl:template>
14264
+
14184
14265
  <xsl:template name="number-to-words">
14185
14266
  <xsl:param name="number"/>
14186
14267
  <xsl:param name="first"/>
@@ -14468,4 +14549,18 @@
14468
14549
  </xsl:if>
14469
14550
  </xsl:template>
14470
14551
 
14552
+ <xsl:template match="@*|node()" mode="set_table_role_skip">
14553
+ <xsl:copy>
14554
+ <xsl:apply-templates select="@*|node()" mode="set_table_role_skip"/>
14555
+ </xsl:copy>
14556
+ </xsl:template>
14557
+
14558
+ <xsl:template match="*[starts-with(local-name(), 'table')]" mode="set_table_role_skip">
14559
+ <xsl:copy>
14560
+ <xsl:apply-templates select="@*" mode="set_table_role_skip"/>
14561
+ <xsl:attribute name="role">SKIP</xsl:attribute>
14562
+ <xsl:apply-templates select="node()" mode="set_table_role_skip"/>
14563
+ </xsl:copy>
14564
+ </xsl:template>
14565
+
14471
14566
  </xsl:stylesheet>
@@ -5246,6 +5246,7 @@
5246
5246
 
5247
5247
  <fo:block role="SKIP">
5248
5248
  <xsl:apply-templates/>
5249
+ <xsl:if test="$isGenerateTableIF = 'false' and count(node()) = 0"> </xsl:if>
5249
5250
  </fo:block>
5250
5251
  </fo:table-cell>
5251
5252
  </xsl:template> <!-- cell in table header row - 'th' -->
@@ -5309,6 +5310,8 @@
5309
5310
 
5310
5311
  <xsl:if test="$isGenerateTableIF = 'true'"> <fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> -->
5311
5312
 
5313
+ <xsl:if test="$isGenerateTableIF = 'false' and count(node()) = 0"> </xsl:if>
5314
+
5312
5315
  </fo:block>
5313
5316
  </fo:table-cell>
5314
5317
  </xsl:template> <!-- td -->
@@ -8115,14 +8118,16 @@
8115
8118
  <xsl:template match="*[local-name()='link']" name="link">
8116
8119
  <xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
8117
8120
  <xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
8121
+ <xsl:variable name="isLinkToEmbeddedFile" select="normalize-space(@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target])"/>
8118
8122
  <xsl:variable name="target">
8119
8123
  <xsl:choose>
8120
8124
  <xsl:when test="@updatetype = 'true'">
8121
8125
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
8122
8126
  </xsl:when>
8123
8127
  <!-- link to the PDF attachment -->
8124
- <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]">
8125
- <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
8128
+ <xsl:when test="$isLinkToEmbeddedFile = 'true'">
8129
+ <xsl:variable name="target_file" select="java:org.metanorma.fop.Util.getFilenameFromPath(@target)"/>
8130
+ <xsl:value-of select="concat('url(embedded-file:', $target_file, ')')"/>
8126
8131
  </xsl:when>
8127
8132
  <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
8128
8133
  <xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
@@ -8153,6 +8158,11 @@
8153
8158
  <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
8154
8159
  </xsl:if>
8155
8160
 
8161
+ <xsl:if test="$isLinkToEmbeddedFile = 'true'">
8162
+ <xsl:attribute name="color">inherit</xsl:attribute>
8163
+ <xsl:attribute name="text-decoration">none</xsl:attribute>
8164
+ </xsl:if>
8165
+
8156
8166
  <xsl:call-template name="refine_link-style"/>
8157
8167
 
8158
8168
  <xsl:choose>
@@ -8163,6 +8173,9 @@
8163
8173
  <xsl:call-template name="insert_basic_link">
8164
8174
  <xsl:with-param name="element">
8165
8175
  <fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
8176
+ <xsl:if test="$isLinkToEmbeddedFile = 'true'">
8177
+ <xsl:attribute name="role">Annot</xsl:attribute>
8178
+ </xsl:if>
8166
8179
  <xsl:choose>
8167
8180
  <xsl:when test="normalize-space(.) = ''">
8168
8181
  <xsl:call-template name="add-zero-spaces-link-java">
@@ -8175,6 +8188,10 @@
8175
8188
  </xsl:otherwise>
8176
8189
  </xsl:choose>
8177
8190
  </fo:basic-link>
8191
+ <xsl:if test="$isLinkToEmbeddedFile = 'true'">
8192
+ <!-- reserve space at right for PaperClip icon -->
8193
+ <fo:inline keep-with-previous.within-line="always">        </fo:inline>
8194
+ </xsl:if>
8178
8195
  </xsl:with-param>
8179
8196
  </xsl:call-template>
8180
8197
  </xsl:otherwise>
@@ -13745,9 +13762,14 @@
13745
13762
  </x:xmpmeta>
13746
13763
  <!-- add attachments -->
13747
13764
  <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
13748
- <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/>
13749
-
13750
- <pdf:embedded-file filename="{@name}">
13765
+ <xsl:variable name="bibitem_attachment_" select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]"/>
13766
+ <xsl:variable name="bibitem_attachment" select="xalan:nodeset($bibitem_attachment_)"/>
13767
+ <xsl:variable name="description" select="normalize-space($bibitem_attachment/*[local-name() = 'formattedref'])"/>
13768
+ <xsl:variable name="filename" select="java:org.metanorma.fop.Util.getFilenameFromPath(@name)"/>
13769
+ <!-- Todo: need update -->
13770
+ <xsl:variable name="afrelationship" select="normalize-space($bibitem_attachment//*[local-name() = 'span'][@class = 'pdf-AFRelationship'])"/>
13771
+
13772
+ <pdf:embedded-file filename="{$filename}" link-as-file-annotation="true">
13751
13773
  <xsl:attribute name="src">
13752
13774
  <xsl:choose>
13753
13775
  <xsl:when test="normalize-space() != ''">
@@ -13763,18 +13785,27 @@
13763
13785
  <xsl:if test="$description != ''">
13764
13786
  <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13765
13787
  </xsl:if>
13788
+ <xsl:if test="$afrelationship != ''">
13789
+ <xsl:attribute name="afrelationship"><xsl:value-of select="$afrelationship"/></xsl:attribute>
13790
+ </xsl:if>
13766
13791
  </pdf:embedded-file>
13767
13792
  </xsl:for-each>
13768
13793
  <!-- references to external attachments (no binary-encoded within the Metanorma XML file) -->
13769
13794
  <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])">
13770
13795
  <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]">
13771
13796
  <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/>
13797
+ <xsl:variable name="attachment_name" select="java:org.metanorma.fop.Util.getFilenameFromPath($attachment_path)"/>
13772
13798
  <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/>
13773
13799
  <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/>
13774
- <pdf:embedded-file src="{$url}" filename="{$attachment_path}">
13800
+ <!-- Todo: need update -->
13801
+ <xsl:variable name="afrelationship" select="normalize-space(.//*[local-name() = 'span'][@class = 'pdf-AFRelationship'])"/>
13802
+ <pdf:embedded-file src="{$url}" filename="{$attachment_name}" link-as-file-annotation="true">
13775
13803
  <xsl:if test="$description != ''">
13776
13804
  <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute>
13777
13805
  </xsl:if>
13806
+ <xsl:if test="$afrelationship != ''">
13807
+ <xsl:attribute name="afrelationship"><xsl:value-of select="$afrelationship"/></xsl:attribute>
13808
+ </xsl:if>
13778
13809
  </pdf:embedded-file>
13779
13810
  </xsl:for-each>
13780
13811
  </xsl:if>
@@ -13794,6 +13825,12 @@
13794
13825
  <!-- Get or calculate depth of the element -->
13795
13826
  <xsl:template name="getLevel">
13796
13827
  <xsl:param name="depth"/>
13828
+ <!-- <xsl:message>
13829
+ <xsl:choose>
13830
+ <xsl:when test="local-name() = 'title'">title=<xsl:value-of select="."/></xsl:when>
13831
+ <xsl:when test="local-name() = 'clause'">clause/title=<xsl:value-of select="*[local-name() = 'title']"/></xsl:when>
13832
+ </xsl:choose>
13833
+ </xsl:message> -->
13797
13834
  <xsl:choose>
13798
13835
  <xsl:when test="normalize-space(@depth) != ''">
13799
13836
  <xsl:value-of select="@depth"/>
@@ -13814,8 +13851,27 @@
13814
13851
  <xsl:when test="ancestor::*[local-name() = 'preface']">
13815
13852
  <xsl:value-of select="$level_total - 2"/>
13816
13853
  </xsl:when>
13854
+ <xsl:when test="ancestor::*[local-name() = 'sections'] and self::*[local-name() = 'title']">
13855
+ <xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/>
13856
+ <xsl:choose>
13857
+ <xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
13858
+ <xsl:value-of select="number($upper_clause_depth + 1)"/>
13859
+ </xsl:when>
13860
+ <xsl:otherwise>
13861
+ <xsl:value-of select="$level_total - 2"/>
13862
+ </xsl:otherwise>
13863
+ </xsl:choose>
13864
+ </xsl:when>
13817
13865
  <xsl:when test="ancestor::*[local-name() = 'sections']">
13818
- <xsl:value-of select="$level_total - 1"/>
13866
+ <xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][1]/*[local-name() = 'title']/@depth)"/>
13867
+ <xsl:choose>
13868
+ <xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
13869
+ <xsl:value-of select="number($upper_clause_depth + 1)"/>
13870
+ </xsl:when>
13871
+ <xsl:otherwise>
13872
+ <xsl:value-of select="$level_total - 1"/>
13873
+ </xsl:otherwise>
13874
+ </xsl:choose>
13819
13875
  </xsl:when>
13820
13876
  <xsl:when test="ancestor::*[local-name() = 'bibliography']">
13821
13877
  <xsl:value-of select="$level_total - 1"/>
@@ -13823,6 +13879,17 @@
13823
13879
  <xsl:when test="parent::*[local-name() = 'annex']">
13824
13880
  <xsl:value-of select="$level_total - 1"/>
13825
13881
  </xsl:when>
13882
+ <xsl:when test="ancestor::*[local-name() = 'annex'] and self::*[local-name() = 'title']">
13883
+ <xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/>
13884
+ <xsl:choose>
13885
+ <xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
13886
+ <xsl:value-of select="number($upper_clause_depth + 1)"/>
13887
+ </xsl:when>
13888
+ <xsl:otherwise>
13889
+ <xsl:value-of select="$level_total - 1"/>
13890
+ </xsl:otherwise>
13891
+ </xsl:choose>
13892
+ </xsl:when>
13826
13893
  <xsl:when test="ancestor::*[local-name() = 'annex']">
13827
13894
  <xsl:value-of select="$level_total"/>
13828
13895
  </xsl:when>
@@ -14181,6 +14248,20 @@
14181
14248
 
14182
14249
  <!-- END: insert cover page image -->
14183
14250
 
14251
+ <xsl:template name="insertVerticalChar">
14252
+ <xsl:param name="str"/>
14253
+ <xsl:if test="string-length($str) &gt; 0">
14254
+ <fo:inline-container writing-mode="lr-tb" text-align="center" alignment-baseline="central" reference-orientation="90" width="1em" margin="0" padding="0" text-indent="0mm" last-line-end-indent="0mm" start-indent="0mm" end-indent="0mm">
14255
+ <fo:block-container width="1em">
14256
+ <fo:block line-height="1em"><xsl:value-of select="substring($str,1,1)"/></fo:block>
14257
+ </fo:block-container>
14258
+ </fo:inline-container>
14259
+ <xsl:call-template name="insertVerticalChar">
14260
+ <xsl:with-param name="str" select="substring($str, 2)"/>
14261
+ </xsl:call-template>
14262
+ </xsl:if>
14263
+ </xsl:template>
14264
+
14184
14265
  <xsl:template name="number-to-words">
14185
14266
  <xsl:param name="number"/>
14186
14267
  <xsl:param name="first"/>
@@ -14468,4 +14549,18 @@
14468
14549
  </xsl:if>
14469
14550
  </xsl:template>
14470
14551
 
14552
+ <xsl:template match="@*|node()" mode="set_table_role_skip">
14553
+ <xsl:copy>
14554
+ <xsl:apply-templates select="@*|node()" mode="set_table_role_skip"/>
14555
+ </xsl:copy>
14556
+ </xsl:template>
14557
+
14558
+ <xsl:template match="*[starts-with(local-name(), 'table')]" mode="set_table_role_skip">
14559
+ <xsl:copy>
14560
+ <xsl:apply-templates select="@*" mode="set_table_role_skip"/>
14561
+ <xsl:attribute name="role">SKIP</xsl:attribute>
14562
+ <xsl:apply-templates select="node()" mode="set_table_role_skip"/>
14563
+ </xsl:copy>
14564
+ </xsl:template>
14565
+
14471
14566
  </xsl:stylesheet>