lib/isodoc/gb/gb.recommendation.xsl in metanorma-gb-1.5.1 vs lib/isodoc/gb/gb.recommendation.xsl in metanorma-gb-1.5.2

- old
+ new

@@ -35,24 +35,12 @@ <item level="1" id="Foreword" display="true">Foreword</item> <item id="term-script" display="false">3.2</item> --> <xsl:variable name="contents"> <contents> - <xsl:apply-templates select="/gb:gb-standard/gb:preface/node()" mode="contents"/> - - <xsl:apply-templates select="/gb:gb-standard/gb:sections/gb:clause[1]" mode="contents"/> <!-- [@id = '_scope'] --> - - <!-- Normative references --> - <xsl:apply-templates select="/gb:gb-standard/gb:bibliography/gb:references[1]" mode="contents"/> <!-- [@id = '_normative_references'] --> - - <xsl:apply-templates select="/gb:gb-standard/gb:sections/*[position() &gt; 1]" mode="contents"/> <!-- @id != '_scope' --> - - <xsl:apply-templates select="/gb:gb-standard/gb:annex" mode="contents"/> - - <!-- Bibliography --> - <xsl:apply-templates select="/gb:gb-standard/gb:bibliography/gb:references[position() &gt; 1]" mode="contents"/> <!-- @id = '_bibliography' --> - + <xsl:call-template name="processPrefaceSectionsDefault_Contents"/> + <xsl:call-template name="processMainSectionsDefault_Contents"/> </contents> </xsl:variable> <xsl:variable name="lang"> <xsl:call-template name="getLang"/> @@ -365,12 +353,12 @@ </xsl:for-each> </fo:block> </fo:block-container> <!-- Foreword, Introduction --> - <fo:block line-height="150%"> - <xsl:apply-templates select="/gb:gb-standard/gb:preface/node()"/> + <fo:block line-height="150%"> + <xsl:call-template name="processPrefaceSectionsDefault"/> </fo:block> </fo:flow> </fo:page-sequence> @@ -389,24 +377,12 @@ <xsl:call-template name="insertTitle"> <xsl:with-param name="lang" select="$language"/> </xsl:call-template> </fo:block> - <xsl:apply-templates select="/gb:gb-standard/gb:sections/gb:clause[1]"/> <!-- Scope --> + <xsl:call-template name="processMainSectionsDefault"/> - <!-- Normative references --> - <xsl:apply-templates select="/gb:gb-standard/gb:bibliography/gb:references[1]"/> - - <!-- Main sections --> - <xsl:apply-templates select="/gb:gb-standard/gb:sections/*[position() &gt; 1]"/> - - <!-- Annex(s) --> - <xsl:apply-templates select="/gb:gb-standard/gb:annex"/> - - <!-- Bibliography --> - <xsl:apply-templates select="/gb:gb-standard/gb:bibliography/gb:references[position() &gt; 1]"/> - </fo:block> </fo:flow> </fo:page-sequence> <fo:page-sequence master-reference="last" force-page-count="no-force"> @@ -601,11 +577,11 @@ <xsl:apply-templates/> </fo:block> </xsl:template> <!-- Bibliography --> - <xsl:template match="gb:references[position() &gt; 1]/gb:title"> + <xsl:template match="gb:references[not(@normative='true')]/gb:title"> <fo:block font-family="SimHei" text-align="center" margin-top="6pt" margin-bottom="16pt" keep-with-next="always"> <xsl:apply-templates/> </fo:block> </xsl:template> @@ -719,21 +695,11 @@ <xsl:text>— </xsl:text> </xsl:if> <xsl:apply-templates/> </xsl:element> <xsl:if test="$element-name = 'fo:inline' and not(local-name(..) = 'admonition')"> - <xsl:value-of select="$linebreak"/> - <!-- <xsl:choose> - <xsl:when test="ancestor::gb:annex"> - <xsl:value-of select="$linebreak"/> - </xsl:when> - <xsl:otherwise> - <fo:block margin-bottom="12pt"> - <xsl:value-of select="$linebreak"/> - </fo:block> - </xsl:otherwise> - </xsl:choose> --> + <xsl:value-of select="$linebreak"/> </xsl:if> </xsl:template> <xsl:template match="gb:li//gb:p//text()"> <xsl:choose> @@ -773,17 +739,17 @@ <xsl:when test="xalan:nodeset($p_fn)//fn[@gen_id = $gen_id]"> <fo:footnote> <fo:inline font-size="60%" keep-with-previous.within-line="always" vertical-align="super"> <fo:basic-link internal-destination="footnote_{@reference}_{$number}" fox:alt-text="footnote {@reference} {$number}"> <!-- <xsl:value-of select="@reference"/> --> - <xsl:value-of select="$number + count(//gb:bibitem[ancestor::gb:references[@id='_normative_references' or not(preceding-sibling::gb:references)]]/gb:note)"/> + <xsl:value-of select="$number + count(//gb:bibitem[ancestor::gb:references[@normative='true' or not(preceding-sibling::gb:references)]]/gb:note)"/> </fo:basic-link> </fo:inline> <fo:footnote-body> <fo:block font-size="9pt" margin-bottom="12pt"> <fo:inline font-size="50%" id="footnote_{@reference}_{$number}" keep-with-next.within-line="always" vertical-align="super"> - <xsl:value-of select="$number + count(//gb:bibitem[ancestor::gb:references[@id='_normative_references' or not(preceding-sibling::gb:references)]]/gb:note)"/> + <xsl:value-of select="$number + count(//gb:bibitem[ancestor::gb:references[@normative='true' or not(preceding-sibling::gb:references)]]/gb:note)"/> </fo:inline> <xsl:for-each select="gb:p"> <xsl:apply-templates/> </xsl:for-each> </fo:block> @@ -963,11 +929,11 @@ </xsl:template> <!-- <xsl:template match="gb:references[@id = '_bibliography']"> --> - <xsl:template match="gb:references[position() &gt; 1]"> + <xsl:template match="gb:references[not(@normative='true')]"> <fo:block break-after="page"/> <fo:block id="{@id}"> <xsl:apply-templates/> </fo:block> <fo:block-container text-align="center"> @@ -978,11 +944,11 @@ </xsl:template> <!-- Example: [1] ISO 9:1995, Information and documentation – Transliteration of Cyrillic characters into Latin characters – Slavic and non-Slavic languages --> <!-- <xsl:template match="gb:references[@id = '_bibliography']/gb:bibitem"> --> - <xsl:template match="gb:references[position() &gt; 1]/gb:bibitem"> + <xsl:template match="gb:references[not(@normative='true')]/gb:bibitem"> <fo:list-block font-size="11pt" margin-bottom="12pt" provisional-distance-between-starts="12mm"> <fo:list-item> <fo:list-item-label end-indent="label-end()"> <fo:block> <fo:inline id="{@id}"> @@ -1017,14 +983,14 @@ </fo:list-item> </fo:list-block> </xsl:template> <!-- <xsl:template match="gb:references[@id = '_bibliography']/gb:bibitem" mode="contents"/> --> - <xsl:template match="gb:references[position() &gt; 1]/gb:bibitem" mode="contents"/> + <xsl:template match="gb:references[not(@normative='true')]/gb:bibitem" mode="contents"/> <!-- <xsl:template match="gb:references[@id = '_bibliography']/gb:bibitem/gb:title"> --> - <xsl:template match="gb:references[position() &gt; 1]/gb:bibitem/gb:title"> + <xsl:template match="gb:references[not(@normative='true')]/gb:bibitem/gb:title"> <fo:inline font-style="italic"> <xsl:apply-templates/> </fo:inline> </xsl:template> @@ -1320,10 +1286,11 @@ </xsl:attribute-set><xsl:attribute-set name="example-body-style"> + </xsl:attribute-set><xsl:attribute-set name="example-name-style"> <xsl:attribute name="padding-right">5mm</xsl:attribute> @@ -1336,12 +1303,14 @@ + + </xsl:attribute-set><xsl:attribute-set name="example-p-style"> <xsl:attribute name="font-size">10pt</xsl:attribute> @@ -1354,10 +1323,12 @@ + + </xsl:attribute-set><xsl:attribute-set name="termexample-name-style"> <xsl:attribute name="padding-right">1mm</xsl:attribute> <xsl:attribute name="font-family">SimHei</xsl:attribute> @@ -1379,10 +1350,11 @@ + </xsl:attribute-set><xsl:attribute-set name="appendix-style"> <xsl:attribute name="font-size">12pt</xsl:attribute> <xsl:attribute name="font-weight">bold</xsl:attribute> <xsl:attribute name="margin-top">12pt</xsl:attribute> @@ -1514,11 +1486,11 @@ - + </xsl:attribute-set><xsl:attribute-set name="formula-style"> </xsl:attribute-set><xsl:attribute-set name="image-style"> <xsl:attribute name="text-align">center</xsl:attribute> @@ -1560,11 +1532,47 @@ </xsl:attribute-set><xsl:attribute-set name="deprecates-style"> </xsl:attribute-set><xsl:attribute-set name="definition-style"> - </xsl:attribute-set><xsl:template match="text()"> + </xsl:attribute-set><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"/> + </xsl:template><xsl:template name="processMainSectionsDefault_Contents"> + <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='clause'][@type='scope']" mode="contents"/> + + <!-- Normative references --> + <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']" mode="contents"/> + <!-- Terms and definitions --> + <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name()='terms'] | /*/*[local-name()='sections']/*[local-name()='clause'][.//*[local-name()='terms']] | /*/*[local-name()='sections']/*[local-name()='definitions'] | /*/*[local-name()='sections']/*[local-name()='clause'][.//*[local-name()='definitions']]" mode="contents"/> + <!-- Another main sections --> + <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name() != 'terms' and local-name() != 'definitions' and not(@type='scope') and not(local-name() = 'clause' and .//*[local-name()='terms']) and not(local-name() = 'clause' and .//*[local-name()='definitions'])]" mode="contents"/> + <xsl:apply-templates select="/*/*[local-name()='annex']" mode="contents"/> + <!-- Bibliography --> + <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]" mode="contents"/> + </xsl:template><xsl:template name="processPrefaceSectionsDefault"> + <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='abstract']"/> + <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='foreword']"/> + <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='introduction']"/> + <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name() != 'abstract' and local-name() != 'foreword' and local-name() != 'introduction' and local-name() != 'acknowledgements']"/> + <xsl:apply-templates select="/*/*[local-name()='preface']/*[local-name()='acknowledgements']"/> + </xsl:template><xsl:template name="processMainSectionsDefault"> + <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'] | /*/*[local-name()='sections']/*[local-name()='clause'][.//*[local-name()='terms']] | /*/*[local-name()='sections']/*[local-name()='definitions'] | /*/*[local-name()='sections']/*[local-name()='clause'][.//*[local-name()='definitions']]"/> + <!-- Another main sections --> + <xsl:apply-templates select="/*/*[local-name()='sections']/*[local-name() != 'terms' and local-name() != 'definitions' and not(@type='scope') and not(local-name() = 'clause' and .//*[local-name()='terms']) and not(local-name() = 'clause' and .//*[local-name()='definitions'])]"/> + <xsl:apply-templates select="/*/*[local-name()='annex']"/> + <!-- Bibliography --> + <xsl:apply-templates select="/*/*[local-name()='bibliography']/*[local-name()='references'][not(@normative='true')]"/> + </xsl:template><xsl:template match="text()"> <xsl:value-of select="."/> </xsl:template><xsl:template match="*[local-name()='br']"> <xsl:value-of select="$linebreak"/> </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"/> --> @@ -1639,10 +1647,11 @@ + <fo:table id="{@id}" table-layout="fixed" width="100%" margin-left="{$margin-left}mm" margin-right="{$margin-left}mm" table-omit-footer-at-break="true"> @@ -1653,10 +1662,11 @@ <xsl:attribute name="font-size">10pt</xsl:attribute> + <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> @@ -1908,18 +1918,27 @@ <xsl:apply-templates/> </fo:table-row> </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:when> + <xsl:otherwise>center</xsl:otherwise> + </xsl:choose> + </xsl:attribute> + <xsl:if test="@colspan"> <xsl:attribute name="number-columns-spanned"> <xsl:value-of select="@colspan"/> </xsl:attribute> </xsl:if> @@ -1932,10 +1951,18 @@ <xsl:apply-templates/> </fo:block> </fo:table-cell> </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:when> + <xsl:otherwise>left</xsl:otherwise> + </xsl:choose> + </xsl:attribute> <xsl:if test="ancestor::*[local-name() = 'tfoot']"> @@ -3182,10 +3209,121 @@ </xsl:if> </xsl:template><xsl:template match="*[local-name() = 'recommendation']/*[local-name() = 'label']"> <fo:block xsl:use-attribute-sets="recommendation-label-style"> <xsl:apply-templates/> </fo:block> + </xsl:template><xsl:template match="*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']"> + <fo:block-container margin-left="0mm" margin-right="0mm" margin-bottom="12pt"> + <fo:block-container margin-left="0mm" margin-right="0mm"> + <fo:table id="{@id}" table-layout="fixed" width="100%" border="0pt solid black"> + <xsl:variable name="simple-table"> + <xsl:call-template name="getSimpleTable"/> + </xsl:variable> + <xsl:variable name="cols-count" select="count(xalan:nodeset($simple-table)//tr[1]/td)"/> + <xsl:if test="$cols-count = 2 and not(ancestor::*[local-name()='table'])"> + <fo:table-column column-width="35mm"/> + <fo:table-column column-width="115mm"/> + </xsl:if> + <xsl:apply-templates mode="requirement"/> + </fo:table> + <!-- fn processing --> + <xsl:if test=".//*[local-name() = 'fn']"> + <xsl:for-each select="*[local-name() = 'tbody']"> + <fo:block font-size="90%" border-bottom="1.pt solid black"> + <xsl:call-template name="fn_display"/> + </fo:block> + </xsl:for-each> + </xsl:if> + </fo:block-container> + </fo:block-container> + </xsl:template><xsl:template match="*[local-name()='thead']" mode="requirement"> + <fo:table-header> + <xsl:apply-templates mode="requirement"/> + </fo:table-header> + </xsl:template><xsl:template match="*[local-name()='tbody']" mode="requirement"> + <fo:table-body> + <xsl:apply-templates mode="requirement"/> + </fo:table-body> + </xsl:template><xsl:template match="*[local-name()='tr']" mode="requirement"> + <fo:table-row> + <xsl:apply-templates mode="requirement"/> + </fo:table-row> + </xsl:template><xsl:template match="*[local-name()='th']" mode="requirement"> + <fo:table-cell text-align="{@align}"> + <xsl:attribute name="text-align"> + <xsl:choose> + <xsl:when test="@align"> + <xsl:value-of select="@align"/> + </xsl:when> + <xsl:otherwise>center</xsl:otherwise> + </xsl:choose> + </xsl:attribute> + <xsl:if test="@colspan"> + <xsl:attribute name="number-columns-spanned"> + <xsl:value-of select="@colspan"/> + </xsl:attribute> + </xsl:if> + <xsl:if test="@rowspan"> + <xsl:attribute name="number-rows-spanned"> + <xsl:value-of select="@rowspan"/> + </xsl:attribute> + </xsl:if> + + <xsl:if test="ancestor::*[local-name()='table']/@type = 'recommend'"> + <xsl:attribute name="padding-top">0.5mm</xsl:attribute> + <xsl:attribute name="background-color">rgb(165, 165, 165)</xsl:attribute> + </xsl:if> + <xsl:if test="ancestor::*[local-name()='table']/@type = 'recommendtest'"> + <xsl:attribute name="padding-top">0.5mm</xsl:attribute> + <xsl:attribute name="background-color">rgb(201, 201, 201)</xsl:attribute> + </xsl:if> + + <fo:block> + <xsl:apply-templates/> + </fo:block> + </fo:table-cell> + </xsl:template><xsl:template match="*[local-name()='td']" mode="requirement"> + <fo:table-cell text-align="{@align}"> + <xsl:attribute name="text-align"> + <xsl:choose> + <xsl:when test="@align"> + <xsl:value-of select="@align"/> + </xsl:when> + <xsl:otherwise>left</xsl:otherwise> + </xsl:choose> + </xsl:attribute> + <xsl:if test="@colspan"> + <xsl:attribute name="number-columns-spanned"> + <xsl:value-of select="@colspan"/> + </xsl:attribute> + </xsl:if> + <xsl:if test="@rowspan"> + <xsl:attribute name="number-rows-spanned"> + <xsl:value-of select="@rowspan"/> + </xsl:attribute> + </xsl:if> + + <xsl:if test="ancestor::*[local-name()='table']/@type = 'recommend'"> + <xsl:attribute name="padding-left">0.5mm</xsl:attribute> + <xsl:attribute name="padding-top">0.5mm</xsl:attribute> + <xsl:if test="parent::*[local-name()='tr']/preceding-sibling::*[local-name()='tr'] and not(*[local-name()='table'])"> <!-- 2nd line and below --> + <xsl:attribute name="background-color">rgb(201, 201, 201)</xsl:attribute> + </xsl:if> + </xsl:if> + + <fo:block> + <xsl:apply-templates/> + </fo:block> + </fo:table-cell> + </xsl:template><xsl:template match="*[local-name() = 'p'][@class='RecommendationTitle' or @class = 'RecommendationTestTitle']" priority="2"> + <fo:block font-size="11pt" font-weight="bold" text-align="center" margin-bottom="4pt"> + <xsl:apply-templates/> + </fo:block> + </xsl:template><xsl:template match="*[local-name() = 'p'][ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']]"> + <fo:block margin-bottom="10pt"> + <xsl:apply-templates/> + </fo:block> </xsl:template><xsl:template match="*[local-name() = 'termexample']"> <fo:block id="{@id}" xsl:use-attribute-sets="termexample-style"> <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/> <xsl:apply-templates/> </fo:block> @@ -3454,11 +3592,11 @@ </fo:block> </xsl:template><xsl:template match="*[local-name() = 'definitions']"> <fo:block id="{@id}"> <xsl:apply-templates/> </fo:block> - </xsl:template><xsl:template match="/*/*[local-name() = 'bibliography']/*[local-name() = 'references'][@id = '_normative_references' or @id = '_references']"> + </xsl:template><xsl:template match="/*/*[local-name() = 'bibliography']/*[local-name() = 'references'][@normative='true']"> <fo:block id="{@id}"> <xsl:apply-templates/> </fo:block> </xsl:template><xsl:template match="*[local-name() = 'annex']"> @@ -3708,10 +3846,11 @@ <xsl:value-of select="document('')//*/namespace::gb"/> - + + </xsl:variable> <xsl:if test="$documentNS != $XSLNS"> <xsl:message>[WARNING]: Document namespace: '<xsl:value-of select="$documentNS"/>' doesn't equal to xslt namespace '<xsl:value-of select="$XSLNS"/>'</xsl:message> </xsl:if> </xsl:template><xsl:template name="getLanguage"> \ No newline at end of file