metanorma-ogc 2.5.12 → 2.5.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -7978,18 +7978,33 @@
7978
7978
 
7979
7979
  <xsl:template match="*[local-name()='localityStack']"/>
7980
7980
 
7981
+ <xsl:variable name="pdfAttachmentsList_">
7982
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
7983
+ <attachment filename="{@name}"/>
7984
+ </xsl:for-each>
7985
+ </xsl:variable>
7986
+ <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
7987
+
7981
7988
  <xsl:template match="*[local-name()='link']" name="link">
7989
+ <xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
7990
+ <xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
7982
7991
  <xsl:variable name="target">
7983
7992
  <xsl:choose>
7984
7993
  <xsl:when test="@updatetype = 'true'">
7985
7994
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
7986
7995
  </xsl:when>
7996
+ <!-- link to the PDF attachment -->
7997
+ <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
7998
+ <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
7999
+ </xsl:when>
8000
+ <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
8001
+ <xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
8002
+ </xsl:when>
7987
8003
  <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
7988
- <!-- link to the PDF attachment -->
7989
8004
  <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
7990
8005
  <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
7991
8006
  <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
7992
- </xsl:when>
8007
+ </xsl:when> -->
7993
8008
  <xsl:otherwise>
7994
8009
  <xsl:value-of select="normalize-space(@target)"/>
7995
8010
  </xsl:otherwise>
@@ -9666,8 +9681,11 @@
9666
9681
  </xsl:template>
9667
9682
 
9668
9683
  <xsl:template match="*[local-name() = 'strong']" mode="contents_item">
9684
+ <xsl:param name="element"/>
9669
9685
  <xsl:copy>
9670
- <xsl:apply-templates mode="contents_item"/>
9686
+ <xsl:apply-templates mode="contents_item">
9687
+ <xsl:with-param name="element" select="$element"/>
9688
+ </xsl:apply-templates>
9671
9689
  </xsl:copy>
9672
9690
  </xsl:template>
9673
9691
 
@@ -9734,7 +9752,10 @@
9734
9752
 
9735
9753
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
9736
9754
  <xsl:template match="*[local-name() = 'span']" mode="contents_item">
9737
- <xsl:apply-templates mode="contents_item"/>
9755
+ <xsl:param name="element"/>
9756
+ <xsl:apply-templates mode="contents_item">
9757
+ <xsl:with-param name="element" select="$element"/>
9758
+ </xsl:apply-templates>
9738
9759
  </xsl:template>
9739
9760
 
9740
9761
  <!-- =============== -->
@@ -12630,6 +12651,17 @@
12630
12651
  <xsl:copy-of select="."/>
12631
12652
  </xsl:template>
12632
12653
 
12654
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
12655
+ <xsl:copy>
12656
+ <xsl:copy-of select="@*"/>
12657
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
12658
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
12659
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
12660
+ <xsl:value-of select="."/>
12661
+ </xsl:if>
12662
+ </xsl:copy>
12663
+ </xsl:template>
12664
+
12633
12665
  <!-- add @id, mandatory for table auto-layout algorithm -->
12634
12666
  <xsl:template match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1">
12635
12667
  <xsl:copy>
@@ -13504,7 +13536,8 @@
13504
13536
  </xsl:when>
13505
13537
  <xsl:otherwise>
13506
13538
  <!-- _{filename}_attachments -->
13507
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
13539
+ <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
13540
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13508
13541
  <pdf:embedded-file src="{$url}" filename="{@name}"/>
13509
13542
  </xsl:otherwise>
13510
13543
  </xsl:choose>
@@ -7978,18 +7978,33 @@
7978
7978
 
7979
7979
  <xsl:template match="*[local-name()='localityStack']"/>
7980
7980
 
7981
+ <xsl:variable name="pdfAttachmentsList_">
7982
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
7983
+ <attachment filename="{@name}"/>
7984
+ </xsl:for-each>
7985
+ </xsl:variable>
7986
+ <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
7987
+
7981
7988
  <xsl:template match="*[local-name()='link']" name="link">
7989
+ <xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
7990
+ <xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
7982
7991
  <xsl:variable name="target">
