lib/isodoc/ogc/ogc.white-paper.xsl in metanorma-ogc-2.6.0 vs lib/isodoc/ogc/ogc.white-paper.xsl in metanorma-ogc-2.6.1

- old
+ new

@@ -6895,10 +6895,16 @@ <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:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])"> + <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]"> + <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/> + <attachment filename="{$attachment_path}"/> + </xsl:for-each> + </xsl:if> </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, '\', '/')"/> @@ -6907,11 +6913,11 @@ <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:when test="@attachment = 'true' and $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> @@ -7556,11 +7562,20 @@ <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="img_src"> <xsl:choose> - <xsl:when test="not(starts-with(@src, 'data:'))"><xsl:value-of select="concat($basepath, @src)"/></xsl:when> + <xsl:when test="not(starts-with(@src, 'data:'))"> + <xsl:choose> + <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 --> + <xsl:value-of select="@src"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat($basepath, @src)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> <xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="image_width_effective"> @@ -7569,11 +7584,11 @@ </xsl:variable> <!-- <xsl:message>width_effective=<xsl:value-of select="$width_effective"/></xsl:message> <xsl:message>indent_left=<xsl:value-of select="$indent_left"/></xsl:message> <xsl:message>image_width_effective=<xsl:value-of select="$image_width_effective"/> for <xsl:value-of select="ancestor::ogc:p[1]/@id"/></xsl:message> --> - <xsl:variable name="scale" select="java:org.metanorma.fop.Util.getImageScale($img_src, $image_width_effective, $height_effective)"/> + <xsl:variable name="scale" select="java:org.metanorma.fop.utils.ImageUtils.getImageScale($img_src, $image_width_effective, $height_effective)"/> <xsl:value-of select="$scale"/> </xsl:template> <xsl:template name="image_src"> <xsl:choose> @@ -7588,11 +7603,18 @@ <xsl:when test="not(starts-with(@src, 'data:')) and (java:endsWith(java:java.lang.String.new(@src), '.webp') or java:endsWith(java:java.lang.String.new(@src), '.WEBP'))"> <xsl:variable name="src_png" select="java:org.metanorma.fop.utils.ImageUtils.convertWebPtoPNG(@src)"/> <xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/> </xsl:when> <xsl:when test="not(starts-with(@src, 'data:'))"> - <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/> + <xsl:choose> + <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 --> + <xsl:value-of select="concat('url(file:///', @src, ')')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/> + </xsl:otherwise> + </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:value-of select="@src"/> </xsl:otherwise> </xsl:choose> @@ -7610,11 +7632,18 @@ <image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="{$src}" style="overflow:visible;"/> </svg> </xsl:when> <xsl:when test="not(starts-with(@src, 'data:'))"> <xsl:variable name="src"> - <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/> + <xsl:choose> + <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 --> + <xsl:value-of select="concat('url(file:///', @src, ')')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/> + </xsl:otherwise> + </xsl:choose> </xsl:variable> <xsl:variable name="file" select="java:java.io.File.new(@src)"/> <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/> <xsl:variable name="width" select="java:getWidth($bufferedImage)"/> <xsl:variable name="height" select="java:getHeight($bufferedImage)"/> @@ -12426,30 +12455,41 @@ </rdf:Description> </rdf:RDF> </x:xmpmeta> <!-- add attachments --> <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']"> - <xsl:choose> - <xsl:when test="normalize-space() != ''"> - <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks --> - <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$src_attachment}" 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 , @name, ')')"/> - <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/> - </xsl:otherwise> - </xsl:choose> + <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/> + + <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" filename="{@name}"> + <xsl:attribute name="src"> + <xsl:choose> + <xsl:when test="normalize-space() != ''"> + <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks --> + <xsl:value-of select="$src_attachment"/> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath , @name, ')')"/> + <xsl:value-of select="$url"/> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + <xsl:if test="$description != ''"> + <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute> + </xsl:if> + </pdf:embedded-file> </xsl:for-each> <!-- references to external attachments (no binary-encoded within the Metanorma XML file) --> <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])"> <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]"> <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/> - <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/> - <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/> - <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$filename_embedded}"/> + <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/> + <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/> + <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$attachment_path}"> + <xsl:if test="$description != ''"> + <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute> + </xsl:if> + </pdf:embedded-file> </xsl:for-each> </xsl:if> </xsl:template> <!-- addPDFUAmeta --> <xsl:template name="getId"> @@ -12823,10 +12863,17 @@ <xsl:choose> <xsl:when test="starts-with($src, 'data:image')"> <xsl:value-of select="$src"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/> + <xsl:choose> + <xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 --> + <xsl:value-of select="concat('url(file:///', @src, ')')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat('url(file:///',$basepath, $src, ')')"/> + </xsl:otherwise> + </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="getSVG"> \ No newline at end of file