Skip to content

Commit

Permalink
Merge pull request #201 from metanorma/feature/xslt-update
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Mar 9, 2024
2 parents 0ab574e + c615f28 commit dee0348
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 12 deletions.
42 changes: 36 additions & 6 deletions lib/isodoc/m3aawg/m3aawg.policy.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -7044,16 +7044,44 @@
</xsl:choose>

<xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
<xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
<xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
<xsl:variable name="svg_width_" select="xalan:nodeset($svg_content)/*/@width"/>
<xsl:variable name="svg_width" select="number(translate($svg_width_, 'px', ''))"/>
<xsl:variable name="svg_height_" select="xalan:nodeset($svg_content)/*/@height"/>
<xsl:variable name="svg_height" select="number(translate($svg_height_, 'px', ''))"/>

<!-- Example: -->
<!-- effective height 297 - 27.4 - 13 = 256.6 -->
<!-- effective width 210 - 12.5 - 25 = 172.5 -->
<!-- effective height / width = 1.48, 1.4 - with title -->
<xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->

<xsl:variable name="scale_x">
<xsl:choose>
<xsl:when test="$svg_width &gt; $width_effective_px">
<xsl:value-of select="$width_effective_px div $svg_width"/>
</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="scale_y">
<xsl:choose>
<xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
<xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>

<!-- for images with big height -->
<!-- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)">
<xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
<xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
</xsl:if>
</xsl:if> -->
<xsl:attribute name="scaling">uniform</xsl:attribute>

<xsl:if test="$scale_y != 1">
<xsl:attribute name="content-height"><xsl:value-of select="round($scale_x * $scale_y * 100)"/>%</xsl:attribute>
</xsl:if>

<xsl:copy-of select="$svg_content"/>
</fo:instream-foreign-object>
<!-- </fo:block> -->
Expand Down Expand Up @@ -9212,7 +9240,9 @@
</xsl:template> <!-- sections_element_style -->

<xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
<fo:block break-after="page"/>

<fo:block break-after="page"/>

<fo:block>
<xsl:call-template name="setId"/>
<xsl:apply-templates/>
Expand Down Expand Up @@ -9279,7 +9309,7 @@
<xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
<fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
</xsl:when>
<xsl:when test="not(//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
<xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
<fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
</xsl:when>
</xsl:choose>
Expand Down
42 changes: 36 additions & 6 deletions lib/isodoc/m3aawg/m3aawg.report.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -7044,16 +7044,44 @@
</xsl:choose>

<xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute>
<xsl:variable name="svg_width" select="xalan:nodeset($svg_content)/*/@width"/>
<xsl:variable name="svg_height" select="xalan:nodeset($svg_content)/*/@height"/>
<xsl:variable name="svg_width_" select="xalan:nodeset($svg_content)/*/@width"/>
<xsl:variable name="svg_width" select="number(translate($svg_width_, 'px', ''))"/>
<xsl:variable name="svg_height_" select="xalan:nodeset($svg_content)/*/@height"/>
<xsl:variable name="svg_height" select="number(translate($svg_height_, 'px', ''))"/>

<!-- Example: -->
<!-- effective height 297 - 27.4 - 13 = 256.6 -->
<!-- effective width 210 - 12.5 - 25 = 172.5 -->
<!-- effective height / width = 1.48, 1.4 - with title -->
<xsl:if test="$svg_height &gt; ($svg_width * 1.4)"> <!-- for images with big height -->

<xsl:variable name="scale_x">
<xsl:choose>
<xsl:when test="$svg_width &gt; $width_effective_px">
<xsl:value-of select="$width_effective_px div $svg_width"/>
</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="scale_y">
<xsl:choose>
<xsl:when test="$svg_height * $scale_x &gt; $height_effective_px">
<xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/>
</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>

<!-- for images with big height -->
<!-- <xsl:if test="$svg_height &gt; ($svg_width * 1.4)">
<xsl:variable name="width" select="(($svg_width * 1.4) div $svg_height) * 100"/>
<xsl:attribute name="width"><xsl:value-of select="$width"/>%</xsl:attribute>
</xsl:if>
</xsl:if> -->
<xsl:attribute name="scaling">uniform</xsl:attribute>

<xsl:if test="$scale_y != 1">
<xsl:attribute name="content-height"><xsl:value-of select="round($scale_x * $scale_y * 100)"/>%</xsl:attribute>
</xsl:if>

<xsl:copy-of select="$svg_content"/>
</fo:instream-foreign-object>
<!-- </fo:block> -->
Expand Down Expand Up @@ -9212,7 +9240,9 @@
</xsl:template> <!-- sections_element_style -->

<xsl:template match="//*[contains(local-name(), '-standard')]/*[local-name() = 'preface']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* -->
<fo:block break-after="page"/>

<fo:block break-after="page"/>

<fo:block>
<xsl:call-template name="setId"/>
<xsl:apply-templates/>
Expand Down Expand Up @@ -9279,7 +9309,7 @@
<xsl:when test="ancestor::*[contains(local-name(), '-standard')] and not(ancestor::*[contains(local-name(), '-standard')]//*[@id = $id_from])">
<fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
</xsl:when>
<xsl:when test="not(//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
<xsl:when test="not(/*[@id = $id_from]) and not(/*//*[@id = $id_from]) and not(preceding-sibling::*[@id = $id_from])">
<fo:block id="{@from}" font-size="1pt"><xsl:value-of select="$hair_space"/></fo:block>
</xsl:when>
</xsl:choose>
Expand Down

0 comments on commit dee0348

Please sign in to comment.