7983
7992
  <xsl:choose>
7984
7993
  <xsl:when test="@updatetype = 'true'">
7985
7994
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
7986
7995
  </xsl:when>
7996
+ <!-- link to the PDF attachment -->
7997
+ <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
7998
+ <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
7999
+ </xsl:when>
8000
+ <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
8001
+ <xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
8002
+ </xsl:when>
7987
8003
  <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
7988
- <!-- link to the PDF attachment -->
7989
8004
  <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
7990
8005
  <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
7991
8006
  <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
7992
- </xsl:when>
8007
+ </xsl:when> -->
7993
8008
  <xsl:otherwise>
7994
8009
  <xsl:value-of select="normalize-space(@target)"/>
7995
8010
  </xsl:otherwise>
@@ -9666,8 +9681,11 @@
9666
9681
  </xsl:template>
9667
9682
 
9668
9683
  <xsl:template match="*[local-name() = 'strong']" mode="contents_item">
9684
+ <xsl:param name="element"/>
9669
9685
  <xsl:copy>
9670
- <xsl:apply-templates mode="contents_item"/>
9686
+ <xsl:apply-templates mode="contents_item">
9687
+ <xsl:with-param name="element" select="$element"/>
9688
+ </xsl:apply-templates>
9671
9689
  </xsl:copy>
9672
9690
  </xsl:template>
9673
9691
 
@@ -9734,7 +9752,10 @@
9734
9752
 
9735
9753
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
9736
9754
  <xsl:template match="*[local-name() = 'span']" mode="contents_item">
9737
- <xsl:apply-templates mode="contents_item"/>
9755
+ <xsl:param name="element"/>
9756
+ <xsl:apply-templates mode="contents_item">
9757
+ <xsl:with-param name="element" select="$element"/>
9758
+ </xsl:apply-templates>
9738
9759
  </xsl:template>
9739
9760
 
9740
9761
  <!-- =============== -->
@@ -12630,6 +12651,17 @@
12630
12651
  <xsl:copy-of select="."/>
12631
12652
  </xsl:template>
12632
12653
 
12654
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
12655
+ <xsl:copy>
12656
+ <xsl:copy-of select="@*"/>
12657
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
12658
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
12659
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
12660
+ <xsl:value-of select="."/>
12661
+ </xsl:if>
12662
+ </xsl:copy>
12663
+ </xsl:template>
12664
+
12633
12665
  <!-- add @id, mandatory for table auto-layout algorithm -->
12634
12666
  <xsl:template match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1">
12635
12667
  <xsl:copy>
@@ -13504,7 +13536,8 @@
13504
13536
  </xsl:when>
13505
13537
  <xsl:otherwise>
13506
13538
  <!-- _{filename}_attachments -->
13507
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
13539
+ <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
13540
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13508
13541
  <pdf:embedded-file src="{$url}" filename="{@name}"/>
13509
13542
  </xsl:otherwise>
13510
13543
  </xsl:choose>
@@ -7978,18 +7978,33 @@
7978
7978
 
7979
7979
  <xsl:template match="*[local-name()='localityStack']"/>
7980
7980
 
7981
+ <xsl:variable name="pdfAttachmentsList_">
7982
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
7983
+ <attachment filename="{@name}"/>
7984
+ </xsl:for-each>
7985
+ </xsl:variable>
7986
+ <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
7987
+
7981
7988
  <xsl:template match="*[local-name()='link']" name="link">
7989
+ <xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
7990
+ <xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
7982
7991
  <xsl:variable name="target">
7983
7992
  <xsl:choose>
7984
7993
  <xsl:when test="@updatetype = 'true'">
7985
7994
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
7986
7995
  </xsl:when>
7996
+ <!-- link to the PDF attachment -->
7997
+ <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
7998
+ <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
7999
+ </xsl:when>
8000
+ <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
8001
+ <xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
8002
+ </xsl:when>
7987
8003
  <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
7988
- <!-- link to the PDF attachment -->
7989
8004
  <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
7990
8005
  <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
7991
8006
  <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
7992
- </xsl:when>
8007
+ </xsl:when> -->
7993
8008
  <xsl:otherwise>
