lib/isodoc/itu/itu.service-publication.xsl in metanorma-itu-2.1.13 vs lib/isodoc/itu/itu.service-publication.xsl in metanorma-itu-2.2.0

- old
+ new

@@ -4688,10 +4688,14 @@ <xsl:variable name="ref_id" select="concat('footnote_', $lang, '_', $reference, '_', $current_fn_number)"/> <xsl:variable name="footnote_inline"> <fo:inline xsl:use-attribute-sets="fn-num-style"> + <xsl:if test="following-sibling::*[1][local-name() = 'fn']"> + <xsl:attribute name="padding-right">0.5mm</xsl:attribute> + </xsl:if> + <fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}"> <xsl:value-of select="$current_fn_number_text"/> </fo:basic-link> </fo:inline> </xsl:variable> @@ -5862,10 +5866,27 @@ <!-- Note: to enable the addition of character span markup with semantic styling for DIS Word output --> <xsl:template match="*[local-name() = 'span']"> <xsl:apply-templates/> </xsl:template> + <!-- Don't break standard's numbers --> + <!-- Example : <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> --> + <xsl:template match="*[local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']" priority="2"> + <xsl:choose> + <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:apply-templates/></xsl:when> + <xsl:when test="following-sibling::*[2][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']"> + <fo:inline keep-with-next.within-line="always"><xsl:apply-templates/></fo:inline> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + <xsl:template match="text()[not(ancestor::*[local-name() = 'table']) and preceding-sibling::*[1][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear'] and following-sibling::*[1][local-name() = 'span'][@class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']]" priority="2"> + <fo:inline keep-with-next.within-line="always"><xsl:value-of select="."/></fo:inline> + </xsl:template> + <!-- ========================= --> <!-- END Rich text formatting --> <!-- ========================= --> <!-- split string 'text' by 'separator' --> @@ -6257,11 +6278,11 @@ <xsl:template match="*[local-name()='th'] | *[local-name()='td']" mode="simple-table-colspan"> <xsl:choose> <xsl:when test="@colspan"> <xsl:variable name="td"> - <xsl:element name="td"> + <xsl:element name="{local-name()}"> <xsl:attribute name="divide"><xsl:value-of select="@colspan"/></xsl:attribute> <xsl:if test="local-name()='th'"> <xsl:attribute name="font-weight">bold</xsl:attribute> </xsl:if> <xsl:apply-templates select="@*" mode="simple-table-colspan"/> @@ -6272,11 +6293,11 @@ <xsl:with-param name="count" select="@colspan"/> <xsl:with-param name="node" select="$td"/> </xsl:call-template> </xsl:when> <xsl:otherwise> - <xsl:element name="td"> + <xsl:element name="{local-name()}"> <xsl:apply-templates select="@*" mode="simple-table-colspan"/> <xsl:if test="local-name()='th'"> <xsl:attribute name="font-weight">bold</xsl:attribute> </xsl:if> <xsl:apply-templates mode="simple-table-colspan"/> @@ -6339,11 +6360,11 @@ <xsl:template match="tr" mode="simple-table-rowspan"> <xsl:param name="previousRow"/> <xsl:variable name="currentRow" select="."/> <xsl:variable name="normalizedTDs"> - <xsl:for-each select="xalan:nodeset($previousRow)//td"> + <xsl:for-each select="xalan:nodeset($previousRow)//*[self::td or self::th]"> <xsl:choose> <xsl:when test="@rowspan &gt; 1"> <xsl:copy> <xsl:attribute name="rowspan"> <xsl:value-of select="@rowspan - 1"/> @@ -6351,11 +6372,11 @@ <xsl:copy-of select="@*[not(name() = 'rowspan')]"/> <xsl:copy-of select="node()"/> </xsl:copy> </xsl:when> <xsl:otherwise> - <xsl:copy-of select="$currentRow/td[1 + count(current()/preceding-sibling::td[not(@rowspan) or (@rowspan = 1)])]"/> + <xsl:copy-of select="$currentRow/*[self::td or self::th][1 + count(current()/preceding-sibling::*[self::td or self::th][not(@rowspan) or (@rowspan = 1)])]"/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:variable> @@ -7021,16 +7042,10 @@ <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style"> <fo:block-container margin-left="0mm"> - <!-- <xsl:if test="$namespace = 'iho'"> - <xsl:if test="ancestor::iho:td"> - <xsl:attribute name="font-size">12pt</xsl:attribute> - </xsl:if> - </xsl:if> --> - <fo:block> <xsl:if test="ancestor::itu:figure"> <xsl:attribute name="keep-with-previous">always</xsl:attribute> </xsl:if> @@ -7536,10 +7551,35 @@ </xsl:attribute> <xsl:apply-templates mode="svg_update"/> </xsl:copy> </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> + + <!-- replace + stroke="rgba(r, g, b, alpha)" to + stroke="rgb(r,g,b)" stroke-opacity="alpha", and + fill="rgba(r, g, b, alpha)" to + fill="rgb(r,g,b)" fill-opacity="alpha" --> + <xsl:template match="@*[local-name() = 'stroke' or local-name() = 'fill'][starts-with(normalize-space(.), 'rgba')]" mode="svg_update"> + <xsl:variable name="components_"> + <xsl:call-template name="split"> + <xsl:with-param name="pText" select="substring-before(substring-after(., '('), ')')"/> + <xsl:with-param name="sep" select="','"/> + </xsl:call-template> + </xsl:variable> + <xsl:variable name="components" select="xalan:nodeset($components_)"/> + <xsl:variable name="att_name" select="local-name()"/> + <xsl:attribute name="{$att_name}"><xsl:value-of select="concat('rgb(', $components/item[1], ',', $components/item[2], ',', $components/item[3], ')')"/></xsl:attribute> + <xsl:attribute name="{$att_name}-opacity"><xsl:value-of select="$components/item[4]"/></xsl:attribute> + </xsl:template> + <!-- ============== --> <!-- END: svg_update --> <!-- ============== --> <!-- image with svg and emf --> @@ -10514,11 +10554,13 @@ <!-- ===================================== --> <!-- Update xml --> <!-- ===================================== --> <!-- =========================================================================== --> - <!-- STEP1: Re-order elements in 'preface', 'sections' based on @displayorder --> + <!-- STEP1: --> + <!-- - Re-order elements in 'preface', 'sections' based on @displayorder --> + <!-- - Ignore 'span' without style --> <!-- =========================================================================== --> <xsl:template match="@*|node()" mode="update_xml_step1"> <xsl:copy> <xsl:apply-templates select="@*|node()" mode="update_xml_step1"/> </xsl:copy> @@ -10597,10 +10639,11 @@ <xsl:apply-templates select="." mode="update_xml_step1"/> </xsl:for-each> </xsl:copy> </xsl:template> - <xsl:template match="*[local-name() = 'span'][@style]" mode="update_xml_step1" priority="2"> + <!-- Example with 'class': <span class="stdpublisher">ISO</span> <span class="stddocNumber">10303</span>-<span class="stddocPartNumber">1</span>:<span class="stdyear">1994</span> --> + <xsl:template match="*[local-name() = 'span'][@style or @class = 'stdpublisher' or @class = 'stddocNumber' or @class = 'stddocPartNumber' or @class = 'stdyear']" mode="update_xml_step1" priority="2"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates mode="update_xml_step1"/> </xsl:copy> </xsl:template> \ No newline at end of file