Skip to content

Commit

Permalink
rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Sep 11, 2024
2 parents 5fcac74 + af54955 commit 44e366a
Show file tree
Hide file tree
Showing 22 changed files with 13,845 additions and 12,040 deletions.
2 changes: 1 addition & 1 deletion Gemfile.devel
Original file line number Diff line number Diff line change
@@ -1 +1 @@
gem "pubid-itu", git: "https://github.com/metanorma/pubid-itu", branch: "annex-to-ob"
gem "pubid-itu", git: "https://github.com/metanorma/pubid-itu", branch: "main"
89 changes: 68 additions & 21 deletions lib/isodoc/itu/itu.implementers-guide.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -8880,6 +8880,12 @@
<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_)"/>

Expand All @@ -8892,7 +8898,7 @@
<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]">
Expand Down Expand Up @@ -9547,7 +9553,16 @@
</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>
Expand All @@ -9560,7 +9575,7 @@
<!-- <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>

Expand All @@ -9579,7 +9594,14 @@
<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"/>
Expand All @@ -9601,7 +9623,14 @@
</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)"/>
Expand Down Expand Up @@ -14417,26 +14446,37 @@
</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 -->
Expand Down Expand Up @@ -14814,7 +14854,14 @@
<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>
Expand Down
89 changes: 68 additions & 21 deletions lib/isodoc/itu/itu.in-force.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -8880,6 +8880,12 @@
<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_)"/>

Expand All @@ -8892,7 +8898,7 @@
<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]">
Expand Down Expand Up @@ -9547,7 +9553,16 @@
</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>
Expand All @@ -9560,7 +9575,7 @@
<!-- <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>

Expand All @@ -9579,7 +9594,14 @@
<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"/>
Expand All @@ -9601,7 +9623,14 @@
</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)"/>
Expand Down Expand Up @@ -14417,26 +14446,37 @@
</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 -->
Expand Down Expand Up @@ -14814,7 +14854,14 @@
<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>
Expand Down
Loading

0 comments on commit 44e366a

Please sign in to comment.