7994
8009
  <xsl:value-of select="normalize-space(@target)"/>
7995
8010
  </xsl:otherwise>
@@ -9666,8 +9681,11 @@
9666
9681
  </xsl:template>
9667
9682
 
9668
9683
  <xsl:template match="*[local-name() = 'strong']" mode="contents_item">
9684
+ <xsl:param name="element"/>
9669
9685
  <xsl:copy>
9670
- <xsl:apply-templates mode="contents_item"/>
9686
+ <xsl:apply-templates mode="contents_item">
9687
+ <xsl:with-param name="element" select="$element"/>
9688
+ </xsl:apply-templates>
9671
9689
  </xsl:copy>
9672
9690
  </xsl:template>
9673
9691
 
@@ -9734,7 +9752,10 @@
9734
9752
 
9735
9753
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
9736
9754
  <xsl:template match="*[local-name() = 'span']" mode="contents_item">
9737
- <xsl:apply-templates mode="contents_item"/>
9755
+ <xsl:param name="element"/>
9756
+ <xsl:apply-templates mode="contents_item">
9757
+ <xsl:with-param name="element" select="$element"/>
9758
+ </xsl:apply-templates>
9738
9759
  </xsl:template>
9739
9760
 
9740
9761
  <!-- =============== -->
@@ -12630,6 +12651,17 @@
12630
12651
  <xsl:copy-of select="."/>
12631
12652
  </xsl:template>
12632
12653
 
12654
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
12655
+ <xsl:copy>
12656
+ <xsl:copy-of select="@*"/>
12657
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
12658
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
12659
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
12660
+ <xsl:value-of select="."/>
12661
+ </xsl:if>
12662
+ </xsl:copy>
12663
+ </xsl:template>
12664
+
12633
12665
  <!-- add @id, mandatory for table auto-layout algorithm -->
12634
12666
  <xsl:template match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1">
12635
12667
  <xsl:copy>
@@ -13504,7 +13536,8 @@
13504
13536
  </xsl:when>
13505
13537
  <xsl:otherwise>
13506
13538
  <!-- _{filename}_attachments -->
13507
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
13539
+ <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
13540
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13508
13541
  <pdf:embedded-file src="{$url}" filename="{@name}"/>
13509
13542
  </xsl:otherwise>
13510
13543
  </xsl:choose>
@@ -7978,18 +7978,33 @@
7978
7978
 
7979
7979
  <xsl:template match="*[local-name()='localityStack']"/>
7980
7980
 
7981
+ <xsl:variable name="pdfAttachmentsList_">
7982
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
7983
+ <attachment filename="{@name}"/>
7984
+ </xsl:for-each>
7985
+ </xsl:variable>
7986
+ <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
7987
+
7981
7988
  <xsl:template match="*[local-name()='link']" name="link">
7989
+ <xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
7990
+ <xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
7982
7991
  <xsl:variable name="target">
7983
7992
  <xsl:choose>
7984
7993
  <xsl:when test="@updatetype = 'true'">
7985
7994
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
7986
7995
  </xsl:when>
7996
+ <!-- link to the PDF attachment -->
7997
+ <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
7998
+ <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
7999
+ </xsl:when>
8000
+ <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
8001
+ <xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
8002
+ </xsl:when>
7987
8003
  <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
7988
- <!-- link to the PDF attachment -->
7989
8004
  <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
7990
8005
  <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
7991
8006
  <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
7992
- </xsl:when>
8007
+ </xsl:when> -->
7993
8008
  <xsl:otherwise>
7994
8009
  <xsl:value-of select="normalize-space(@target)"/>
7995
8010
  </xsl:otherwise>
@@ -9666,8 +9681,11 @@
9666
9681
  </xsl:template>
9667
9682
 
9668
9683
  <xsl:template match="*[local-name() = 'strong']" mode="contents_item">
9684
+ <xsl:param name="element"/>
9669
9685
  <xsl:copy>
9670
- <xsl:apply-templates mode="contents_item"/>
9686
+ <xsl:apply-templates mode="contents_item">
9687
+ <xsl:with-param name="element" select="$element"/>
9688
+ </xsl:apply-templates>
9671
9689
  </xsl:copy>
