lib/isodoc/mpfa/mpfd.guidelines.xsl in metanorma-mpfa-0.5.12 vs lib/isodoc/mpfa/mpfd.guidelines.xsl in metanorma-mpfa-0.5.13

- old
+ new

@@ -1279,204 +1279,238 @@ </xsl:template><xsl:template match="*[local-name()='td']//text() | *[local-name()='th']//text() | *[local-name()='dt']//text() | *[local-name()='dd']//text()" priority="1"> <!-- <xsl:call-template name="add-zero-spaces"/> --> <xsl:call-template name="add-zero-spaces-java"/> </xsl:template><xsl:template match="*[local-name()='table']" name="table"> - <xsl:variable name="simple-table"> - <xsl:call-template name="getSimpleTable"/> - </xsl:variable> + <xsl:variable name="table"> + <xsl:variable name="simple-table"> + <xsl:call-template name="getSimpleTable"/> + </xsl:variable> - - - - <!-- <xsl:if test="$namespace = 'bipm'"> - <fo:block>&#xA0;</fo:block> - </xsl:if> --> - - <!-- $namespace = 'iso' or --> - - <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/> - - - - <xsl:call-template name="fn_name_display"/> - - - <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/> - - <!-- <xsl:variable name="cols-count"> - <xsl:choose> - <xsl:when test="*[local-name()='thead']"> - <xsl:call-template name="calculate-columns-numbers"> - <xsl:with-param name="table-row" select="*[local-name()='thead']/*[local-name()='tr'][1]"/> - </xsl:call-template> - </xsl:when> - <xsl:otherwise> - <xsl:call-template name="calculate-columns-numbers"> - <xsl:with-param name="table-row" select="*[local-name()='tbody']/*[local-name()='tr'][1]"/> - </xsl:call-template> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> --> - <!-- cols-count=<xsl:copy-of select="$cols-count"/> --> - <!-- cols-count2=<xsl:copy-of select="$cols-count2"/> --> - - - - <xsl:variable name="colwidths"> - <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])"> - <xsl:call-template name="calculate-column-widths"> - <xsl:with-param name="cols-count" select="$cols-count"/> - <xsl:with-param name="table" select="$simple-table"/> - </xsl:call-template> - </xsl:if> - </xsl:variable> - <!-- colwidths=<xsl:copy-of select="$colwidths"/> --> - - <!-- <xsl:variable name="colwidths2"> - <xsl:call-template name="calculate-column-widths"> - <xsl:with-param name="cols-count" select="$cols-count"/> - </xsl:call-template> - </xsl:variable> --> - - <!-- cols-count=<xsl:copy-of select="$cols-count"/> - colwidthsNew=<xsl:copy-of select="$colwidths"/> - colwidthsOld=<xsl:copy-of select="$colwidths2"/>z --> - - <xsl:variable name="margin-left"> - <xsl:choose> - <xsl:when test="sum(xalan:nodeset($colwidths)//column) &gt; 75">15</xsl:when> - <xsl:otherwise>0</xsl:otherwise> - </xsl:choose> - </xsl:variable> - - <fo:block-container margin-left="-{$margin-left}mm" margin-right="-{$margin-left}mm"> - - - + <!-- <xsl:if test="$namespace = 'bipm'"> + <fo:block>&#xA0;</fo:block> + </xsl:if> --> - + <!-- $namespace = 'iso' or --> + <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/> + + <xsl:call-template name="fn_name_display"/> - <xsl:attribute name="space-after">12pt</xsl:attribute> - <xsl:attribute name="margin-left">0mm</xsl:attribute> - <xsl:attribute name="margin-right">0mm</xsl:attribute> + + <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/> + <!-- <xsl:variable name="cols-count"> + <xsl:choose> + <xsl:when test="*[local-name()='thead']"> + <xsl:call-template name="calculate-columns-numbers"> + <xsl:with-param name="table-row" select="*[local-name()='thead']/*[local-name()='tr'][1]"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="calculate-columns-numbers"> + <xsl:with-param name="table-row" select="*[local-name()='tbody']/*[local-name()='tr'][1]"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> --> + <!-- cols-count=<xsl:copy-of select="$cols-count"/> --> + <!-- cols-count2=<xsl:copy-of select="$cols-count2"/> --> - <xsl:variable name="table_attributes"> - <attribute name="table-layout">fixed</attribute> - <attribute name="width"> - <xsl:choose> - <xsl:when test="@width"><xsl:value-of select="@width"/></xsl:when> - <xsl:otherwise>100%</xsl:otherwise> - </xsl:choose> - </attribute> - <attribute name="margin-left"><xsl:value-of select="$margin-left"/>mm</attribute> - <attribute name="margin-right"><xsl:value-of select="$margin-left"/>mm</attribute> + + <xsl:variable name="colwidths"> + <xsl:if test="not(*[local-name()='colgroup']/*[local-name()='col'])"> + <xsl:call-template name="calculate-column-widths"> + <xsl:with-param name="cols-count" select="$cols-count"/> + <xsl:with-param name="table" select="$simple-table"/> + </xsl:call-template> + </xsl:if> + </xsl:variable> + <!-- colwidths=<xsl:copy-of select="$colwidths"/> --> + + <!-- <xsl:variable name="colwidths2"> + <xsl:call-template name="calculate-column-widths"> + <xsl:with-param name="cols-count" select="$cols-count"/> + </xsl:call-template> + </xsl:variable> --> + + <!-- cols-count=<xsl:copy-of select="$cols-count"/> + colwidthsNew=<xsl:copy-of select="$colwidths"/> + colwidthsOld=<xsl:copy-of select="$colwidths2"/>z --> + + <xsl:variable name="margin-left"> + <xsl:choose> + <xsl:when test="sum(xalan:nodeset($colwidths)//column) &gt; 75">15</xsl:when> + <xsl:otherwise>0</xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <fo:block-container margin-left="-{$margin-left}mm" margin-right="-{$margin-left}mm"> + + + - - - + - <attribute name="border-top">2pt solid black</attribute> - <attribute name="border-bottom">2pt solid black</attribute> - - </xsl:variable> - - - <fo:table id="{@id}" table-omit-footer-at-break="true"> - <xsl:for-each select="xalan:nodeset($table_attributes)/attribute"> - <xsl:attribute name="{@name}"> - <xsl:value-of select="."/> - </xsl:attribute> - </xsl:for-each> + <xsl:attribute name="space-after">12pt</xsl:attribute> + <xsl:attribute name="margin-left">0mm</xsl:attribute> + <xsl:attribute name="margin-right">0mm</xsl:attribute> - <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or .//*[local-name()='fn'][local-name(..) != 'name']"/> - <xsl:if test="$isNoteOrFnExist = 'true'"> - <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer --> - </xsl:if> - <xsl:choose> - <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']"> - <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']"> - <fo:table-column column-width="{@width}"/> - </xsl:for-each> - </xsl:when> - <xsl:otherwise> - <xsl:for-each select="xalan:nodeset($colwidths)//column"> - <xsl:choose> - <xsl:when test=". = 1 or . = 0"> - <fo:table-column column-width="proportional-column-width(2)"/> - </xsl:when> - <xsl:otherwise> - <fo:table-column column-width="proportional-column-width({.})"/> - </xsl:otherwise> - </xsl:choose> - </xsl:for-each> - </xsl:otherwise> - </xsl:choose> - <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/> - </xsl:otherwise> - </xsl:choose> + <xsl:variable name="table_width"> + <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) --> + 100% + + + </xsl:variable> - </fo:table> - - <xsl:variable name="colgroup" select="*[local-name()='colgroup']"/> - <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody --> - <xsl:call-template name="insertTableFooterInSeparateTable"> - <xsl:with-param name="table_attributes" select="$table_attributes"/> - <xsl:with-param name="colwidths" select="$colwidths"/> - <xsl:with-param name="colgroup" select="$colgroup"/> - </xsl:call-template> - </xsl:for-each> - - <!-- insert footer as table --> - <!-- <fo:table> - <xsl:for-each select="xalan::nodeset($table_attributes)/attribute"> - <xsl:attribute name="{@name}"> - <xsl:value-of select="."/> - </xsl:attribute> - </xsl:for-each> + <xsl:variable name="table_attributes"> + <attribute name="table-layout">fixed</attribute> + <attribute name="width"><xsl:value-of select="normalize-space($table_width)"/></attribute> + <attribute name="margin-left"><xsl:value-of select="$margin-left"/>mm</attribute> + <attribute name="margin-right"><xsl:value-of select="$margin-left"/>mm</attribute> + + + + + + + + + + <attribute name="border-top">2pt solid black</attribute> + <attribute name="border-bottom">2pt solid black</attribute> + + + </xsl:variable> - <xsl:for-each select="xalan:nodeset($colwidths)//column"> + + <fo:table id="{@id}" table-omit-footer-at-break="true"> + + <xsl:for-each select="xalan:nodeset($table_attributes)/attribute"> + <xsl:attribute name="{@name}"> + <xsl:value-of select="."/> + </xsl:attribute> + </xsl:for-each> + + <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or .//*[local-name()='fn'][local-name(..) != 'name']"/> + <xsl:if test="$isNoteOrFnExist = 'true'"> + <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer --> + </xsl:if> + <xsl:choose> - <xsl:when test=". = 1 or . = 0"> - <fo:table-column column-width="proportional-column-width(2)"/> + <xsl:when test="*[local-name()='colgroup']/*[local-name()='col']"> + <xsl:for-each select="*[local-name()='colgroup']/*[local-name()='col']"> + <fo:table-column column-width="{@width}"/> + </xsl:for-each> </xsl:when> <xsl:otherwise> - <fo:table-column column-width="proportional-column-width({.})"/> + <xsl:for-each select="xalan:nodeset($colwidths)//column"> + <xsl:choose> + <xsl:when test=". = 1 or . = 0"> + <fo:table-column column-width="proportional-column-width(2)"/> + </xsl:when> + <xsl:otherwise> + <fo:table-column column-width="proportional-column-width({.})"/> + </xsl:otherwise> + </xsl:choose> + </xsl:for-each> </xsl:otherwise> </xsl:choose> + + <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/> + </xsl:otherwise> + </xsl:choose> + + </fo:table> + + <xsl:variable name="colgroup" select="*[local-name()='colgroup']"/> + <xsl:for-each select="*[local-name()='tbody']"><!-- select context to tbody --> + <xsl:call-template name="insertTableFooterInSeparateTable"> + <xsl:with-param name="table_attributes" select="$table_attributes"/> + <xsl:with-param name="colwidths" select="$colwidths"/> + <xsl:with-param name="colgroup" select="$colgroup"/> + </xsl:call-template> </xsl:for-each> - </fo:table>--> - - - - - - </fo:block-container> + + <!-- insert footer as table --> + <!-- <fo:table> + <xsl:for-each select="xalan::nodeset($table_attributes)/attribute"> + <xsl:attribute name="{@name}"> + <xsl:value-of select="."/> + </xsl:attribute> + </xsl:for-each> + + <xsl:for-each select="xalan:nodeset($colwidths)//column"> + <xsl:choose> + <xsl:when test=". = 1 or . = 0"> + <fo:table-column column-width="proportional-column-width(2)"/> + </xsl:when> + <xsl:otherwise> + <fo:table-column column-width="proportional-column-width({.})"/> + </xsl:otherwise> + </xsl:choose> + </xsl:for-each> + </fo:table>--> + + + + + + </fo:block-container> + </xsl:variable> + + + + <xsl:choose> + <xsl:when test="@width"> + + <!-- centered table when table name is centered (see table-name-style) --> + + <fo:table table-layout="fixed" width="100%"> + <fo:table-column column-width="proportional-column-width(1)"/> + <fo:table-column column-width="{@width}"/> + <fo:table-column column-width="proportional-column-width(1)"/> + <fo:table-body> + <fo:table-row> + <fo:table-cell column-number="2"> + <fo:block><xsl:copy-of select="$table"/></fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + + + + + </xsl:when> + <xsl:otherwise> + <xsl:copy-of select="$table"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template><xsl:template match="*[local-name()='table']/*[local-name() = 'name']"/><xsl:template match="*[local-name()='table']/*[local-name() = 'name']" mode="presentation"> <xsl:if test="normalize-space() != ''"> <fo:block xsl:use-attribute-sets="table-name-style"> @@ -2286,11 +2320,11 @@ <xsl:call-template name="calculate-column-widths"> <xsl:with-param name="cols-count" select="2"/> <xsl:with-param name="table" select="$html-table"/> </xsl:call-template> </xsl:variable> - <!-- colwidths=<xsl:value-of select="$colwidths"/> --> + <!-- colwidths=<xsl:copy-of select="$colwidths"/> --> <xsl:variable name="maxlength_dt"> <xsl:call-template name="getMaxLength_dt"/> </xsl:variable> <xsl:call-template name="setColumnWidth_dl"> <xsl:with-param name="colwidths" select="$colwidths"/> @@ -2315,18 +2349,27 @@ <fo:table-column column-width="50%"/> <fo:table-column column-width="50%"/> </xsl:when> <xsl:otherwise> <xsl:choose> + <!-- to set width check most wide chars like `W` --> <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 2"> <!-- if dt contains short text like t90, a, etc --> - <fo:table-column column-width="5%"/> - <fo:table-column column-width="95%"/> + <fo:table-column column-width="7%"/> + <fo:table-column column-width="93%"/> </xsl:when> - <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 5"> <!-- if dt contains short text like t90, a, etc --> - <fo:table-column column-width="10%"/> - <fo:table-column column-width="90%"/> + <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 5"> <!-- if dt contains short text like ABC, etc --> + <fo:table-column column-width="15%"/> + <fo:table-column column-width="85%"/> </xsl:when> + <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 7"> <!-- if dt contains short text like ABCDEF, etc --> + <fo:table-column column-width="20%"/> + <fo:table-column column-width="80%"/> + </xsl:when> + <xsl:when test="normalize-space($maxlength_dt) != '' and number($maxlength_dt) &lt;= 10"> <!-- if dt contains short text like ABCDEFEF, etc --> + <fo:table-column column-width="25%"/> + <fo:table-column column-width="75%"/> + </xsl:when> <!-- <xsl:when test="xalan:nodeset($colwidths)/column[1] div xalan:nodeset($colwidths)/column[2] &gt; 1.7"> <fo:table-column column-width="60%"/> <fo:table-column column-width="40%"/> </xsl:when> --> <xsl:when test="xalan:nodeset($colwidths)/column[1] div xalan:nodeset($colwidths)/column[2] &gt; 1.3"> @@ -2628,10 +2671,14 @@ </xsl:for-each> </xsl:template><xsl:template name="add-zero-spaces-java"> <xsl:param name="text" select="."/> <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space --> <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| )','$1​')"/> + </xsl:template><xsl:template name="add-zero-spaces-link-java"> + <xsl:param name="text" select="."/> + <!-- add zero-width space (#x200B) after characters: dash, dot, colon, equal, underscore, em dash, thin space --> + <xsl:value-of select="java:replaceAll(java:java.lang.String.new($text),'(-|\.|:|=|_|—| |,)','$1​')"/> </xsl:template><xsl:template name="add-zero-spaces"> <xsl:param name="text" select="."/> <xsl:variable name="zero-space-after-chars">-</xsl:variable> <xsl:variable name="zero-space-after-dot">.</xsl:variable> <xsl:variable name="zero-space-after-colon">:</xsl:variable> @@ -2888,10 +2935,15 @@ </xsl:template><xsl:template match="mathml:mtext" mode="mathml"> <xsl:copy> <!-- replace start and end spaces to non-break space --> <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'(^ )|( $)',' ')"/> </xsl:copy> + </xsl:template><xsl:template match="mathml:mi[. = ',' and not(following-sibling::*[1][local-name() = 'mtext' and text() = ' '])]" mode="mathml"> + <xsl:copy> + <xsl:apply-templates select="@*|node()" mode="mathml"/> + </xsl:copy> + <mathml:mspace width="0.5ex"/> </xsl:template><xsl:template match="*[local-name()='localityStack']"/><xsl:template match="*[local-name()='link']" name="link"> <xsl:variable name="target"> <xsl:choose> <xsl:when test="starts-with(normalize-space(@target), 'mailto:')"> <xsl:value-of select="normalize-space(substring-after(@target, 'mailto:'))"/> @@ -2909,11 +2961,14 @@ </xsl:when> <xsl:otherwise> <fo:basic-link external-destination="{@target}" fox:alt-text="{@target}"> <xsl:choose> <xsl:when test="normalize-space(.) = ''"> - <xsl:value-of select="$target"/> + <!-- <xsl:value-of select="$target"/> --> + <xsl:call-template name="add-zero-spaces-link-java"> + <xsl:with-param name="text" select="$target"/> + </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> @@ -3380,10 +3435,12 @@ </xsl:copy> </xsl:template><xsl:template match="*[local-name() = 'em']" mode="contents_item"> <xsl:copy> <xsl:apply-templates mode="contents_item"/> </xsl:copy> + </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="contents_item"> + <xsl:copy-of select="."/> </xsl:template><xsl:template match="*[local-name() = 'br']" mode="contents_item"> <xsl:text> </xsl:text> </xsl:template><xsl:template match="*[local-name()='sourcecode']" name="sourcecode"> <fo:block-container margin-left="0mm"> @@ -3782,15 +3839,17 @@ <xsl:if test="not(ancestor::*[local-name() = 'table'])"> <xsl:attribute name="margin-left">5mm</xsl:attribute> </xsl:if> </xsl:if> + <fo:block-container margin-left="0mm"> <fo:block xsl:use-attribute-sets="quote-style"> <!-- <xsl:apply-templates select=".//*[local-name() = 'p']"/> --> - <xsl:apply-templates select="./*[not(local-name() = 'author') and not(local-name() = 'source')]"/> <!-- process all nested nodes, except author and source --> + + <xsl:apply-templates select="./node()[not(local-name() = 'author') and not(local-name() = 'source')]"/> <!-- process all nested nodes, except author and source --> </fo:block> <xsl:if test="*[local-name() = 'author'] or *[local-name() = 'source']"> <fo:block xsl:use-attribute-sets="quote-source-style"> <!-- — ISO, ISO 7301:2011, Clause 1 --> <xsl:apply-templates select="*[local-name() = 'author']"/> @@ -4194,20 +4253,20 @@ <xsl:param name="sorting" select="'true'"/> <xsl:param name="charAtEnd" select="'.'"/> <xsl:param name="charDelim" select="', '"/> <xsl:choose> <xsl:when test="$sorting = 'true' or $sorting = 'yes'"> - <xsl:for-each select="/*/*[local-name() = 'bibdata']//*[local-name() = 'keyword']"> + <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']//*[local-name() = 'keyword']"> <xsl:sort data-type="text" order="ascending"/> <xsl:call-template name="insertKeyword"> <xsl:with-param name="charAtEnd" select="$charAtEnd"/> <xsl:with-param name="charDelim" select="$charDelim"/> </xsl:call-template> </xsl:for-each> </xsl:when> <xsl:otherwise> - <xsl:for-each select="/*/*[local-name() = 'bibdata']//*[local-name() = 'keyword']"> + <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']//*[local-name() = 'keyword']"> <xsl:call-template name="insertKeyword"> <xsl:with-param name="charAtEnd" select="$charAtEnd"/> <xsl:with-param name="charDelim" select="$charDelim"/> </xsl:call-template> </xsl:for-each> @@ -4220,10 +4279,13 @@ <xsl:choose> <xsl:when test="position() != last()"><xsl:value-of select="$charDelim"/></xsl:when> <xsl:otherwise><xsl:value-of select="$charAtEnd"/></xsl:otherwise> </xsl:choose> </xsl:template><xsl:template name="addPDFUAmeta"> + <xsl:variable name="lang"> + <xsl:call-template name="getLang"/> + </xsl:variable> <fo:declarations> <pdf:catalog xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf"> <pdf:dictionary type="normal" key="ViewerPreferences"> <pdf:boolean key="DisplayDocTitle">true</pdf:boolean> </pdf:dictionary> @@ -4232,17 +4294,20 @@ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pdf="http://ns.adobe.com/pdf/1.3/" rdf:about=""> <!-- Dublin Core properties go here --> <dc:title> <xsl:variable name="title"> - - - - <xsl:value-of select="/*/*[local-name() = 'bibdata']/*[local-name() = 'title'][@language = 'en']"/> - - - + <xsl:for-each select="(//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']"> + + + + + <xsl:value-of select="*[local-name() = 'title'][@language = $lang]"/> + + + + </xsl:for-each> </xsl:variable> <xsl:choose> <xsl:when test="normalize-space($title) != ''"> <xsl:value-of select="$title"/> </xsl:when> @@ -4250,18 +4315,17 @@ <xsl:text> </xsl:text> </xsl:otherwise> </xsl:choose> </dc:title> <dc:creator> - - - - </dc:creator> - <dc:description> - <xsl:variable name="abstract"> + <xsl:for-each select="(//*[contains(local-name(), '-standard')])[1]/*[local-name() = 'bibdata']"> + </xsl:for-each> + </dc:creator> + <dc:description> + <xsl:variable name="abstract"> </xsl:variable> <xsl:value-of select="normalize-space($abstract)"/> </dc:description> \ No newline at end of file