Skip to content

Commit

Permalink
Merge pull request #1264 from metanorma/feature/xslt-update
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Dec 21, 2024
2 parents eb1dc04 + 6870101 commit f48afc6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 62 deletions.
55 changes: 24 additions & 31 deletions lib/isodoc/iso/iso.amendment.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -12951,16 +12951,29 @@
<xsl:template name="getImageSrc">
<xsl:choose>
<xsl:when test="not(starts-with(@src, 'data:'))">
<xsl:call-template name="getImageSrcExternal"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="getImageSrcExternal">
<xsl:choose>
<xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
<xsl:value-of select="@src"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="src_with_basepath" select="concat($basepath, @src)"/>
<xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($src_with_basepath)))"/>
<xsl:choose>
<xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
<xsl:value-of select="@src"/>
<xsl:when test="$file_exists = 'true'">
<xsl:value-of select="$src_with_basepath"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($basepath, @src)"/>
<xsl:value-of select="@src"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

Expand Down Expand Up @@ -13008,14 +13021,8 @@
<xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
</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="concat('url(file:///', @src, ')')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:variable name="src_external"><xsl:call-template name="getImageSrcExternal"/></xsl:variable>
<xsl:value-of select="concat('url(file:///', $src_external, ')')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@src"/>
Expand All @@ -13036,16 +13043,8 @@
</svg>
</xsl:when>
<xsl:when test="not(starts-with(@src, 'data:'))">
<xsl:variable name="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="src_external"><xsl:call-template name="getImageSrcExternal"/></xsl:variable>
<xsl:variable name="src" select="concat('url(file:///', $src_external, ')')"/>
<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)"/>
Expand Down Expand Up @@ -18867,14 +18866,8 @@
<xsl:value-of select="$src"/>
</xsl:when>
<xsl:otherwise>
<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 name="src_external"><xsl:call-template name="getImageSrcExternal"/></xsl:variable>
<xsl:value-of select="concat('url(file:///', $src_external, ')')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Expand Down
55 changes: 24 additions & 31 deletions lib/isodoc/iso/iso.international-standard.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -12951,16 +12951,29 @@
<xsl:template name="getImageSrc">
<xsl:choose>
<xsl:when test="not(starts-with(@src, 'data:'))">
<xsl:call-template name="getImageSrcExternal"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="getImageSrcExternal">
<xsl:choose>
<xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
<xsl:value-of select="@src"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="src_with_basepath" select="concat($basepath, @src)"/>
<xsl:variable name="file_exists" select="normalize-space(java:exists(java:java.io.File.new($src_with_basepath)))"/>
<xsl:choose>
<xsl:when test="@extracted = 'true'"> <!-- added in mn2pdf v1.97 -->
<xsl:value-of select="@src"/>
<xsl:when test="$file_exists = 'true'">
<xsl:value-of select="$src_with_basepath"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($basepath, @src)"/>
<xsl:value-of select="@src"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise><xsl:value-of select="@src"/></xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

Expand Down Expand Up @@ -13008,14 +13021,8 @@
<xsl:value-of select="concat('url(file:///',$basepath, $src_png, ')')"/>
</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="concat('url(file:///', @src, ')')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('url(file:///',$basepath, @src, ')')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:variable name="src_external"><xsl:call-template name="getImageSrcExternal"/></xsl:variable>
<xsl:value-of select="concat('url(file:///', $src_external, ')')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@src"/>
Expand All @@ -13036,16 +13043,8 @@
</svg>
</xsl:when>
<xsl:when test="not(starts-with(@src, 'data:'))">
<xsl:variable name="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="src_external"><xsl:call-template name="getImageSrcExternal"/></xsl:variable>
<xsl:variable name="src" select="concat('url(file:///', $src_external, ')')"/>
<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)"/>
Expand Down Expand Up @@ -18867,14 +18866,8 @@
<xsl:value-of select="$src"/>
</xsl:when>
<xsl:otherwise>
<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 name="src_external"><xsl:call-template name="getImageSrcExternal"/></xsl:variable>
<xsl:value-of select="concat('url(file:///', $src_external, ')')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Expand Down

0 comments on commit f48afc6

Please sign in to comment.