9672
9690
  </xsl:template>
9673
9691
 
@@ -9734,7 +9752,10 @@
9734
9752
 
9735
9753
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
9736
9754
  <xsl:template match="*[local-name() = 'span']" mode="contents_item">
9737
- <xsl:apply-templates mode="contents_item"/>
9755
+ <xsl:param name="element"/>
9756
+ <xsl:apply-templates mode="contents_item">
9757
+ <xsl:with-param name="element" select="$element"/>
9758
+ </xsl:apply-templates>
9738
9759
  </xsl:template>
9739
9760
 
9740
9761
  <!-- =============== -->
@@ -12630,6 +12651,17 @@
12630
12651
  <xsl:copy-of select="."/>
12631
12652
  </xsl:template>
12632
12653
 
12654
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
12655
+ <xsl:copy>
12656
+ <xsl:copy-of select="@*"/>
12657
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
12658
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
12659
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
12660
+ <xsl:value-of select="."/>
12661
+ </xsl:if>
12662
+ </xsl:copy>
12663
+ </xsl:template>
12664
+
12633
12665
  <!-- add @id, mandatory for table auto-layout algorithm -->
12634
12666
  <xsl:template match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1">
12635
12667
  <xsl:copy>
@@ -13504,7 +13536,8 @@
13504
13536
  </xsl:when>
13505
13537
  <xsl:otherwise>
13506
13538
  <!-- _{filename}_attachments -->
13507
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
13539
+ <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
13540
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13508
13541
  <pdf:embedded-file src="{$url}" filename="{@name}"/>
13509
13542
  </xsl:otherwise>
13510
13543
  </xsl:choose>
@@ -7978,18 +7978,33 @@
7978
7978
 
7979
7979
  <xsl:template match="*[local-name()='localityStack']"/>
7980
7980
 
7981
+ <xsl:variable name="pdfAttachmentsList_">
7982
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
7983
+ <attachment filename="{@name}"/>
7984
+ </xsl:for-each>
7985
+ </xsl:variable>
7986
+ <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
7987
+
7981
7988
  <xsl:template match="*[local-name()='link']" name="link">
7989
+ <xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
7990
+ <xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
7982
7991
  <xsl:variable name="target">
7983
7992
  <xsl:choose>
7984
7993
  <xsl:when test="@updatetype = 'true'">
7985
7994
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
7986
7995
  </xsl:when>
7996
+ <!-- link to the PDF attachment -->
7997
+ <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
7998
+ <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
7999
+ </xsl:when>
8000
+ <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
8001
+ <xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
8002
+ </xsl:when>
7987
8003
  <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
7988
- <!-- link to the PDF attachment -->
7989
8004
  <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
7990
8005
  <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
7991
8006
  <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
7992
- </xsl:when>
8007
+ </xsl:when> -->
7993
8008
  <xsl:otherwise>
7994
8009
  <xsl:value-of select="normalize-space(@target)"/>
7995
8010
  </xsl:otherwise>
@@ -9666,8 +9681,11 @@
9666
9681
  </xsl:template>
9667
9682
 
9668
9683
  <xsl:template match="*[local-name() = 'strong']" mode="contents_item">
9684
+ <xsl:param name="element"/>
9669
9685
  <xsl:copy>
9670
- <xsl:apply-templates mode="contents_item"/>
9686
+ <xsl:apply-templates mode="contents_item">
9687
+ <xsl:with-param name="element" select="$element"/>
9688
+ </xsl:apply-templates>
9671
9689
  </xsl:copy>
9672
9690
  </xsl:template>
9673
9691
 
@@ -9734,7 +9752,10 @@
9734
9752
 
9735
9753
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
9736
9754
  <xsl:template match="*[local-name() = 'span']" mode="contents_item">
9737
- <xsl:apply-templates mode="contents_item"/>
9755
+ <xsl:param name="element"/>
9756
+ <xsl:apply-templates mode="contents_item">
9757
+ <xsl:with-param name="element" select="$element"/>
9758
+ </xsl:apply-templates>
9738
9759
  </xsl:template>
9739
9760
 
9740
9761
  <!-- =============== -->
