lib/isodoc/nist/nist.csts.xsl in metanorma-nist-1.3.1 vs lib/isodoc/nist/nist.csts.xsl in metanorma-nist-1.3.2

- old
+ new

@@ -1159,10 +1159,13 @@ <title-amendment lang="en">AMENDMENT</title-amendment> <title-continued lang="en">(continued)</title-continued> <title-continued lang="fr">(continué)</title-continued> + </xsl:variable><xsl:variable name="bibdata"> + <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'bibdata']"/> + <xsl:copy-of select="//*[contains(local-name(), '-standard')]/*[local-name() = 'localized-strings']"/> </xsl:variable><xsl:variable name="tab_zh"> </xsl:variable><xsl:template name="getTitle"> <xsl:param name="name"/> <xsl:param name="lang"/> <xsl:variable name="lang_"> <xsl:choose> @@ -1184,14 +1187,16 @@ <xsl:value-of select="$titles/*[local-name() = $name][@lang = 'en']"/> </xsl:otherwise> </xsl:choose> </xsl:template><xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable><xsl:variable name="upper">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable><xsl:variable name="en_chars" select="concat($lower,$upper,',.`1234567890-=~!@#$%^*()_+[]{}\|?/')"/><xsl:variable name="linebreak" select="'&#8232;'"/><xsl:attribute-set name="root-style"> + </xsl:attribute-set><xsl:attribute-set name="link-style"> + </xsl:attribute-set><xsl:attribute-set name="sourcecode-style"> <xsl:attribute name="white-space">pre</xsl:attribute> <xsl:attribute name="wrap-option">wrap</xsl:attribute> @@ -1303,10 +1308,11 @@ </xsl:attribute-set><xsl:attribute-set name="table-name-style"> <xsl:attribute name="keep-with-next">always</xsl:attribute> + @@ -1332,10 +1338,11 @@ </xsl:attribute-set><xsl:attribute-set name="xref-style"> + <xsl:attribute name="color">blue</xsl:attribute> <xsl:attribute name="text-decoration">underline</xsl:attribute> </xsl:attribute-set><xsl:attribute-set name="eref-style"> @@ -1347,10 +1354,11 @@ </xsl:attribute-set><xsl:attribute-set name="note-style"> + @@ -1374,10 +1382,11 @@ + </xsl:attribute-set><xsl:attribute-set name="note-p-style"> @@ -1394,15 +1403,17 @@ </xsl:attribute-set><xsl:attribute-set name="termnote-style"> + <xsl:attribute name="margin-top">4pt</xsl:attribute> </xsl:attribute-set><xsl:attribute-set name="termnote-name-style"> + </xsl:attribute-set><xsl:attribute-set name="quote-style"> @@ -1419,18 +1430,20 @@ + </xsl:attribute-set><xsl:attribute-set name="origin-style"> </xsl:attribute-set><xsl:attribute-set name="term-style"> </xsl:attribute-set><xsl:attribute-set name="figure-name-style"> + @@ -1458,17 +1471,19 @@ + </xsl:attribute-set><xsl:attribute-set name="figure-pseudocode-p-style"> </xsl:attribute-set><xsl:attribute-set name="image-graphic-style"> + <xsl:attribute name="width">75%</xsl:attribute> <xsl:attribute name="content-height">100%</xsl:attribute> <xsl:attribute name="content-width">scale-to-fit</xsl:attribute> <xsl:attribute name="scaling">uniform</xsl:attribute> @@ -1486,17 +1501,36 @@ </xsl:attribute-set><xsl:attribute-set name="domain-style"> </xsl:attribute-set><xsl:attribute-set name="admitted-style"> - + </xsl:attribute-set><xsl:attribute-set name="deprecates-style"> </xsl:attribute-set><xsl:attribute-set name="definition-style"> - </xsl:attribute-set><xsl:template name="processPrefaceSectionsDefault_Contents"> + + </xsl:attribute-set><xsl:variable name="color-added-text"> + <xsl:text>rgb(0, 255, 0)</xsl:text> + </xsl:variable><xsl:attribute-set name="add-style"> + <xsl:attribute name="color">red</xsl:attribute> + <xsl:attribute name="text-decoration">underline</xsl:attribute> + <!-- <xsl:attribute name="color">black</xsl:attribute> + <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute> + <xsl:attribute name="padding-top">1mm</xsl:attribute> + <xsl:attribute name="padding-bottom">0.5mm</xsl:attribute> --> + </xsl:attribute-set><xsl:variable name="color-deleted-text"> + <xsl:text>red</xsl:text> + </xsl:variable><xsl:attribute-set name="del-style"> + <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute> + <xsl:attribute name="text-decoration">line-through</xsl:attribute> + </xsl:attribute-set><xsl:attribute-set name="mathml-style"> + <xsl:attribute name="font-family">STIX Two Math</xsl:attribute> + + + </xsl:attribute-set><xsl:variable name="border-block-added">2.5pt solid rgb(0, 176, 80)</xsl:variable><xsl:variable name="border-block-deleted">2.5pt solid rgb(255, 0, 0)</xsl:variable><xsl:template name="processPrefaceSectionsDefault_Contents"> <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']" mode="contents"/> <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']" mode="contents"/> <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='introduction']" mode="contents"/> <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements']" mode="contents"/> <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='acknowledgements']" mode="contents"/> @@ -1537,20 +1571,21 @@ </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="table-preamble"> + + + </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 --> @@ -1559,11 +1594,11 @@ - <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/> + <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"> @@ -1578,12 +1613,10 @@ </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"/> @@ -1607,13 +1640,15 @@ <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:attribute name="space-after">6pt</xsl:attribute> @@ -1634,10 +1669,12 @@ + + <xsl:variable name="table_width"> <!-- for centered table always 100% (@width will be set for middle/second cell of outer table) --> 100% @@ -1650,10 +1687,12 @@ <attribute name="margin-right"><xsl:value-of select="$margin-left"/>mm</attribute> + + @@ -1739,12 +1778,13 @@ </fo:block-container> </xsl:variable> + <xsl:variable name="isAdded" select="@added"/> + <xsl:variable name="isDeleted" select="@deleted"/> - <xsl:choose> <xsl:when test="@width"> <!-- centered table when table name is centered (see table-name-style) --> @@ -1753,31 +1793,64 @@ <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> + <xsl:copy-of select="$table-preamble"/> + <fo:block> + <xsl:call-template name="setTrackChangesStyles"> + <xsl:with-param name="isAdded" select="$isAdded"/> + <xsl:with-param name="isDeleted" select="$isDeleted"/> + </xsl:call-template> + <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:choose> + <xsl:when test="$isAdded = 'true' or $isDeleted = 'true'"> + <xsl:copy-of select="$table-preamble"/> + <fo:block> + <xsl:call-template name="setTrackChangesStyles"> + <xsl:with-param name="isAdded" select="$isAdded"/> + <xsl:with-param name="isDeleted" select="$isDeleted"/> + </xsl:call-template> + <xsl:copy-of select="$table"/> + </fo:block> + </xsl:when> + <xsl:otherwise> + <xsl:copy-of select="$table-preamble"/> + <xsl:copy-of select="$table"/> + </xsl:otherwise> + </xsl:choose> </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:param name="continued"/> <xsl:if test="normalize-space() != ''"> <fo:block xsl:use-attribute-sets="table-name-style"> - <xsl:apply-templates/> + <xsl:choose> + <xsl:when test="$continued = 'true'"> + <!-- <xsl:if test="$namespace = 'bsi'"></xsl:if> --> + + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates/> + </xsl:otherwise> + </xsl:choose> + + </fo:block> </xsl:if> </xsl:template><xsl:template name="calculate-columns-numbers"> <xsl:param name="table-row"/> <xsl:variable name="columns-count" select="count($table-row/*)"/> @@ -1825,11 +1898,11 @@ </width> </xsl:for-each> </xsl:when> <xsl:otherwise> - <xsl:for-each select="xalan:nodeset($table)//tr"> + <xsl:for-each select="xalan:nodeset($table)/*/tr"> <xsl:variable name="td_text"> <xsl:apply-templates select="td[$curr-col]" mode="td_text"/> <!-- <xsl:if test="$namespace = 'bipm'"> <xsl:for-each select="*[local-name()='td'][$curr-col]//*[local-name()='math']"> @@ -1913,22 +1986,22 @@ <fo:table-header> <xsl:apply-templates/> </fo:table-header> </xsl:template><xsl:template name="table-header-title"> - <xsl:param name="cols-count"/> + <xsl:param name="cols-count"/> <!-- row for title --> <fo:table-row> <fo:table-cell number-columns-spanned="{$cols-count}" border-left="1.5pt solid white" border-right="1.5pt solid white" border-top="1.5pt solid white" border-bottom="1.5pt solid black"> - <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']" mode="presentation"/> + + <xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']" mode="presentation"> + <xsl:with-param name="continued">true</xsl:with-param> + </xsl:apply-templates> <xsl:for-each select="ancestor::*[local-name()='table'][1]"> <xsl:call-template name="fn_name_display"/> - </xsl:for-each> - <fo:block text-align="right" font-style="italic"> - <xsl:text> </xsl:text> - <fo:retrieve-table-marker retrieve-class-name="table_continued"/> - </fo:block> + </xsl:for-each> + </fo:table-cell> </fo:table-row> </xsl:template><xsl:template match="*[local-name()='thead']" mode="process_tbody"> <fo:table-body> <xsl:apply-templates/> @@ -2148,10 +2221,11 @@ + </xsl:if> <xsl:if test="$parent-name = 'tfoot'"> </xsl:if> @@ -2168,19 +2242,21 @@ </xsl:template><xsl:template match="*[local-name()='th']"> <fo:table-cell text-align="{@align}" font-weight="bold" border="solid black 1pt" padding-left="1mm" display-align="center"> <xsl:attribute name="text-align"> <xsl:choose> <xsl:when test="@align"> - <xsl:value-of select="@align"/> + <xsl:call-template name="setAlignment"/> + <!-- <xsl:value-of select="@align"/> --> </xsl:when> <xsl:otherwise>center</xsl:otherwise> </xsl:choose> </xsl:attribute> + <xsl:attribute name="text-align">center</xsl:attribute> <xsl:attribute name="background-color">black</xsl:attribute> <xsl:attribute name="color">white</xsl:attribute> @@ -2188,10 +2264,13 @@ + <xsl:if test="$lang = 'ar'"> + <xsl:attribute name="padding-right">1mm</xsl:attribute> + </xsl:if> <xsl:if test="@colspan"> <xsl:attribute name="number-columns-spanned"> <xsl:value-of select="@colspan"/> </xsl:attribute> </xsl:if> @@ -2219,30 +2298,38 @@ </xsl:template><xsl:template match="*[local-name()='td']"> <fo:table-cell text-align="{@align}" display-align="center" border="solid black 1pt" padding-left="1mm"> <xsl:attribute name="text-align"> <xsl:choose> <xsl:when test="@align"> - <xsl:value-of select="@align"/> + <xsl:call-template name="setAlignment"/> + <!-- <xsl:value-of select="@align"/> --> </xsl:when> <xsl:otherwise>left</xsl:otherwise> </xsl:choose> </xsl:attribute> + <xsl:if test="$lang = 'ar'"> + <xsl:attribute name="padding-right">1mm</xsl:attribute> + </xsl:if> + <xsl:if test="ancestor::*[local-name()='thead']"> <xsl:attribute name="font-weight">normal</xsl:attribute> </xsl:if> + <xsl:if test=".//*[local-name() = 'table']"> + <xsl:attribute name="padding-right">1mm</xsl:attribute> + </xsl:if> <xsl:if test="@colspan"> <xsl:attribute name="number-columns-spanned"> <xsl:value-of select="@colspan"/> </xsl:attribute> </xsl:if> @@ -2370,17 +2457,17 @@ <xsl:value-of select="substring-before(name(/*), '-')"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <!-- <xsl:variable name="ns" select="substring-before(name(/*), '-')"/> --> - <xsl:element name="{$ns}:table"> + <!-- <xsl:element name="{$ns}:table"> --> <xsl:for-each select="*[local-name() = 'dl'][1]"> <tbody> <xsl:apply-templates mode="dl"/> </tbody> </xsl:for-each> - </xsl:element> + <!-- </xsl:element> --> </xsl:variable> <xsl:call-template name="calculate-column-widths"> <xsl:with-param name="cols-count" select="2"/> <xsl:with-param name="table" select="$html-table"/> @@ -2472,10 +2559,12 @@ </xsl:template><xsl:template match="*[local-name()='fn']/*[local-name()='p']"> <fo:inline> <xsl:apply-templates/> </fo:inline> </xsl:template><xsl:template match="*[local-name()='dl']"> + <xsl:variable name="isAdded" select="@added"/> + <xsl:variable name="isDeleted" select="@deleted"/> <fo:block-container> <xsl:if test="not(ancestor::*[local-name() = 'quote'])"> <xsl:attribute name="margin-left">0mm</xsl:attribute> </xsl:if> @@ -2488,10 +2577,16 @@ <xsl:otherwise><xsl:value-of select="$note-body-indent-table"/></xsl:otherwise> </xsl:choose> </xsl:attribute> </xsl:if> + + <xsl:call-template name="setTrackChangesStyles"> + <xsl:with-param name="isAdded" select="$isAdded"/> + <xsl:with-param name="isDeleted" select="$isDeleted"/> + </xsl:call-template> + <fo:block-container> <xsl:attribute name="margin-left">0mm</xsl:attribute> <xsl:attribute name="margin-right">0mm</xsl:attribute> @@ -2603,15 +2698,15 @@ <xsl:value-of select="substring-before(name(/*), '-')"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <!-- <xsl:variable name="ns" select="substring-before(name(/*), '-')"/> --> - <xsl:element name="{$ns}:table"> + <!-- <xsl:element name="{$ns}:table"> --> <tbody> <xsl:apply-templates mode="dl"/> </tbody> - </xsl:element> + <!-- </xsl:element> --> </xsl:variable> <!-- html-table<xsl:copy-of select="$html-table"/> --> <xsl:variable name="colwidths"> <xsl:call-template name="calculate-column-widths"> <xsl:with-param name="cols-count" select="2"/> @@ -2873,10 +2968,11 @@ + </xsl:variable> <xsl:variable name="font-size" select="normalize-space($_font-size)"/> <xsl:if test="$font-size != ''"> <xsl:attribute name="font-size"> @@ -2890,12 +2986,78 @@ </fo:inline> </xsl:template><xsl:template match="*[local-name()='underline']"> <fo:inline text-decoration="underline"> <xsl:apply-templates/> </fo:inline> + </xsl:template><xsl:template match="*[local-name()='add']"> + <xsl:choose> + <xsl:when test="@amendment"> + <fo:inline> + <xsl:call-template name="insertTag"> + <xsl:with-param name="kind">A</xsl:with-param> + <xsl:with-param name="value"><xsl:value-of select="@amendment"/></xsl:with-param> + </xsl:call-template> + <xsl:apply-templates/> + <xsl:call-template name="insertTag"> + <xsl:with-param name="type">closing</xsl:with-param> + <xsl:with-param name="kind">A</xsl:with-param> + <xsl:with-param name="value"><xsl:value-of select="@amendment"/></xsl:with-param> + </xsl:call-template> + </fo:inline> + </xsl:when> + <xsl:when test="@corrigenda"> + <fo:inline> + <xsl:call-template name="insertTag"> + <xsl:with-param name="kind">C</xsl:with-param> + <xsl:with-param name="value"><xsl:value-of select="@corrigenda"/></xsl:with-param> + </xsl:call-template> + <xsl:apply-templates/> + <xsl:call-template name="insertTag"> + <xsl:with-param name="type">closing</xsl:with-param> + <xsl:with-param name="kind">C</xsl:with-param> + <xsl:with-param name="value"><xsl:value-of select="@corrigenda"/></xsl:with-param> + </xsl:call-template> + </fo:inline> + </xsl:when> + <xsl:otherwise> + <fo:inline xsl:use-attribute-sets="add-style"> + <xsl:apply-templates/> + </fo:inline> + </xsl:otherwise> + </xsl:choose> + + </xsl:template><xsl:template name="insertTag"> + <xsl:param name="type"/> + <xsl:param name="kind"/> + <xsl:param name="value"/> + <xsl:variable name="add_width" select="string-length($value) * 20"/> + <xsl:variable name="maxwidth" select="60 + $add_width"/> + <fo:instream-foreign-object fox:alt-text="OpeningTag" baseline-shift="-20%"><!-- alignment-baseline="middle" --> + <!-- <xsl:attribute name="width">7mm</xsl:attribute> + <xsl:attribute name="content-height">100%</xsl:attribute> --> + <xsl:attribute name="height">5mm</xsl:attribute> + <xsl:attribute name="content-width">100%</xsl:attribute> + <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute> + <xsl:attribute name="scaling">uniform</xsl:attribute> + <svg xmlns="http://www.w3.org/2000/svg" width="{$maxwidth + 32}" height="80"> + <g> + <xsl:if test="$type = 'closing'"> + <xsl:attribute name="transform">scale(-1 1) translate(-<xsl:value-of select="$maxwidth + 32"/>,0)</xsl:attribute> + </xsl:if> + <polyline points="0,0 {$maxwidth},0 {$maxwidth + 30},40 {$maxwidth},80 0,80 " stroke="black" stroke-width="5" fill="white"/> + <line x1="0" y1="0" x2="0" y2="80" stroke="black" stroke-width="20"/> + </g> + <text font-family="Arial" x="15" y="57" font-size="40pt"> + <xsl:if test="$type = 'closing'"> + <xsl:attribute name="x">25</xsl:attribute> + </xsl:if> + <xsl:value-of select="$kind"/><tspan dy="10" font-size="30pt"><xsl:value-of select="$value"/></tspan> + </text> + </svg> + </fo:instream-foreign-object> </xsl:template><xsl:template match="*[local-name()='del']"> - <fo:inline font-size="10pt" color="red" text-decoration="line-through"> + <fo:inline xsl:use-attribute-sets="del-style"> <xsl:apply-templates/> </fo:inline> </xsl:template><xsl:template match="*[local-name()='hi']"> <fo:inline background-color="yellow"> <xsl:apply-templates/> @@ -3188,15 +3350,19 @@ <xsl:apply-templates select="following-sibling::tr[1]" mode="simple-table-rowspan"> <xsl:with-param name="previousRow" select="$newRow"/> </xsl:apply-templates> </xsl:template><xsl:template name="getLang"> <xsl:variable name="language_current" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/> + <xsl:variable name="language_current_2" select="normalize-space(xalan:nodeset($bibdata)//*[local-name()='bibdata']//*[local-name()='language'][@current = 'true'])"/> <xsl:variable name="language"> <xsl:choose> <xsl:when test="$language_current != ''"> <xsl:value-of select="$language_current"/> </xsl:when> + <xsl:when test="$language_current_2 != ''"> + <xsl:value-of select="$language_current_2"/> + </xsl:when> <xsl:otherwise> <xsl:value-of select="//*[local-name()='bibdata']//*[local-name()='language']"/> </xsl:otherwise> </xsl:choose> </xsl:variable> @@ -3232,17 +3398,27 @@ </xsl:template><xsl:template name="capitalize"> <xsl:param name="str"/> <xsl:value-of select="java:toUpperCase(java:java.lang.String.new(substring($str, 1, 1)))"/> <xsl:value-of select="substring($str, 2)"/> </xsl:template><xsl:template match="mathml:math"> - <fo:inline font-family="STIX Two Math"> <!-- --> + <xsl:variable name="isAdded" select="@added"/> + <xsl:variable name="isDeleted" select="@deleted"/> + + <fo:inline xsl:use-attribute-sets="mathml-style"> + + <xsl:call-template name="setTrackChangesStyles"> + <xsl:with-param name="isAdded" select="$isAdded"/> + <xsl:with-param name="isDeleted" select="$isDeleted"/> + </xsl:call-template> + <xsl:variable name="mathml"> <xsl:apply-templates select="." mode="mathml"/> </xsl:variable> <fo:instream-foreign-object fox:alt-text="Math"> + <!-- <xsl:copy-of select="."/> --> <xsl:copy-of select="xalan:nodeset($mathml)"/> </fo:instream-foreign-object> </fo:inline> </xsl:template><xsl:template match="@*|node()" mode="mathml"> @@ -3395,10 +3571,11 @@ <fo:inline xsl:use-attribute-sets="note-name-style"> + <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/> </fo:inline> <xsl:apply-templates/> </fo:block> @@ -3421,10 +3598,11 @@ </xsl:otherwise> </xsl:choose> </xsl:template><xsl:template match="*[local-name() = 'termnote']"> <fo:block id="{@id}" xsl:use-attribute-sets="termnote-style"> <fo:inline xsl:use-attribute-sets="termnote-name-style"> + <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/> </fo:inline> <xsl:apply-templates/> </fo:block> </xsl:template><xsl:template match="*[local-name() = 'note']/*[local-name() = 'name'] | *[local-name() = 'termnote']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'note']/*[local-name() = 'name']" mode="presentation"> @@ -3486,20 +3664,30 @@ <xsl:text>.</xsl:text> </xsl:if> --> </fo:inline> </xsl:if> </xsl:template><xsl:template match="*[local-name() = 'figure']" name="figure"> + <xsl:variable name="isAdded" select="@added"/> + <xsl:variable name="isDeleted" select="@deleted"/> <fo:block-container id="{@id}"> + <xsl:call-template name="setTrackChangesStyles"> + <xsl:with-param name="isAdded" select="$isAdded"/> + <xsl:with-param name="isDeleted" select="$isDeleted"/> + </xsl:call-template> + <fo:block> <xsl:apply-templates/> </fo:block> <xsl:call-template name="fn_display_figure"/> <xsl:for-each select="*[local-name() = 'note']"> <xsl:call-template name="note"/> </xsl:for-each> - <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/> + + + <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/> + </fo:block-container> </xsl:template><xsl:template match="*[local-name() = 'figure'][@class = 'pseudocode']"> <fo:block id="{@id}"> <xsl:apply-templates/> </fo:block> @@ -3507,44 +3695,126 @@ </xsl:template><xsl:template match="*[local-name() = 'figure'][@class = 'pseudocode']//*[local-name() = 'p']"> <fo:block xsl:use-attribute-sets="figure-pseudocode-p-style"> <xsl:apply-templates/> </fo:block> </xsl:template><xsl:template match="*[local-name() = 'image']"> - <fo:block xsl:use-attribute-sets="image-style"> - - - <xsl:variable name="src"> - <xsl:choose> - <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]"> - <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/> - </xsl:when> - <xsl:when test="not(starts-with(@src, 'data:'))"> - <xsl:value-of select="concat('url(file:',$basepath, @src, ')')"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@src"/> - </xsl:otherwise> - </xsl:choose> - </xsl:variable> - - <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"/> - </fo:block> + <xsl:variable name="isAdded" select="../@added"/> + <xsl:variable name="isDeleted" select="../@deleted"/> + <xsl:choose> + <xsl:when test="ancestor::*[local-name() = 'title']"> + <fo:inline padding-left="1mm" padding-right="1mm"> + <xsl:variable name="src"> + <xsl:call-template name="image_src"/> + </xsl:variable> + <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" vertical-align="middle"/> + </fo:inline> + </xsl:when> + <xsl:otherwise> + <fo:block xsl:use-attribute-sets="image-style"> + + <xsl:variable name="src"> + <xsl:call-template name="image_src"/> + </xsl:variable> + + <xsl:choose> + <xsl:when test="$isDeleted = 'true'"> + <!-- enclose in svg --> + <fo:instream-foreign-object fox:alt-text="Image {@alt}"> + <xsl:attribute name="width">100%</xsl:attribute> + <xsl:attribute name="content-height">100%</xsl:attribute> + <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute> + <xsl:attribute name="scaling">uniform</xsl:attribute> + + + <xsl:apply-templates select="." mode="cross_image"/> + + </fo:instream-foreign-object> + </xsl:when> + <xsl:otherwise> + <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style"/> + </xsl:otherwise> + </xsl:choose> + + </fo:block> + </xsl:otherwise> + </xsl:choose> + </xsl:template><xsl:template name="image_src"> + <xsl:choose> + <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]"> + <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/> + </xsl:when> + <xsl:when test="not(starts-with(@src, 'data:'))"> + <xsl:value-of select="concat('url(file:',$basepath, @src, ')')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@src"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template><xsl:template match="*[local-name() = 'image']" mode="cross_image"> + <xsl:choose> + <xsl:when test="@mimetype = 'image/svg+xml' and $images/images/image[@id = current()/@id]"> + <xsl:variable name="src"> + <xsl:value-of select="$images/images/image[@id = current()/@id]/@src"/> + </xsl:variable> + <xsl:variable name="width" select="document($src)/@width"/> + <xsl:variable name="height" select="document($src)/@height"/> + <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="enable-background:new 0 0 595.28 841.89;" height="{$height}" width="{$width}" viewBox="0 0 {$width} {$height}" y="0px" x="0px" id="Layer_1" version="1.1"> + <image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="{$src}" style="overflow:visible;"/> + </svg> + </xsl:when> + <xsl:when test="not(starts-with(@src, 'data:'))"> + <xsl:variable name="src"> + <xsl:value-of select="concat('url(file:',$basepath, @src, ')')"/> + </xsl:variable> + <xsl:variable name="file" select="java:java.io.File.new(@src)"/> + <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($file)"/> + <xsl:variable name="width" select="java:getWidth($bufferedImage)"/> + <xsl:variable name="height" select="java:getHeight($bufferedImage)"/> + <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="enable-background:new 0 0 595.28 841.89;" height="{$height}" width="{$width}" viewBox="0 0 {$width} {$height}" y="0px" x="0px" id="Layer_1" version="1.1"> + <image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="{$src}" style="overflow:visible;"/> + </svg> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="base64String" select="substring-after(@src, 'base64,')"/> + <xsl:variable name="decoder" select="java:java.util.Base64.getDecoder()"/> + <xsl:variable name="fileContent" select="java:decode($decoder, $base64String)"/> + <xsl:variable name="bis" select="java:java.io.ByteArrayInputStream.new($fileContent)"/> + <xsl:variable name="bufferedImage" select="java:javax.imageio.ImageIO.read($bis)"/> + <xsl:variable name="width" select="java:getWidth($bufferedImage)"/> + <!-- width=<xsl:value-of select="$width"/> --> + <xsl:variable name="height" select="java:getHeight($bufferedImage)"/> + <!-- height=<xsl:value-of select="$height"/> --> + <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="enable-background:new 0 0 595.28 841.89;" height="{$height}" width="{$width}" viewBox="0 0 {$width} {$height}" y="0px" x="0px" id="Layer_1" version="1.1"> + <image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="{@src}" height="{$height}" width="{$width}" style="overflow:visible;"/> + <xsl:call-template name="svg_cross"> + <xsl:with-param name="width" select="$width"/> + <xsl:with-param name="height" select="$height"/> + </xsl:call-template> + </svg> + </xsl:otherwise> + </xsl:choose> + + </xsl:template><xsl:template name="svg_cross"> + <xsl:param name="width"/> + <xsl:param name="height"/> + <line xmlns="http://www.w3.org/2000/svg" x1="0" y1="0" x2="{$width}" y2="{$height}" style="stroke: rgb(255, 0, 0); stroke-width:4px; "/> + <line xmlns="http://www.w3.org/2000/svg" x1="0" y1="{$height}" x2="{$width}" y2="0" style="stroke: rgb(255, 0, 0); stroke-width:4px; "/> </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'table']/*[local-name() = 'name'] | *[local-name() = 'permission']/*[local-name() = 'name'] | *[local-name() = 'recommendation']/*[local-name() = 'name'] | *[local-name() = 'requirement']/*[local-name() = 'name']" mode="contents"> <xsl:apply-templates mode="contents"/> <xsl:text> </xsl:text> </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] | *[local-name() = 'table']/*[local-name() = 'name'] | *[local-name() = 'permission']/*[local-name() = 'name'] | *[local-name() = 'recommendation']/*[local-name() = 'name'] | *[local-name() = 'requirement']/*[local-name() = 'name']" mode="bookmarks"> <xsl:apply-templates mode="bookmarks"/> <xsl:text> </xsl:text> - </xsl:template><xsl:template match="*[local-name() = 'name']/text()" mode="contents" priority="2"> + </xsl:template><xsl:template match="*[local-name() = 'figure' or local-name() = 'table' or local-name() = 'permission' or local-name() = 'recommendation' or local-name() = 'requirement']/*[local-name() = 'name']/text()" mode="contents" priority="2"> <xsl:value-of select="."/> - </xsl:template><xsl:template match="*[local-name() = 'name']/text()" mode="bookmarks" priority="2"> + </xsl:template><xsl:template match="*[local-name() = 'figure' or local-name() = 'table' or local-name() = 'permission' or local-name() = 'recommendation' or local-name() = 'requirement']/*[local-name() = 'name']/text()" mode="bookmarks" priority="2"> <xsl:value-of select="."/> </xsl:template><xsl:template match="node()" mode="contents"> <xsl:apply-templates mode="contents"/> </xsl:template><xsl:template match="node()" mode="bookmarks"> <xsl:apply-templates mode="bookmarks"/> - </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="contents"> + </xsl:template><xsl:template match="*[local-name() = 'title' or local-name() = 'name']//*[local-name() = 'stem']" mode="contents"> <xsl:apply-templates select="."/> </xsl:template><xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/><xsl:template match="*[local-name() = 'stem']" mode="bookmarks"> <xsl:apply-templates mode="bookmarks"/> </xsl:template><xsl:template name="addBookmarks"> <xsl:param name="contents"/> @@ -3743,10 +4013,12 @@ </xsl:choose> </fo:block> </fo:list-item-body> </fo:list-item> </fo:list-block> + </xsl:template><xsl:template name="extractSection"> + <xsl:value-of select="*[local-name() = 'tab'][1]/preceding-sibling::node()"/> </xsl:template><xsl:template name="extractTitle"> <xsl:choose> <xsl:when test="*[local-name() = 'tab']"> <xsl:apply-templates select="*[local-name() = 'tab'][1]/following-sibling::node()"/> </xsl:when> @@ -3790,10 +4062,11 @@ + 10 @@ -4072,18 +4345,19 @@ </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'example']/*[local-name() = 'name']" mode="presentation"> <xsl:variable name="element"> block + <xsl:if test="following-sibling::*[1][local-name() = 'table']">block</xsl:if> </xsl:variable> <xsl:choose> <xsl:when test="ancestor::*[local-name() = 'appendix']"> <fo:inline> <xsl:apply-templates/> </fo:inline> </xsl:when> - <xsl:when test="normalize-space($element) = 'block'"> + <xsl:when test="contains(normalize-space($element), 'block')"> <fo:block xsl:use-attribute-sets="example-name-style"> <xsl:apply-templates/> </fo:block> </xsl:when> <xsl:otherwise> @@ -4116,38 +4390,47 @@ <fo:inline xsl:use-attribute-sets="example-p-style"> <xsl:apply-templates/> </fo:inline> </xsl:otherwise> </xsl:choose> - </xsl:template><xsl:template match="*[local-name() = 'termsource']"> + </xsl:template><xsl:template match="*[local-name() = 'termsource']" name="termsource"> <fo:block xsl:use-attribute-sets="termsource-style"> <!-- Example: [SOURCE: ISO 5127:2017, 3.1.6.02] --> <xsl:variable name="termsource_text"> <xsl:apply-templates/> </xsl:variable> <xsl:choose> <xsl:when test="starts-with(normalize-space($termsource_text), '[')"> - <xsl:apply-templates/> + <!-- <xsl:apply-templates /> --> + <xsl:copy-of select="$termsource_text"/> </xsl:when> <xsl:otherwise> <xsl:text>[</xsl:text> - <xsl:apply-templates/> + <!-- <xsl:apply-templates /> --> + <xsl:copy-of select="$termsource_text"/> <xsl:text>]</xsl:text> </xsl:otherwise> </xsl:choose> </fo:block> </xsl:template><xsl:template match="*[local-name() = 'termsource']/text()"> <xsl:if test="normalize-space() != ''"> <xsl:value-of select="."/> </xsl:if> - </xsl:template><xsl:template match="*[local-name() = 'origin']"> + </xsl:template><xsl:variable name="localized.source"> + <xsl:call-template name="getLocalizedString"> + <xsl:with-param name="key">source</xsl:with-param> + </xsl:call-template> + </xsl:variable><xsl:template match="*[local-name() = 'origin']"> <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}"> + <xsl:if test="normalize-space(@citeas) = ''"> + <xsl:attribute name="fox:alt-text"><xsl:value-of select="@bibitemid"/></xsl:attribute> + </xsl:if> <fo:inline xsl:use-attribute-sets="origin-style"> <xsl:apply-templates/> </fo:inline> </fo:basic-link> @@ -4292,11 +4575,12 @@ <xsl:with-param name="count" select="$padding-right"/> </xsl:call-template> </fo:inline> </xsl:when> <xsl:otherwise> - <fo:inline padding-right="{$padding-right}mm">​</fo:inline> + <xsl:variable name="direction"><xsl:if test="$lang = 'ar'"><xsl:value-of select="$RLM"/></xsl:if></xsl:variable> + <fo:inline padding-right="{$padding-right}mm"><xsl:value-of select="$direction"/>​</fo:inline> </xsl:otherwise> </xsl:choose> </xsl:template><xsl:template name="insertNonBreakSpaces"> <xsl:param name="count"/> @@ -4346,11 +4630,10 @@ - <xsl:apply-templates/> </fo:block> <xsl:if test="position() != last()"> @@ -4395,20 +4678,21 @@ </xsl:template><xsl:template match="*[local-name() = 'name']/text()"> <!-- 0xA0 to space replacement --> <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),' ',' ')"/> </xsl:template><xsl:template match="*[local-name() = 'ul'] | *[local-name() = 'ol']"> <xsl:choose> - <xsl:when test="parent::*[local-name() = 'note']"> + <xsl:when test="parent::*[local-name() = 'note'] or parent::*[local-name() = 'termnote']"> <fo:block-container> <xsl:attribute name="margin-left"> <xsl:choose> <xsl:when test="not(ancestor::*[local-name() = 'table'])"><xsl:value-of select="$note-body-indent"/></xsl:when> <xsl:otherwise><xsl:value-of select="$note-body-indent-table"/></xsl:otherwise> </xsl:choose> </xsl:attribute> + <fo:block-container margin-left="0mm"> <fo:block> <xsl:apply-templates select="." mode="ul_ol"/> </fo:block> </fo:block-container> @@ -4608,10 +4892,14 @@ + + + + </xsl:template><xsl:template name="processBibitemDocId"> <xsl:variable name="_doc_ident" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]"/> <xsl:choose> <xsl:when test="normalize-space($_doc_ident) != ''"> <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]/@type"/> @@ -4664,10 +4952,74 @@ <xsl:value-of select="translate(.,'. ','')"/> </xsl:template><xsl:template match="*[local-name() = 'name']/*[local-name() = 'forename']/text()" mode="strip"> <xsl:value-of select="substring(.,1,1)"/> </xsl:template><xsl:template match="*[local-name() = 'title']" mode="title"> <fo:inline><xsl:apply-templates/></fo:inline> + </xsl:template><xsl:template match="*[local-name() = 'form']"> + <fo:block> + <xsl:apply-templates/> + </fo:block> + </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'label']"> + <fo:inline><xsl:apply-templates/></fo:inline> + </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'text' or @type = 'date' or @type = 'file' or @type = 'password']"> + <fo:inline> + <xsl:call-template name="text_input"/> + </fo:inline> + </xsl:template><xsl:template name="text_input"> + <xsl:variable name="count"> + <xsl:choose> + <xsl:when test="normalize-space(@maxlength) != ''"><xsl:value-of select="@maxlength"/></xsl:when> + <xsl:when test="normalize-space(@size) != ''"><xsl:value-of select="@size"/></xsl:when> + <xsl:otherwise>10</xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:call-template name="repeat"> + <xsl:with-param name="char" select="'_'"/> + <xsl:with-param name="count" select="$count"/> + </xsl:call-template> + <xsl:text> </xsl:text> + </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'button']"> + <xsl:variable name="caption"> + <xsl:choose> + <xsl:when test="normalize-space(@value) != ''"><xsl:value-of select="@value"/></xsl:when> + <xsl:otherwise>BUTTON</xsl:otherwise> + </xsl:choose> + </xsl:variable> + <fo:inline>[<xsl:value-of select="$caption"/>]</fo:inline> + </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'checkbox']"> + <fo:inline padding-right="1mm"> + <fo:instream-foreign-object fox:alt-text="Box" baseline-shift="-10%"> + <xsl:attribute name="height">3.5mm</xsl:attribute> + <xsl:attribute name="content-width">100%</xsl:attribute> + <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute> + <xsl:attribute name="scaling">uniform</xsl:attribute> + <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80"> + <polyline points="0,0 80,0 80,80 0,80 0,0" stroke="black" stroke-width="5" fill="white"/> + </svg> + </fo:instream-foreign-object> + </fo:inline> + </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'input'][@type = 'radio']"> + <fo:inline padding-right="1mm"> + <fo:instream-foreign-object fox:alt-text="Box" baseline-shift="-10%"> + <xsl:attribute name="height">3.5mm</xsl:attribute> + <xsl:attribute name="content-width">100%</xsl:attribute> + <xsl:attribute name="content-width">scale-down-to-fit</xsl:attribute> + <xsl:attribute name="scaling">uniform</xsl:attribute> + <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80"> + <circle cx="40" cy="40" r="30" stroke="black" stroke-width="5" fill="white"/> + <circle cx="40" cy="40" r="15" stroke="black" stroke-width="5" fill="white"/> + </svg> + </fo:instream-foreign-object> + </fo:inline> + </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'select']"> + <fo:inline> + <xsl:call-template name="text_input"/> + </fo:inline> + </xsl:template><xsl:template match="*[local-name() = 'form']//*[local-name() = 'textarea']"> + <fo:block-container border="1pt solid black" width="50%"> + <fo:block> </fo:block> + </fo:block-container> </xsl:template><xsl:template name="convertDate"> <xsl:param name="date"/> <xsl:param name="format" select="'short'"/> <xsl:variable name="year" select="substring($date, 1, 4)"/> <xsl:variable name="month" select="substring($date, 6, 2)"/> @@ -4930,10 +5282,11 @@ + <xsl:value-of select="document('')//*/namespace::nist"/> @@ -4995,19 +5348,64 @@ <xsl:with-param name="char" select="$char"/> <xsl:with-param name="count" select="$count - 1"/> </xsl:call-template> </xsl:if> </xsl:template><xsl:template name="getLocalizedString"> - <xsl:param name="key"/> + <xsl:param name="key"/> <xsl:variable name="curr_lang"> <xsl:call-template name="getLang"/> </xsl:variable> + <xsl:variable name="data_value" select="normalize-space(xalan:nodeset($bibdata)//*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang])"/> + <xsl:choose> + <xsl:when test="$data_value != ''"> + <xsl:value-of select="$data_value"/> + </xsl:when> <xsl:when test="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"> <xsl:value-of select="/*/*[local-name() = 'localized-strings']/*[local-name() = 'localized-string'][@key = $key and @language = $curr_lang]"/> </xsl:when> <xsl:otherwise><xsl:value-of select="$key"/></xsl:otherwise> </xsl:choose> + </xsl:template><xsl:template name="setTrackChangesStyles"> + <xsl:param name="isAdded"/> + <xsl:param name="isDeleted"/> + <xsl:choose> + <xsl:when test="local-name() = 'math'"> + <xsl:if test="$isAdded = 'true'"> + <xsl:attribute name="background-color"><xsl:value-of select="$color-added-text"/></xsl:attribute> + </xsl:if> + <xsl:if test="$isDeleted = 'true'"> + <xsl:attribute name="background-color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute> + </xsl:if> + </xsl:when> + <xsl:otherwise> + <xsl:if test="$isAdded = 'true'"> + <xsl:attribute name="border"><xsl:value-of select="$border-block-added"/></xsl:attribute> + <xsl:attribute name="padding">2mm</xsl:attribute> + </xsl:if> + <xsl:if test="$isDeleted = 'true'"> + <xsl:attribute name="border"><xsl:value-of select="$border-block-deleted"/></xsl:attribute> + <xsl:if test="local-name() = 'table'"> + <xsl:attribute name="background-color">rgb(255, 185, 185)</xsl:attribute> + </xsl:if> + <!-- <xsl:attribute name="color"><xsl:value-of select="$color-deleted-text"/></xsl:attribute> --> + <xsl:attribute name="padding">2mm</xsl:attribute> + </xsl:if> + </xsl:otherwise> + </xsl:choose> + </xsl:template><xsl:variable name="LRM" select="'‎'"/><xsl:variable name="RLM" select="'‏'"/><xsl:template name="setWritingMode"> + <xsl:if test="$lang = 'ar'"> + <xsl:attribute name="writing-mode">rl-tb</xsl:attribute> + </xsl:if> + </xsl:template><xsl:template name="setAlignment"> + <xsl:param name="align" select="normalize-space(@align)"/> + <xsl:choose> + <xsl:when test="$lang = 'ar' and $align = 'left'">start</xsl:when> + <xsl:when test="$lang = 'ar' and $align = 'right'">end</xsl:when> + <xsl:when test="$align != ''"> + <xsl:value-of select="$align"/> + </xsl:when> + </xsl:choose> </xsl:template></xsl:stylesheet> \ No newline at end of file