lib/isodoc/iho/iho.specification.xsl in metanorma-iho-0.6.13 vs lib/isodoc/iho/iho.specification.xsl in metanorma-iho-0.7.0

- old
+ new

@@ -333,34 +333,37 @@ <!-- =========================== --> <!-- =========================== --> <!-- Document Pages --> - <fo:page-sequence master-reference="document" initial-page-number="1" format="1" force-page-count="no-force"> - <fo:static-content flow-name="xsl-footnote-separator"> - <fo:block> - <fo:leader leader-pattern="rule" leader-length="30%"/> - </fo:block> - </fo:static-content> - <xsl:call-template name="insertHeaderFooter"/> - <fo:flow flow-name="xsl-region-body"> - <fo:block-container> + <xsl:if test="/iho:iho-standard/iho:sections/*"> - <!-- <fo:block font-size="16pt" font-weight="bold" margin-bottom="18pt" role="H1"><xsl:value-of select="$title-en"/></fo:block> --> + <fo:page-sequence master-reference="document" initial-page-number="1" format="1" force-page-count="no-force"> + <fo:static-content flow-name="xsl-footnote-separator"> + <fo:block> + <fo:leader leader-pattern="rule" leader-length="30%"/> + </fo:block> + </fo:static-content> + <xsl:call-template name="insertHeaderFooter"/> + <fo:flow flow-name="xsl-region-body"> + <fo:block-container> - <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']"/> - <!-- Normative references --> - <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']"/> - <!-- Terms and definitions --> - <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='terms']"/> - <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='definitions']"/> - <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name() != 'terms' and local-name() != 'definitions' and not(@type='scope')]"/> + <!-- <fo:block font-size="16pt" font-weight="bold" margin-bottom="18pt" role="H1"><xsl:value-of select="$title-en"/></fo:block> --> - </fo:block-container> - </fo:flow> - </fo:page-sequence> + <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']"/> + <!-- Normative references --> + <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']"/> + <!-- Terms and definitions --> + <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='terms']"/> + <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='definitions']"/> + <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name() != 'terms' and local-name() != 'definitions' and not(@type='scope')]"/> + </fo:block-container> + </fo:flow> + </fo:page-sequence> + </xsl:if> + <xsl:if test="/iho:iho-standard/iho:annex"> <fo:page-sequence master-reference="document"> <fo:static-content flow-name="xsl-footnote-separator"> <fo:block> <fo:leader leader-pattern="rule" leader-length="30%"/> @@ -482,10 +485,14 @@ </xsl:if> </xsl:template> + <xsl:template match="*[local-name() = 'strong']" mode="contents_item" priority="2"> + <xsl:apply-templates mode="contents_item"/> + </xsl:template> + <!-- ============================= --> <!-- END CONTENTS --> <!-- ============================= --> <!-- ============================= --> @@ -3441,10 +3448,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> @@ -4665,10 +4676,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' --> @@ -5060,11 +5088,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"/> @@ -5075,11 +5103,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"/> @@ -5142,11 +5170,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"/> @@ -5154,11 +5182,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> @@ -5824,16 +5852,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> <fo:inline xsl:use-attribute-sets="note-name-style"> <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' --> @@ -6333,10 +6355,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 --> @@ -6975,11 +7022,11 @@ <xsl:variable name="sourcecode_attributes"> <xsl:element name="sourcecode_attributes" use-attribute-sets="sourcecode-style"> <xsl:variable name="_font-size"> - 10 + 9.5 <!-- 9 --> <!-- <xsl:if test="$namespace = 'ieee'"> <xsl:if test="$current_template = 'standard'">8</xsl:if> </xsl:if> --> @@ -9245,11 +9292,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> @@ -9328,10 +9377,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