@@ -12630,6 +12651,17 @@
12630
12651
  <xsl:copy-of select="."/>
12631
12652
  </xsl:template>
12632
12653
 
12654
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
12655
+ <xsl:copy>
12656
+ <xsl:copy-of select="@*"/>
12657
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
12658
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
12659
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
12660
+ <xsl:value-of select="."/>
12661
+ </xsl:if>
12662
+ </xsl:copy>
12663
+ </xsl:template>
12664
+
12633
12665
  <!-- add @id, mandatory for table auto-layout algorithm -->
12634
12666
  <xsl:template match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1">
12635
12667
  <xsl:copy>
@@ -13504,7 +13536,8 @@
13504
13536
  </xsl:when>
13505
13537
  <xsl:otherwise>
13506
13538
  <!-- _{filename}_attachments -->
13507
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
13539
+ <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
13540
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13508
13541
  <pdf:embedded-file src="{$url}" filename="{@name}"/>
13509
13542
  </xsl:otherwise>
13510
13543
  </xsl:choose>
@@ -7978,18 +7978,33 @@
7978
7978
 
7979
7979
  <xsl:template match="*[local-name()='localityStack']"/>
7980
7980
 
7981
+ <xsl:variable name="pdfAttachmentsList_">
7982
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
7983
+ <attachment filename="{@name}"/>
7984
+ </xsl:for-each>
7985
+ </xsl:variable>
7986
+ <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
7987
+
7981
7988
  <xsl:template match="*[local-name()='link']" name="link">
7989
+ <xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
7990
+ <xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
7982
7991
  <xsl:variable name="target">
7983
7992
  <xsl:choose>
7984
7993
  <xsl:when test="@updatetype = 'true'">
7985
7994
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
7986
7995
  </xsl:when>
7996
+ <!-- link to the PDF attachment -->
7997
+ <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
7998
+ <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
7999
+ </xsl:when>
8000
+ <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
8001
+ <xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
8002
+ </xsl:when>
7987
8003
  <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
7988
- <!-- link to the PDF attachment -->
7989
8004
  <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
7990
8005
  <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
7991
8006
  <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
7992
- </xsl:when>
8007
+ </xsl:when> -->
7993
8008
  <xsl:otherwise>
7994
8009
  <xsl:value-of select="normalize-space(@target)"/>
7995
8010
  </xsl:otherwise>
@@ -9666,8 +9681,11 @@
9666
9681
  </xsl:template>
9667
9682
 
9668
9683
  <xsl:template match="*[local-name() = 'strong']" mode="contents_item">
9684
+ <xsl:param name="element"/>
9669
9685
  <xsl:copy>
9670
- <xsl:apply-templates mode="contents_item"/>
9686
+ <xsl:apply-templates mode="contents_item">
9687
+ <xsl:with-param name="element" select="$element"/>
9688
+ </xsl:apply-templates>
9671
9689
  </xsl:copy>
9672
9690
  </xsl:template>
9673
9691
 
@@ -9734,7 +9752,10 @@
9734
9752
 
9735
9753
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
9736
9754
  <xsl:template match="*[local-name() = 'span']" mode="contents_item">
9737
- <xsl:apply-templates mode="contents_item"/>
9755
+ <xsl:param name="element"/>
9756
+ <xsl:apply-templates mode="contents_item">
9757
+ <xsl:with-param name="element" select="$element"/>
9758
+ </xsl:apply-templates>
9738
9759
  </xsl:template>
9739
9760
 
9740
9761
  <!-- =============== -->
@@ -12630,6 +12651,17 @@
12630
12651
  <xsl:copy-of select="."/>
12631
12652
  </xsl:template>
12632
12653
 
12654
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
12655
+ <xsl:copy>
12656
+ <xsl:copy-of select="@*"/>
12657
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
12658
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
12659
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
12660
+ <xsl:value-of select="."/>
12661
+ </xsl:if>
12662
+ </xsl:copy>
12663
+ </xsl:template>
12664
+
12633
12665
  <!-- add @id, mandatory for table auto-layout algorithm -->
12634
12666
  <xsl:template match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1">
12635
12667
  <xsl:copy>
