lib/isodoc/itu/itu.recommendation-supplement.xsl in metanorma-itu-2.4.12 vs lib/isodoc/itu/itu.recommendation-supplement.xsl in metanorma-itu-2.4.13

- old
+ new

@@ -8852,22 +8852,37 @@ <!-- END: math --> <!-- ======================================= --> <xsl:template match="*[local-name()='localityStack']"/> + <xsl:variable name="pdfAttachmentsList_"> + <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']"> + <attachment filename="{@name}"/> + </xsl:for-each> + </xsl:variable> + <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/> + <xsl:template match="*[local-name()='link']" name="link"> + <xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/> + <xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/> <xsl:variable name="target"> <xsl:choose> <xsl:when test="@updatetype = 'true'"> <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/> </xsl:when> + <!-- link to the PDF attachment --> + <xsl:when test="$pdfAttachmentsList//attachment[@filename = current()/@target]"> + <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/> + </xsl:when> + <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]"> + <xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/> + </xsl:when> <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))"> - <!-- link to the PDF attachment --> <xsl:variable name="target_" select="translate(@target, '\', '/')"/> <xsl:variable name="target__" select="substring-after($target_, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/> <xsl:value-of select="concat('url(embedded-file:', $target__, ')')"/> - </xsl:when> + </xsl:when> --> <xsl:otherwise> <xsl:value-of select="normalize-space(@target)"/> </xsl:otherwise> </xsl:choose> </xsl:variable> @@ -13497,10 +13512,21 @@ <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image'] | *[local-name() = 'sourcecode'] | *[local-name() = 'bibdata'] | *[local-name() = 'localized-strings']" mode="update_xml_step1"> <xsl:copy-of select="."/> </xsl:template> + <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']" mode="update_xml_step1"> + <xsl:copy> + <xsl:copy-of select="@*"/> + <xsl:variable name="name_filepath" select="concat($inputxml_basepath, @name)"/> + <xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($name_filepath)))"/> + <xsl:if test="$file_exists = 'false'"> <!-- copy attachment content only if file on disk doesnt exist --> + <xsl:value-of select="."/> + </xsl:if> + </xsl:copy> + </xsl:template> + <!-- add @id, mandatory for table auto-layout algorithm --> <xsl:template match="*[local-name() = 'dl' or local-name() = 'table'][not(@id)]" mode="update_xml_step1"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:call-template name="add_id"/> @@ -14371,10 +14397,11 @@ <xsl:when test="normalize-space() != ''"> <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{.}" filename="{@name}"/> </xsl:when> <xsl:otherwise> <!-- _{filename}_attachments --> - <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> + <!-- <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> --> + <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/> <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/> </xsl:otherwise> </xsl:choose> </xsl:for-each> <!-- references to external attachments (no binary-encoded within the Metanorma XML file) --> \ No newline at end of file