lib/isodoc/cc/cc.standard.xsl in metanorma-cc-2.4.3 vs lib/isodoc/cc/cc.standard.xsl in metanorma-cc-2.4.4

- old
+ new

@@ -4796,11 +4796,12 @@ <xsl:apply-templates/> </fo:inline> </xsl:template> <xsl:template match="text()[ancestor::*[local-name()='smallcap']]"> - <xsl:variable name="text" select="normalize-space(.)"/> + <!-- <xsl:variable name="text" select="normalize-space(.)"/> --> <!-- https://github.com/metanorma/metanorma-iso/issues/1115 --> + <xsl:variable name="text" select="."/> <fo:inline font-size="75%" role="SKIP"> <xsl:if test="string-length($text) &gt; 0"> <xsl:variable name="smallCapsText"> <xsl:call-template name="recursiveSmallCaps"> <xsl:with-param name="text" select="$text"/> @@ -6931,20 +6932,48 @@ <xsl:attribute name="content-height">100%</xsl:attribute> </xsl:otherwise> </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> --> </xsl:copy> </xsl:for-each> @@ -6978,20 +7007,25 @@ </xsl:variable> <xsl:variable name="viewbox" select="xalan:nodeset($viewbox_)"/> <xsl:variable name="width" select="normalize-space($viewbox//item[3])"/> <xsl:variable name="height" select="normalize-space($viewbox//item[4])"/> + <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[1][local-name() = 'image']/@width)"/> + <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[1][local-name() = 'image']/@height)"/> + <xsl:attribute name="width"> <xsl:choose> + <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when> <xsl:when test="$width != ''"> <xsl:value-of select="round($width)"/> </xsl:when> <xsl:otherwise>400</xsl:otherwise> <!-- default width --> </xsl:choose> </xsl:attribute> <xsl:attribute name="height"> <xsl:choose> + <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when> <xsl:when test="$height != ''"> <xsl:value-of select="round($height)"/> </xsl:when> <xsl:otherwise>400</xsl:otherwise> <!-- default height --> </xsl:choose> @@ -6999,10 +7033,32 @@ <xsl:apply-templates mode="svg_update"/> </xsl:copy> </xsl:template> + <xsl:template match="*[local-name() = 'svg']/@width" mode="svg_update"> + <!-- image[@width]/svg --> + <xsl:variable name="parent_image_width" select="normalize-space(ancestor::*[2][local-name() = 'image']/@width)"/> + <xsl:attribute name="width"> + <xsl:choose> + <xsl:when test="$parent_image_width != '' and $parent_image_width != 'auto'"><xsl:value-of select="$parent_image_width"/></xsl:when> + <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise> + </xsl:choose> + </xsl:attribute> + </xsl:template> + + <xsl:template match="*[local-name() = 'svg']/@height" mode="svg_update"> + <!-- image[@height]/svg --> + <xsl:variable name="parent_image_height" select="normalize-space(ancestor::*[2][local-name() = 'image']/@height)"/> + <xsl:attribute name="height"> + <xsl:choose> + <xsl:when test="$parent_image_height != '' and $parent_image_height != 'auto'"><xsl:value-of select="$parent_image_height"/></xsl:when> + <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise> + </xsl:choose> + </xsl:attribute> + </xsl:template> + <!-- regex for 'display: inline-block;' --> <xsl:variable name="regex_svg_style_notsupported">display(\s|\h)*:(\s|\h)*inline-block(\s|\h)*;</xsl:variable> <xsl:template match="*[local-name() = 'svg']//*[local-name() = 'style']/text()" mode="svg_update"> <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.), $regex_svg_style_notsupported, '')"/> </xsl:template> @@ -9077,11 +9133,13 @@ </xsl:if> </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/> </fo:block> </xsl:template> @@ -9144,10 +9202,10 @@ </xsl:when> <!-- if there isn't element with id 'from', then create 'bookmark' here --> <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> </xsl:template> \ No newline at end of file