lib/isodoc/itu/itu.resolution.xsl in metanorma-itu-2.2.7 vs lib/isodoc/itu/itu.resolution.xsl in metanorma-itu-2.2.8

- old
+ new

@@ -2885,10 +2885,11 @@ </xsl:attribute-set> <xsl:attribute-set name="term-name-style"> <xsl:attribute name="keep-with-next">always</xsl:attribute> <xsl:attribute name="font-weight">bold</xsl:attribute> + </xsl:attribute-set> <xsl:attribute-set name="figure-block-style"> <xsl:attribute name="margin-bottom">6pt</xsl:attribute> @@ -3863,11 +3864,11 @@ <xsl:choose> <xsl:when test="not(*[local-name()='tbody']) and *[local-name()='thead']"> <xsl:apply-templates select="*[local-name()='thead']" mode="process_tbody"/> </xsl:when> <xsl:otherwise> - <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer and note that renders separaterely --> + <xsl:apply-templates select="node()[not(local-name() = 'name') and not(local-name() = 'note') and not(local-name() = 'dl') and not(local-name() = 'thead') and not(local-name() = 'tfoot')]"/> <!-- process all table' elements, except name, header, footer, note and dl which render separaterely --> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> @@ -4366,11 +4367,11 @@ <xsl:template name="insertTableFooterInSeparateTable"> <xsl:param name="table_attributes"/> <xsl:param name="colwidths"/> <xsl:param name="colgroup"/> - <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/> + <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/> <xsl:variable name="isNoteOrFnExistShowAfterTable"> </xsl:variable> @@ -4453,10 +4454,11 @@ <!-- for BSI (not PAS) display Notes before footnotes --> <!-- except gb and bsi --> + <xsl:apply-templates select="../*[local-name()='dl']"/> <xsl:apply-templates select="../*[local-name()='note']"/> <xsl:variable name="isDisplayRowSeparator"> </xsl:variable> @@ -4578,11 +4580,11 @@ </xsl:template> <!-- process_table-if --> <!-- ===================== --> <!-- Table's row processing --> <!-- ===================== --> - <!-- row in table header (thead) --> + <!-- row in table header (thead) thead/tr --> <xsl:template match="*[local-name()='thead']/*[local-name()='tr']" priority="2"> <fo:table-row xsl:use-attribute-sets="table-header-row-style"> <xsl:call-template name="setBordersTableArray"/> @@ -4616,11 +4618,11 @@ <xsl:attribute name="border-bottom"><xsl:value-of select="$table-border"/></xsl:attribute> </xsl:otherwise> </xsl:choose> </xsl:template> - <!-- row in table footer (tfoot) --> + <!-- row in table footer (tfoot), tfoot/tr --> <xsl:template match="*[local-name()='tfoot']/*[local-name()='tr']" priority="2"> <fo:table-row xsl:use-attribute-sets="table-footer-row-style"> <xsl:call-template name="setTableRowAttributes"/> <xsl:apply-templates/> @@ -5125,10 +5127,12 @@ <xsl:variable name="isAdded" select="@added"/> <xsl:variable name="isDeleted" select="@deleted"/> <!-- <dl><xsl:copy-of select="."/></dl> --> <fo:block-container> + <xsl:call-template name="setBlockSpanAll"/> + <xsl:if test="not(ancestor::*[local-name() = 'quote'])"> <xsl:attribute name="margin-left">0mm</xsl:attribute> </xsl:if> <xsl:if test="parent::*[local-name() = 'note']"> @@ -7203,17 +7207,21 @@ </fo:block> <xsl:apply-templates select="node()[not(local-name()='name')]"/> </xsl:template> <xsl:template match="*[local-name() = 'callout']"> - <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link> + <xsl:choose> + <xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates/>&gt;</xsl:when> + <xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates/>&gt;</fo:basic-link></xsl:otherwise> + </xsl:choose> </xsl:template> <xsl:template match="*[local-name() = 'annotation']"> <xsl:variable name="annotation-id" select="@id"/> <xsl:variable name="callout" select="//*[@target = $annotation-id]/text()"/> <fo:block id="{$annotation-id}" white-space="nowrap"> + <fo:inline> <xsl:apply-templates> <xsl:with-param name="callout" select="concat('&lt;', $callout, '&gt; ')"/> </xsl:apply-templates> </fo:inline> @@ -7314,19 +7322,25 @@ </xsl:template> <!-- ====== --> <!-- ====== --> + <xsl:template name="setBlockSpanAll"> + <xsl:if test="@columns = 1 or (local-name() = 'p' and *[@columns = 1])"><xsl:attribute name="span">all</xsl:attribute></xsl:if> + </xsl:template> + <!-- ====== --> <!-- note --> <!-- termnote --> <!-- ====== --> <xsl:template match="*[local-name() = 'note']" name="note"> <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style"> + <xsl:call-template name="setBlockSpanAll"/> + <fo:block-container margin-left="0mm" margin-right="0mm"> <fo:block> <xsl:if test="ancestor::itu:figure"> @@ -7377,10 +7391,12 @@ </xsl:template> <xsl:template match="*[local-name() = 'termnote']"> <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style"> + <xsl:call-template name="setBlockSpanAll"/> + <fo:inline xsl:use-attribute-sets="termnote-name-style"> <xsl:if test="not(*[local-name() = 'name']/following-sibling::node()[1][self::text()][normalize-space()=''])"> <xsl:attribute name="padding-right">1mm</xsl:attribute> </xsl:if> @@ -9290,10 +9306,13 @@ <!-- ====== --> <!-- termexample --> <!-- ====== --> <xsl:template match="*[local-name() = 'termexample']"> <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style"> + + <xsl:call-template name="setBlockSpanAll"/> + <xsl:apply-templates select="*[local-name()='name']"/> <xsl:apply-templates select="node()[not(local-name() = 'name')]"/> </fo:block> </xsl:template> @@ -9341,10 +9360,12 @@ --> <xsl:template match="*[local-name() = 'example']"> <fo:block-container id="{@id}" xsl:use-attribute-sets="example-style"> + <xsl:call-template name="setBlockSpanAll"/> + <xsl:variable name="fo_element"> <xsl:if test=".//*[local-name() = 'table'] or .//*[local-name() = 'dl'] or *[not(local-name() = 'name')][1][local-name() = 'sourcecode']">block</xsl:if> block </xsl:variable> @@ -9368,10 +9389,39 @@ </xsl:apply-templates> </fo:block-container> </fo:block-container> </xsl:when> <!-- end block --> + <xsl:when test="contains(normalize-space($fo_element), 'list')"> + + <xsl:variable name="provisional_distance_between_starts"> + 7 + </xsl:variable> + <xsl:variable name="indent"> + 0 + </xsl:variable> + + <fo:list-block provisional-distance-between-starts="{$provisional_distance_between_starts}mm"> + <fo:list-item> + <fo:list-item-label start-indent="{$indent}mm" end-indent="label-end()"> + <fo:block> + <xsl:apply-templates select="*[local-name()='name']"> + <xsl:with-param name="fo_element">block</xsl:with-param> + </xsl:apply-templates> + </fo:block> + </fo:list-item-label> + <fo:list-item-body start-indent="body-start()"> + <fo:block> + <xsl:apply-templates select="node()[not(local-name() = 'name')]"> + <xsl:with-param name="fo_element" select="$fo_element"/> + </xsl:apply-templates> + </fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + </xsl:when> <!-- end list --> + <xsl:otherwise> <!-- inline --> <!-- display 'EXAMPLE' and first element in the same line --> <fo:block> <xsl:apply-templates select="*[local-name()='name']"> @@ -9443,10 +9493,15 @@ <xsl:apply-templates/> </fo:block> </fo:block-container> </xsl:when> + <xsl:when test="starts-with(normalize-space($element), 'list')"> + <fo:block xsl:use-attribute-sets="example-p-style"> + <xsl:apply-templates/> + </fo:block> + </xsl:when> <xsl:otherwise> <fo:inline xsl:use-attribute-sets="example-p-style"> <xsl:apply-templates/> </fo:inline> </xsl:otherwise> @@ -9560,10 +9615,13 @@ <!-- source --> <!-- author --> <!-- ====== --> <xsl:template match="*[local-name() = 'quote']"> <fo:block-container margin-left="0mm"> + + <xsl:call-template name="setBlockSpanAll"/> + <xsl:if test="parent::*[local-name() = 'note']"> <xsl:if test="not(ancestor::*[local-name() = 'table'])"> <xsl:attribute name="margin-left">5mm</xsl:attribute> </xsl:if> </xsl:if> @@ -9852,10 +9910,12 @@ <xsl:template match="*[local-name() = 'clause']"> <fo:block> <xsl:call-template name="setId"/> + <xsl:call-template name="setBlockSpanAll"/> + <xsl:if test="@inline-header='true'"> <xsl:attribute name="text-align">justify</xsl:attribute> </xsl:if> <xsl:apply-templates/> @@ -9870,10 +9930,12 @@ <xsl:template match="*[local-name() = 'annex']"> <fo:block break-after="page"/> <fo:block id="{@id}"> + <xsl:call-template name="setBlockSpanAll"/> + </fo:block> <xsl:apply-templates/> </xsl:template> <xsl:template match="*[local-name() = 'review']"> <!-- 'review' will be processed in mn2pdf/review.xsl --> @@ -10850,10 +10912,12 @@ <xsl:template match="*[local-name() = 'admonition']"> <!-- text in the box --> <fo:block-container id="{@id}" xsl:use-attribute-sets="admonition-style"> + <xsl:call-template name="setBlockSpanAll"/> + <fo:block-container xsl:use-attribute-sets="admonition-container-style"> <fo:block xsl:use-attribute-sets="admonition-name-style"> <xsl:call-template name="displayAdmonitionName"/> </fo:block> @@ -11028,10 +11092,20 @@ <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates mode="update_xml_step1"/> </xsl:copy> </xsl:template> + + <!-- remove semantic xml --> + <xsl:template match="*[local-name() = 'metanorma-extension']/*[local-name() = 'metanorma']/*[local-name() = 'source']" mode="update_xml_step1"/> + + <!-- remove image/emf --> + <xsl:template match="*[local-name() = 'image']/*[local-name() = 'emf']" mode="update_xml_step1"/> + + <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_step1"> + <xsl:copy-of select="."/> + </xsl:template> <!-- =========================================================================== --> <!-- END STEP1: Re-order elements in 'preface', 'sections' based on @displayorder --> <!-- =========================================================================== --> <!-- =========================================================================== --> @@ -11049,11 +11123,11 @@ <xsl:variable name="express_reference_separators">_.\</xsl:variable> <xsl:variable name="express_reference_characters" select="concat($upper,$lower,'1234567890',$express_reference_separators)"/> <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable> - <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line"> + <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or ancestor::*[local-name() = 'svg'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line"> <!-- enclose standard's number into tag 'keep-together_within-line' --> <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable> <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable> <xsl:variable name="text__" select="java:replaceAll(java:java.lang.String.new(.), $regex_standard_reference, concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/> @@ -11123,10 +11197,14 @@ <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise> </xsl:choose> </xsl:template> + <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line"> + <xsl:copy-of select="."/> + </xsl:template> + <xsl:template name="replace_text_tags"> <xsl:param name="tag_open"/> <xsl:param name="tag_close"/> <xsl:param name="text"/> <xsl:choose> @@ -11147,9 +11225,197 @@ <xsl:otherwise><xsl:value-of select="$text"/></xsl:otherwise> </xsl:choose> </xsl:template> <!-- ===================================== --> <!-- END XML UPDATE STEP: enclose standard's name into tag 'keep-together_within-line' --> + <!-- ===================================== --> + + <!-- ===================================== --> + <!-- ===================================== --> + <!-- Make linear XML (need for landscape orientation) --> + <!-- ===================================== --> + <!-- ===================================== --> + <xsl:template match="@*|node()" mode="linear_xml"> + <xsl:copy> + <xsl:apply-templates select="@*|node()" mode="linear_xml"/> + </xsl:copy> + </xsl:template> + + <xsl:template match="processing-instruction()" mode="linear_xml"> + <xsl:copy-of select="."/> + </xsl:template> + + <!-- From: + <clause> + <title>...</title> + <p>...</p> + </clause> + To: + <clause/> + <title>...</title> + <p>...</p> + --> + <xsl:template match="*[local-name() = 'foreword'] | *[local-name() = 'foreword']//*[local-name() = 'clause'] | *[local-name() = 'preface']//*[local-name() = 'clause'][not(@type = 'corrigenda') and not(@type = 'policy') and not(@type = 'related-refs')] | *[local-name() = 'introduction'] | *[local-name() = 'introduction']//*[local-name() = 'clause'] | *[local-name() = 'sections']//*[local-name() = 'clause'] | *[local-name() = 'annex'] | *[local-name() = 'annex']//*[local-name() = 'clause'] | *[local-name() = 'references'][not(@hidden = 'true')] | *[local-name() = 'bibliography']/*[local-name() = 'clause'] | *[local-name() = 'colophon'] | *[local-name() = 'colophon']//*[local-name() = 'clause'] | *[local-name()='sections']//*[local-name()='terms'] | *[local-name()='sections']//*[local-name()='definitions'] | *[local-name()='annex']//*[local-name()='definitions']" mode="linear_xml" name="clause_linear"> + + <xsl:copy> + <xsl:apply-templates select="@*" mode="linear_xml"/> + + <xsl:attribute name="keep-with-next">always</xsl:attribute> + + <xsl:if test="local-name() = 'foreword' or local-name() = 'introduction' or local-name(..) = 'preface' or local-name(..) = 'sections' or (local-name() = 'references' and parent::*[local-name() = 'bibliography']) or (local-name() = 'clause' and parent::*[local-name() = 'bibliography']) or local-name() = 'annex' or local-name(..) = 'annex' or local-name(..) = 'colophon'"> + <xsl:attribute name="mainsection">true</xsl:attribute> + </xsl:if> + </xsl:copy> + + <xsl:apply-templates mode="linear_xml"/> + </xsl:template> + + <xsl:template match="*[local-name() = 'term']" mode="linear_xml" priority="2"> + <xsl:copy> + <xsl:apply-templates select="@*" mode="linear_xml"/> + <xsl:attribute name="keep-with-next">always</xsl:attribute> + <xsl:variable name="level"> + <xsl:call-template name="getLevel"/> + </xsl:variable> + <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute> + <xsl:attribute name="ancestor">sections</xsl:attribute> + <xsl:apply-templates select="node()[not(local-name() = 'term')]" mode="linear_xml"/> + </xsl:copy> + <xsl:apply-templates select="*[local-name() = 'term']" mode="linear_xml"/> + </xsl:template> + + <xsl:template match="*[local-name() = 'introduction']//*[local-name() = 'title'] | *[local-name() = 'foreword']//*[local-name() = 'title'] | *[local-name() = 'sections']//*[local-name() = 'title'] | *[local-name() = 'annex']//*[local-name() = 'title'] | *[local-name() = 'bibliography']/*[local-name() = 'clause']/*[local-name() = 'title'] | *[local-name() = 'references']/*[local-name() = 'title'] | *[local-name() = 'colophon']//*[local-name() = 'title']" mode="linear_xml" priority="2"> + <xsl:copy> + <xsl:apply-templates select="@*" mode="linear_xml"/> + + <xsl:attribute name="keep-with-next">always</xsl:attribute> + + <xsl:variable name="level"> + <xsl:call-template name="getLevel"/> + </xsl:variable> + <xsl:attribute name="depth"><xsl:value-of select="$level"/></xsl:attribute> + + <xsl:if test="parent::*[local-name() = 'annex']"> + <xsl:attribute name="depth">1</xsl:attribute> + </xsl:if> + + <xsl:if test="../@inline-header = 'true' and following-sibling::*[1][local-name() = 'p']"> + <xsl:copy-of select="../@inline-header"/> + </xsl:if> + + <xsl:attribute name="ancestor"> + <xsl:choose> + <xsl:when test="ancestor::*[local-name() = 'foreword']">foreword</xsl:when> + <xsl:when test="ancestor::*[local-name() = 'introduction']">introduction</xsl:when> + <xsl:when test="ancestor::*[local-name() = 'sections']">sections</xsl:when> + <xsl:when test="ancestor::*[local-name() = 'annex']">annex</xsl:when> + <xsl:when test="ancestor::*[local-name() = 'bibliography']">bibliography</xsl:when> + </xsl:choose> + </xsl:attribute> + + <xsl:apply-templates mode="linear_xml"/> + </xsl:copy> + </xsl:template> + + <!-- add @to = figure, table, clause --> + <!-- add @depth = from --> + <xsl:template match="*[local-name() = 'xref']" mode="linear_xml"> + <xsl:copy> + <xsl:apply-templates select="@*" mode="linear_xml"/> + <xsl:variable name="target" select="@target"/> + <xsl:attribute name="to"> + <xsl:value-of select="local-name(//*[@id = current()/@target][1])"/> + </xsl:attribute> + <xsl:attribute name="depth"> + <xsl:value-of select="//*[@id = current()/@target][1]/*[local-name() = 'title']/@depth"/> + </xsl:attribute> + <xsl:apply-templates select="node()" mode="linear_xml"/> + </xsl:copy> + </xsl:template> + + <xsl:template match="*[not(ancestor::*[local-name() = 'sourcecode'])]/*[local-name() = 'p' or local-name() = 'strong' or local-name() = 'em']/text()" mode="linear_xml"> + <xsl:choose> + <xsl:when test="contains(., $non_breaking_hyphen)"> + <xsl:call-template name="replaceChar"> + <xsl:with-param name="text" select="."/> + <xsl:with-param name="replace" select="$non_breaking_hyphen"/> + <xsl:with-param name="by" select="'-'"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template name="replaceChar"> + <xsl:param name="text"/> + <xsl:param name="replace"/> + <xsl:param name="by"/> + <xsl:choose> + <xsl:when test="$text = '' or $replace = '' or not($replace)"> + <xsl:value-of select="$text"/> + </xsl:when> + <xsl:when test="contains($text, $replace)"> + <xsl:value-of select="substring-before($text,$replace)"/> + <xsl:element name="inlineChar" namespace="https://www.metanorma.org/ns/jis"><xsl:value-of select="$by"/></xsl:element> + <xsl:call-template name="replaceChar"> + <xsl:with-param name="text" select="substring-after($text,$replace)"/> + <xsl:with-param name="replace" select="$replace"/> + <xsl:with-param name="by" select="$by"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$text"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template match="*[local-name() = 'inlineChar']"> + <fo:inline><xsl:value-of select="."/></fo:inline> + </xsl:template> + + <!-- change @reference to actual value, and add skip_footnote_body="true" for repeatable (2nd, 3rd, ...) --> + <!-- + <fn reference="1"> + <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p> + </fn> + --> + <xsl:template match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure')] and not(ancestor::*[local-name() = 'name']))]" mode="linear_xml" name="linear_xml_fn"> + <xsl:variable name="p_fn_"> + <xsl:call-template name="get_fn_list"/> + </xsl:variable> + <xsl:variable name="p_fn" select="xalan:nodeset($p_fn_)"/> + <xsl:variable name="gen_id" select="generate-id(.)"/> + <xsl:variable name="lang" select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='bibdata']//*[local-name()='language'][@current = 'true']"/> + <xsl:variable name="reference" select="@reference"/> + <!-- fn sequence number in document --> + <xsl:variable name="current_fn_number" select="count($p_fn//fn[@reference = $reference]/preceding-sibling::fn) + 1"/> + + <xsl:copy> + <xsl:apply-templates select="@*" mode="linear_xml"/> + <!-- put actual reference number --> + <xsl:attribute name="current_fn_number"> + <xsl:value-of select="$current_fn_number"/> + </xsl:attribute> + <xsl:attribute name="skip_footnote_body"> <!-- false for repeatable footnote --> + <xsl:value-of select="not($p_fn//fn[@gen_id = $gen_id] and (1 = 1))"/> + </xsl:attribute> + <xsl:apply-templates select="node()" mode="linear_xml"/> + </xsl:copy> + </xsl:template> + + <xsl:template match="*[local-name() = 'p'][@type = 'section-title']" priority="3" mode="linear_xml"> + <xsl:copy> + <xsl:apply-templates select="@*" mode="linear_xml"/> + <xsl:if test="@depth = '1'"> + <xsl:attribute name="mainsection">true</xsl:attribute> + </xsl:if> + <xsl:apply-templates select="node()" mode="linear_xml"/> + </xsl:copy> + </xsl:template> + <!-- ===================================== --> + <!-- ===================================== --> + <!-- END: Make linear XML (need for landscape orientation) --> + <!-- ===================================== --> <!-- ===================================== --> <!-- for correct rendering combining chars --> <xsl:template match="*[local-name() = 'lang_none']"> <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline> \ No newline at end of file