@@ -13504,7 +13536,8 @@
13504
13536
  </xsl:when>
13505
13537
  <xsl:otherwise>
13506
13538
  <!-- _{filename}_attachments -->
13507
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
13539
+ <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
13540
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13508
13541
  <pdf:embedded-file src="{$url}" filename="{@name}"/>
13509
13542
  </xsl:otherwise>
13510
13543
  </xsl:choose>
@@ -7978,18 +7978,33 @@
7978
7978
 
7979
7979
  <xsl:template match="*[local-name()='localityStack']"/>
7980
7980
 
7981
+ <xsl:variable name="pdfAttachmentsList_">
7982
+ <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']">
7983
+ <attachment filename="{@name}"/>
7984
+ </xsl:for-each>
7985
+ </xsl:variable>
7986
+ <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/>
7987
+
7981
7988
  <xsl:template match="*[local-name()='link']" name="link">
7989
+ <xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/>
7990
+ <xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/>
7982
7991
  <xsl:variable name="target">
7983
7992
  <xsl:choose>
7984
7993
  <xsl:when test="@updatetype = 'true'">
7985
7994
  <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/>
7986
7995
  </xsl:when>
7996
+ <!-- link to the PDF attachment -->
7997
+ <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]">
7998
+ <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/>
7999
+ </xsl:when>
8000
+ <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]">
8001
+ <xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/>
8002
+ </xsl:when>
7987
8003
  <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))">
7988
- <!-- link to the PDF attachment -->
7989
8004
  <xsl:variable name="target_" select="translate(@target, '\', '/')"/>
7990
8005
  <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/>
7991
8006
  <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/>
7992
- </xsl:when>
8007
+ </xsl:when> -->
7993
8008
  <xsl:otherwise>
7994
8009
  <xsl:value-of select="normalize-space(@target)"/>
7995
8010
  </xsl:otherwise>
@@ -9666,8 +9681,11 @@
9666
9681
  </xsl:template>
9667
9682
 
9668
9683
  <xsl:template match="*[local-name() = 'strong']" mode="contents_item">
9684
+ <xsl:param name="element"/>
9669
9685
  <xsl:copy>
9670
- <xsl:apply-templates mode="contents_item"/>
9686
+ <xsl:apply-templates mode="contents_item">
9687
+ <xsl:with-param name="element" select="$element"/>
9688
+ </xsl:apply-templates>
9671
9689
  </xsl:copy>
9672
9690
  </xsl:template>
9673
9691
 
@@ -9734,7 +9752,10 @@
9734
9752
 
9735
9753
  <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output -->
9736
9754
  <xsl:template match="*[local-name() = 'span']" mode="contents_item">
9737
- <xsl:apply-templates mode="contents_item"/>
9755
+ <xsl:param name="element"/>
9756
+ <xsl:apply-templates mode="contents_item">
9757
+ <xsl:with-param name="element" select="$element"/>
9758
+ </xsl:apply-templates>
9738
9759
  </xsl:template>
9739
9760
 
9740
9761
  <!-- =============== -->
@@ -12630,6 +12651,17 @@
12630
12651
  <xsl:copy-of select="."/>
12631
12652
  </xsl:template>
12632
12653
 
12654
+ <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1">
12655
+ <xsl:copy>
12656
+ <xsl:copy-of select="@*"/>
12657
+ <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/>
12658
+ <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/>
12659
+ <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist -->
12660
+ <xsl:value-of select="."/>
12661
+ </xsl:if>
12662
+ </xsl:copy>
12663
+ </xsl:template>
12664
+
12633
12665
  <!-- add @id, mandatory for table auto-layout algorithm -->
12634
12666
  <xsl:template match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1">
12635
12667
  <xsl:copy>
@@ -13504,7 +13536,8 @@
13504
13536
  </xsl:when>
13505
13537
  <xsl:otherwise>
13506
13538
  <!-- _{filename}_attachments -->
13507
- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/>
13539
+ <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> -->
13540
+ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/>
13508
13541
  <pdf:embedded-file src="{$url}" filename="{@name}"/>
13509
13542
  </xsl:otherwise>
13510
13543
  </xsl:choose>