<?xml version=“1.0” encoding=“UTF-8”?><xsl:stylesheet xmlns:xsl=“www.w3.org/1999/XSL/Transform” xmlns:fo=“www.w3.org/1999/XSL/Format” xmlns:gb=“www.metanorma.org/ns/gb” xmlns:mathml=“www.w3.org/1998/Math/MathML” xmlns:xalan=“xml.apache.org/xalan” xmlns:fox=“xmlgraphics.apache.org/fop/extensions” xmlns:java=“xml.apache.org/xalan/java” exclude-result-prefixes=“java” version=“1.0”>

<xsl:output method="xml" encoding="UTF-8" indent="no"/>

<xsl:param name="svg_images"/>
<xsl:variable name="images" select="document($svg_images)"/>

<xsl:key name="kfn" match="gb:p/gb:fn" use="@reference"/>

<xsl:variable name="debug">false</xsl:variable>
<xsl:variable name="pageWidth" select="'210mm'"/>
<xsl:variable name="pageHeight" select="'297mm'"/>

<xsl:variable name="part" select="normalize-space(/gb:gb-standard/gb:bibdata/gb:ext/gb:structuredidentifier/gb:project-number/@part)"/>

<xsl:variable name="standard-name">                     
        <xsl:call-template name="capitalize">
                <xsl:with-param name="str" select="/gb:gb-standard/gb:bibdata/gb:ext/gb:gbtype/gb:gbscope"/>
        </xsl:call-template>
        <xsl:text> standard (</xsl:text>                
        <xsl:call-template name="capitalize">
                <xsl:with-param name="str" select="/gb:gb-standard/gb:bibdata/gb:ext/gb:gbtype/gb:gbmandate"/>
        </xsl:call-template>
        <xsl:text>)</xsl:text>
</xsl:variable>

<xsl:variable name="language" select="/gb:gb-standard/gb:bibdata/gb:language"/>

<!-- Example:
        <item level="1" id="Foreword" display="true">Foreword</item>
        <item id="term-script" display="false">3.2</item>
-->
<xsl:variable name="contents">
        <contents>
                <xsl:call-template name="processPrefaceSectionsDefault_Contents"/>
                <xsl:call-template name="processMainSectionsDefault_Contents"/>
        </contents>
</xsl:variable>

<xsl:variable name="lang">
        <xsl:call-template name="getLang"/>
</xsl:variable>

<xsl:template match="/">
        <xsl:call-template name="namespaceCheck"/>
        <fo:root font-family="SimSun" font-size="10.5pt" xml:lang="{$lang}"> <!--   -->
                <fo:layout-master-set>

                        <!-- cover page -->
                        <fo:simple-page-master master-name="cover" page-width="{$pageWidth}" page-height="{$pageHeight}">
                                <fo:region-body margin-top="10mm" margin-bottom="24mm" margin-left="25mm" margin-right="23mm"/>
                                <fo:region-before region-name="cover-header" extent="10mm"/>
                                <fo:region-after region-name="cover-footer" extent="24mm"/>
                                <fo:region-start region-name="cover-left-region" extent="25mm"/>
                                <fo:region-end region-name="cover-right-region" extent="23mm"/>
                        </fo:simple-page-master>

                        <!-- contents pages -->
                        <!-- odd pages -->
                        <fo:simple-page-master master-name="odd" page-width="{$pageWidth}" page-height="{$pageHeight}">
                                <fo:region-body margin-top="35mm" margin-bottom="20mm" margin-left="25mm" margin-right="20mm"/>
                                <fo:region-before region-name="header" extent="35mm"/>
                                <fo:region-after region-name="footer-odd" extent="20mm"/>
                                <fo:region-start region-name="left-region" extent="25mm"/>
                                <fo:region-end region-name="right-region" extent="20mm"/>
                        </fo:simple-page-master>
                        <!-- even pages -->
                        <fo:simple-page-master master-name="even" page-width="{$pageWidth}" page-height="{$pageHeight}">
                                <fo:region-body margin-top="35mm" margin-bottom="25mm" margin-left="20mm" margin-right="25mm"/>
                                <fo:region-before region-name="header" extent="35mm"/>
                                <fo:region-after region-name="footer-even" extent="20mm"/>
                                <fo:region-start region-name="left-region" extent="20mm"/>
                                <fo:region-end region-name="right-region" extent="25mm"/>
                        </fo:simple-page-master>
                        <fo:page-sequence-master master-name="preface">
                                <fo:repeatable-page-master-alternatives>
                                        <fo:conditional-page-master-reference odd-or-even="even" master-reference="even"/>
                                        <fo:conditional-page-master-reference odd-or-even="odd" master-reference="odd"/>
                                </fo:repeatable-page-master-alternatives>
                        </fo:page-sequence-master>
                        <fo:page-sequence-master master-name="document">
                                <fo:repeatable-page-master-alternatives>
                                        <fo:conditional-page-master-reference odd-or-even="even" master-reference="even"/>
                                        <fo:conditional-page-master-reference odd-or-even="odd" master-reference="odd"/>
                                </fo:repeatable-page-master-alternatives>
                        </fo:page-sequence-master>

                        <fo:simple-page-master master-name="last-odd" page-width="215.9mm" page-height="279.4mm">
                                <fo:region-body margin-top="20mm" margin-bottom="20mm" margin-left="30mm" margin-right="15mm"/>
                                <fo:region-before region-name="header" extent="20mm"/>
                                <fo:region-after region-name="footer-odd" extent="20mm"/>
                                <fo:region-start region-name="left-region" extent="30mm"/>
                                <fo:region-end region-name="right-region" extent="15mm"/>
                        </fo:simple-page-master>
                        <fo:simple-page-master master-name="last-even" page-width="215.9mm" page-height="279.4mm">
                                <fo:region-body margin-top="20mm" margin-bottom="20mm" margin-left="15mm" margin-right="30mm"/>
                                <fo:region-before region-name="header" extent="20mm"/>
                                <fo:region-after region-name="footer-odd" extent="20mm"/>
                                <fo:region-start region-name="left-region" extent="15mm"/>
                                <fo:region-end region-name="right-region" extent="30mm"/>
                        </fo:simple-page-master>
                        <fo:page-sequence-master master-name="last">
                                <fo:repeatable-page-master-alternatives>
                                        <fo:conditional-page-master-reference odd-or-even="even" master-reference="last-even"/>
                                        <fo:conditional-page-master-reference odd-or-even="odd" master-reference="last-odd"/>
                                </fo:repeatable-page-master-alternatives>
                        </fo:page-sequence-master>      
                </fo:layout-master-set>

                <xsl:call-template name="addPDFUAmeta"/>

                <xsl:call-template name="addBookmarks">
                        <xsl:with-param name="contents" select="$contents"/>
                </xsl:call-template>

                <fo:page-sequence master-reference="cover" force-page-count="no-force">
                        <fo:flow flow-name="xsl-region-body">
                                <fo:block-container>
                                        <xsl:variable name="ccs" select="normalize-space(/gb:gb-standard/gb:bibdata/gb:ext/gb:ccs)"/>
                                        <fo:block font-weight="bold" line-height="130%">
                                                <xsl:if test="$ccs != ''">
                                                        <xsl:text>ICS</xsl:text>
                                                </xsl:if>
                                                <xsl:text> </xsl:text>
                                                <xsl:value-of select="$linebreak"/>
                                                <xsl:value-of select="substring($ccs, 1, 1)"/>
                                                <xsl:text> </xsl:text>
                                                <fo:inline font-family="SimHei" font-weight="normal"><xsl:value-of select="substring($ccs, 2)"/></fo:inline>
                                                <xsl:text> </xsl:text>
                                        </fo:block>
                                </fo:block-container>
                                <!-- GB Logo -->
                                <fo:block-container position="absolute" top="3mm" left="119mm"> <!-- top="8mm"  -->
                                        <fo:block>
                                                <xsl:variable name="gbprefix" select="normalize-space(java:toLowerCase(java:java.lang.String.new(/gb:gb-standard/gb:bibdata/gb:ext/gb:gbtype/gb:gbprefix)))"/>                                                  
                                                <xsl:choose>
                                                        <xsl:when test="$gbprefix = 'db' or $gbprefix = '81'">
                                                                <fo:instream-foreign-object fox:alt-text="Logo">
                                                                        <svg xmlns="http://www.w3.org/2000/svg" id="图层_1" data-name="图层 1" viewBox="0 0 133.2 66.6"><title>gb-standard-db</title><path d="M56.5,0H0V66.6H56.5A8.5,8.5,0,0,0,65,58.1V8.5A8.5,8.5,0,0,0,56.5,0ZM42.4,56.3a2.9,2.9,0,0,1-2.9,2.9H22.8V7.5H39.5a2.8,2.8,0,0,1,2.9,2.8Z"/><path d="M133.2,24.7V8.5A8.5,8.5,0,0,0,124.7,0H68.2V66.6h56.5a8.5,8.5,0,0,0,8.5-8.5V41.3a8.6,8.6,0,0,0-6.9-8.3A8.6,8.6,0,0,0,133.2,24.7ZM110.6,56.3a2.9,2.9,0,0,1-2.9,2.9H91.1v-22h16.6a2.9,2.9,0,0,1,2.9,2.8Zm0-29.6a2.9,2.9,0,0,1-2.9,2.9H91.1V7.5h16.6a2.8,2.8,0,0,1,2.9,2.8Z"/></svg>
                                                                </fo:instream-foreign-object>
                                                        </xsl:when>
                                                        <xsl:when test="$gbprefix = 'gb'">
                                                                <fo:instream-foreign-object fox:alt-text="Logo">
                                                                        <svg xmlns="http://www.w3.org/2000/svg" width="29.9mm" id="图层_1" data-name="图层 1" viewBox="0 0 232.1 117"><defs><style>.cls-1{fill:#fff;}.cls-1,.cls-2,.cls-3{stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.32px;}.cls-3{fill:none;}</style></defs><title>gb-standard-gb</title><path class="cls-1" d="M201.6,36.5c0,5.6-4.3,8.4-8.8,8.4H147.9L136,58.5h55.2c14,0,22.7-9.1,23.7-19.8.7-6.5-.9-14.1-6-19l-9.6,11A7.6,7.6,0,0,1,201.6,36.5Z"/><path class="cls-1" d="M133.6,102.7V14.6h61c6.4,0,11,2,14.3,5.1L218.1,9C212.5,4.1,204.4.7,192.8.7H120.1V116.3l13.6-13.6Z"/><path class="cls-1" d="M216.6,81.1c0-11.9-7.1-16-7.1-16a82,82,0,0,1-9.5,9.5,6.1,6.1,0,0,1,2.3,5c0,3.3-.7,8.9-12.3,8.9H147.9l-14.2,14.2h50.8C203.9,102.7,216.6,95.7,216.6,81.1Z"/><path class="cls-2" d="M223.1,56.7s8.3-11.6,7-23.5c-.8-7.1-3.8-17.2-12-24.2l-9.2,10.7c5.1,4.9,6.7,12.5,6,19-1,10.7-9.7,19.8-23.7,19.8H136l11.9-13.6V28.6h44.9a9.4,9.4,0,0,1,6.5,2.1l9.6-11c-3.3-3.1-7.9-5.1-14.3-5.1h-61v88.1h.1l14.2-14.2V72.8h44.9c3.5,0,5.8.7,7.2,1.8a82,82,0,0,0,9.5-9.5s7.1,4.1,7.1,16c0,14.6-12.7,21.6-32.1,21.6H133.7l-13.6,13.6h72.7c20.6,0,35-13.6,37.4-25.5S232.1,67,223.1,56.7Z"/><line class="cls-3" x1="133.6" y1="14.6" x2="120.1" y2="0.7"/><polygon class="cls-2" points="70.9 59.6 57.8 74.7 85.1 74.7 98.8 59.6 70.9 59.6"/><path class="cls-2" d="M52,15.9c-8.8,0-35,9.3-36,38-.6,16,4.3,28.2,11.3,36.3l10.8-9.8c-5.2-4.8-9.2-12.2-9.2-23.1,0-21.4,21-27.3,28.9-27.3H113L98.8,15.9Z"/><path class="cls-1" d="M49.8,101.6h49v-42L85.1,74.7V88.5H57.8a31,31,0,0,1-19.7-8.1L27.3,90.2C33.8,97.6,42.2,101.6,49.8,101.6Z"/><polygon class="cls-1" points="57.8 45.4 57.8 74.7 70.9 59.6 98.8 59.6 113 45.4 85.1 45.4 57.8 45.4"/><path class="cls-2" d="M98.8,101.6h-49c-7.6,0-16-4-22.5-11.4L17,99.5c9.3,10.1,22.7,16.8,40.8,16.8H113V45.4L98.8,59.6Z"/><path class="cls-1" d="M16,53.9c1-28.7,27.2-38,36-38H98.8L113,30V.7H57.8C34.2.7.7,22,.7,52.9.7,69.8,5.8,87.2,17,99.5l10.3-9.3C20.3,82.1,15.4,69.9,16,53.9Z"/><line class="cls-3" x1="57.8" y1="45.4" x2="70.9" y2="59.6"/><line class="cls-3" x1="85.1" y1="88.5" x2="98.8" y2="101.6"/><line class="cls-3" x1="98.8" y1="15.9" x2="113" y2="0.7"/></svg>
                                                                </fo:instream-foreign-object>
                                                        </xsl:when>                                                             
                                                        <xsl:when test="$gbprefix = 'gjb'">
                                                                <fo:instream-foreign-object fox:alt-text="Logo">
                                                                        <svg xmlns="http://www.w3.org/2000/svg" id="图层_1" data-name="图层 1" viewBox="0 0 232.2 88.4"><defs><style>.cls-1{fill:#fff;}.cls-1,.cls-2,.cls-3{stroke:#000;stroke-linecap:round;stroke-linejoin:round;}.cls-3{fill:none;}</style></defs><title>gb-standard-gjb</title><path class="cls-1" d="M209.1,27.6c0,4.2-3.3,6.4-6.7,6.4H168.5l-9,10.2h41.7c10.6,0,17.2-6.9,18-14.9.5-4.9-.7-10.7-4.6-14.4l-7.2,8.3A5.9,5.9,0,0,1,209.1,27.6Z"/><path class="cls-1" d="M157.7,77.6V11h46.1a15.4,15.4,0,0,1,10.8,3.9l7-8.1C217.3,3.1,211.2.5,202.4.5H147.5V87.9l10.3-10.3Z"/><path class="cls-1" d="M220.4,61.3c0-9-5.3-12.1-5.3-12.1a70.7,70.7,0,0,1-7.2,7.2,4.5,4.5,0,0,1,1.7,3.7c0,2.5-.5,6.8-9.3,6.8H168.5L157.8,77.6h38.4C210.9,77.6,220.4,72.3,220.4,61.3Z"/><path class="cls-2" d="M225.4,42.9s6.2-8.8,5.2-17.8c-.6-5.4-2.8-13-9-18.3l-7,8.1c3.9,3.7,5.1,9.5,4.6,14.4-.8,8-7.4,14.9-18,14.9H159.5l9-10.2V21.6h33.9a7.5,7.5,0,0,1,5,1.6l7.2-8.3A15.4,15.4,0,0,0,203.8,11H157.7V77.6h.1l10.7-10.7V55h33.9a9.1,9.1,0,0,1,5.5,1.4,70.7,70.7,0,0,0,7.2-7.2s5.3,3.1,5.3,12.1c0,11-9.5,16.3-24.2,16.3H157.8L147.5,87.9h54.9c15.6,0,26.5-10.3,28.3-19.3S232.1,50.6,225.4,42.9Z"/><line class="cls-3" x1="157.7" y1="11" x2="147.5" y2="0.5"/><path class="cls-2" d="M121.4,87.9c10.3,0,20.3-12.1,20.3-24.5V.5h-21V57.6c0,3.9,0,9.3-7.3,9.3H87.7v21h33.7Z"/><path class="cls-1" d="M120.7,57.6c0,3.9,0,9.3-7.3,9.3H87.7v21L98.8,77.4h19.3c8.3,0,13.3-6,13.3-19V11L141.7.5h-21Z"/><line class="cls-3" x1="131.4" y1="11" x2="120.7" y2="0.5"/><line class="cls-3" x1="98.8" y1="77.4" x2="87.7" y2="66.9"/><polygon class="cls-2" points="51.4 45.1 41.5 56.5 62.2 56.5 72.5 45.1 51.4 45.1"/><path class="cls-2" d="M39.3,12c-6.6,0-26.5,7-27.2,28.7-.4,12.1,3.2,21.4,8.5,27.4l8.2-7.3c-3.9-3.7-7-9.3-7-17.5,0-16.2,15.9-20.6,21.9-20.6H83.3L72.6,12Z"/><path class="cls-1" d="M37.6,76.7h35V45.1L62.2,56.5V66.9H43.7a23.8,23.8,0,0,1-14.9-6.1l-8.2,7.3C25.6,73.8,31.9,76.7,37.6,76.7Z"/><polygon class="cls-1" points="41.5 34.3 41.5 56.5 51.4 45.1 72.5 45.1 83.3 34.3 62.2 34.3 41.5 34.3"/><path class="cls-2" d="M72.6,76.7h-35c-5.7,0-12-2.9-17-8.6l-7.7,7.1c7,7.7,17.1,12.7,30.8,12.7H83.3V34.3L72.6,45.1Z"/><path class="cls-1" d="M12.1,40.7C12.8,19,32.7,12,39.3,12H72.6L83.3,22.7V.5H43.7C25.9.5.5,16.6.5,40c0,12.8,3.9,25.9,12.4,35.2l7.7-7.1C15.3,62.1,11.7,52.8,12.1,40.7Z"/><line class="cls-3" x1="41.5" y1="34.3" x2="51.4" y2="45.1"/><line class="cls-3" x1="62.2" y1="66.9" x2="72.6" y2="76.7"/><line class="cls-3" x1="72.6" y1="12" x2="83.3" y2="0.5"/></svg>
                                                                </fo:instream-foreign-object>
                                                        </xsl:when>
                                                        <xsl:when test="$gbprefix = 'gm'">
                                                                <fo:instream-foreign-object fox:alt-text="Logo">
                                                                        <svg xmlns="http://www.w3.org/2000/svg" id="图层_1" data-name="图层 1" viewBox="0 0 187.2 95.1"><title>gb-standard-gm</title><polygon points="160 0 141.8 32.9 123.6 0 96.3 0 96.3 11.3 96.3 95.1 123.6 95.1 123.6 60.7 125 63.3 141.8 93.6 158.5 63.3 160 60.7 160 95.1 187.2 95.1 187.2 11.3 187.2 0 160 0"/><path d="M81.3,0H9.9A10,10,0,0,0,0,9.9V85.2a9.9,9.9,0,0,0,9.9,9.9h43a9.9,9.9,0,0,0,6.8-2.7v2.7H91.2V43.2H48.8v9.5H59.7V78.9A5.7,5.7,0,0,1,54,84.5H37.2a5.7,5.7,0,0,1-5.7-5.6V16.3a5.8,5.8,0,0,1,5.7-5.7H54a5.8,5.8,0,0,1,5.7,5.7V31.2H91.2V9.9A10,10,0,0,0,81.3,0Z"/></svg>
                                                                </fo:instream-foreign-object>
                                                        </xsl:when>
                                                        <xsl:when test="$gbprefix = 'jjf'">
                                                                <fo:instream-foreign-object fox:alt-text="Logo">
                                                                        <svg xmlns="http://www.w3.org/2000/svg" id="图层_1" data-name="图层 1" viewBox="0 0 226.8 89.6"><defs><style>.cls-1,.cls-2,.cls-3{stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.2px;}.cls-2{fill:#fff;}.cls-3{fill:none;}</style></defs><title>gb-standard-jjf</title><polygon class="cls-1" points="84.3 12.3 75.1 23.9 144.4 23.9 144.4 0.6 133.7 12.3 84.3 12.3"/><polygon class="cls-2" points="75.1 23.9 84.3 12.3 133.7 12.3 144.4 0.6 75.1 0.6 75.1 23.9"/><path class="cls-2" d="M92,73.6c2.6,2.2,6.2,3.4,11.3,3.4,13.4,0,19.1-7.3,19.1-22.2V13.5L110.7,23.7V62s-1,4.6-5.5,4.6a7.5,7.5,0,0,1-3.9-1h0Z" transform="translate(0)"/><path class="cls-1" d="M86.8,57c0,7.1,1.2,13,5.2,16.6l9.3-8h0c-1.9-1.1-2.8-3.3-2.8-6.2V44L86.8,51.7Z" transform="translate(0)"/><path class="cls-1" d="M110.7,12.3V23.7l11.7-10.2V54.8c0,14.9-5.7,22.2-19.1,22.2-5.1,0-8.7-1.2-11.3-3.4l-7.9,6.8c5,4.5,12,7.4,20.8,7.4,19,0,29.1-14.2,29.1-25.8V12.3Z" transform="translate(0)"/><path class="cls-2" d="M86.8,57V51.7L98.5,44H75.1V59.4a28.7,28.7,0,0,0,9,21L92,73.6C88,70,86.8,64.1,86.8,57Z" transform="translate(0)"/><polyline class="cls-3" points="88.4 53.6 86.8 51.7 75.1 44"/><line class="cls-3" x1="84.3" y1="12.3" x2="75.1" y2="0.6"/><polygon class="cls-1" points="9.8 12.3 0.6 23.9 69.9 23.9 69.9 0.6 59.1 12.3 9.8 12.3"/><polygon class="cls-2" points="0.6 23.9 9.8 12.3 59.1 12.3 69.9 0.6 0.6 0.6 0.6 23.9"/><path class="cls-2" d="M17.5,73.6C20,75.8,23.7,77,28.8,77c13.4,0,19-7.3,19-22.2V13.5L36.2,23.7V62s-1.1,4.6-5.5,4.6a8.2,8.2,0,0,1-4-1h0Z" transform="translate(0)"/><path class="cls-1" d="M12.3,57c0,7.1,1.2,13,5.2,16.6l9.2-8h0c-1.8-1.1-2.8-3.3-2.8-6.2V44L12.3,51.7Z" transform="translate(0)"/><path class="cls-1" d="M36.2,12.3V23.7L47.8,13.5V54.8c0,14.9-5.6,22.2-19,22.2-5.1,0-8.8-1.2-11.3-3.4L9.6,80.4c5,4.5,12,7.4,20.7,7.4,19,0,29.2-14.2,29.2-25.8V12.3Z" transform="translate(0)"/><path class="cls-2" d="M12.3,57V51.7L23.9,44H.6V59.4a28.4,28.4,0,0,0,9,21l7.9-6.8C13.5,70,12.3,64.1,12.3,57Z" transform="translate(0)"/><polyline class="cls-3" points="13.9 53.6 12.3 51.7 0.6 44"/><line class="cls-3" x1="9.8" y1="12.3" x2="0.6" y2="0.6"/><polygon class="cls-1" points="226.2 0.6 173.4 0.6 152.4 0.6 149.1 0.6 149.1 89 173.4 89 173.4 24.9 226.2 24.9 226.2 0.6"/><rect class="cls-1" x="161.3" y="36.6" width="64.9" height="24.33"/><polygon class="cls-2" points="162.1 48.8 216.1 48.8 226.2 36.6 173.4 36.6 162.1 48.8"/><polygon class="cls-2" points="152.4 0.6 149.1 0.6 149.1 89 161.3 79.1 161.3 12.3 216.8 12.3 226.2 0.6 173.4 0.6 152.4 0.6"/><line class="cls-3" x1="161.3" y1="12.3" x2="149.1" y2="0.6"/></svg>
                                                                </fo:instream-foreign-object>
                                                        </xsl:when>
                                                        <xsl:when test="$gbprefix = 'zb'">
                                                                <fo:instream-foreign-object fox:alt-text="Logo">
                                                                        <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="图层_1" x="0px" y="0px" viewBox="0 0 157.1 81.9" style="enable-background:new 0 0 157.1 81.9;" xml:space="preserve">
                                                                        <g>
                                                                                <rect x="80.8" width="32.2" height="81.9"/>
                                                                                <polygon points="74.9,46.2 42.7,81.9 74.9,81.9  "/>
                                                                                <polygon points="33.6,0 0,0 0,37.8  "/>
                                                                                <path d="M157.1,61.1c0-8.6-6-17.5-15.4-21c7.7-1.1,14.6-10.4,14.6-21.2c0-10.8-9.5-19-27.7-19h-11.7v81.1             c5.3,0.4,11.4,0.8,17.7,0.8C153,81.9,157.1,69.8,157.1,61.1z"/>
                                                                                <polygon points="75.6,0 40.6,0 0,81.9 35,81.9  "/>
                                                                        </g>
                                                                        </svg>
                                                                </fo:instream-foreign-object>
                                                        </xsl:when>
                                                        <xsl:when test="$gbprefix = 'ls' or $gbprefix = 'abc'">
                                                                <xsl:attribute name="text-align">right</xsl:attribute>
                                                                <xsl:attribute name="font-weight">bold</xsl:attribute>
                                                                <fo:inline font-size="36pt"><xsl:value-of select="/gb:gb-standard/gb:bibdata/gb:ext/gb:gbtype/gb:gbprefix"/></fo:inline>
                                                        </xsl:when>
                                                        <!-- <xsl:when test="$gbprefix = 'gb'">
                                                                <fo:external-graphic src="{concat('data:image/gif;base64,', normalize-space($Image-GB-Logo))}" width="29.9mm" content-height="14.8mm" content-width="scale-to-fit" scaling="uniform" fox:alt-text="Image GB Logo"/>
                                                        </xsl:when> -->
                                                        <xsl:otherwise> </xsl:otherwise>
                                                </xsl:choose>
                                        </fo:block>
                                </fo:block-container>
                                <!-- National standard (Recommended) -->
                                <fo:block-container position="absolute" left="0mm" top="28mm" width="170mm" text-align="center">
                                        <fo:block font-weight="bold" font-size="12pt"> <!-- font-stretch="wider" not supported by FOP-->
                                                <xsl:call-template name="addLetterSpacing">
                                                        <xsl:with-param name="text" select="$standard-name"/>
                                                        <xsl:with-param name="letter-spacing" select="0.7"/>
                                                </xsl:call-template>
                                        </fo:block>
                                </fo:block-container>
                                <fo:block-container position="absolute" left="0mm" top="43mm" height="46.4mm" width="165mm" text-align="right">
                                        <fo:block>
                                                <!-- GB/T/303 80021.1 -->
                                                <fo:block font-family="SimHei" font-size="14pt">
                                                        <xsl:value-of select="/gb:gb-standard/gb:bibdata/gb:docidentifier[@type = 'gb']"/>                                                      
                                                </fo:block>
                                                <!-- Partly Supercedes GB/T 88021-2016 -->
                                                <fo:block margin-top="2.85pt">
                                                        <xsl:variable name="title-partly-supercedes">
                                                                <xsl:call-template name="getTitle">
                                                                        <xsl:with-param name="name" select="'title-partly-supercedes'"/>
                                                                </xsl:call-template>
                                                        </xsl:variable>
                                                        <xsl:value-of select="$title-partly-supercedes"/>                                                               
                                                        <xsl:value-of select="/gb:gb-standard/gb:bibdata/gb:relation[@type='obsoletes']/gb:bibitem/gb:docidentifier"/>
                                                </fo:block>
                                        </fo:block>
                                </fo:block-container>
                                <fo:block-container position="absolute" left="0mm" top="66mm" height="2mm" width="170mm" border-top="1pt solid black">
                                        <fo:block> </fo:block>
                                </fo:block-container>
                                <fo:block-container position="absolute" left="-2.5mm" top="106mm" height="124mm" width="165mm" text-align="center">
                                        <!-- Cereals and pulses—Specifications and test methods—Part 1: Rice -->
                                        <fo:block font-size="26pt" line-height="130%">
                                                <xsl:attribute name="font-family">
                                                        <xsl:choose>
                                                                <xsl:when test="$lang = 'zh'">SimSun</xsl:when>
                                                                <xsl:otherwise>Cambria</xsl:otherwise>
                                                        </xsl:choose>
                                                </xsl:attribute>
                                                <xsl:call-template name="insertTitle">
                                                        <xsl:with-param name="lang" select="$language"/>
                                                </xsl:call-template>
                                        </fo:block>
                                        <fo:block font-size="14pt" margin-top="28.35pt" margin-bottom="28.35pt">                                                        
                                                <xsl:variable name="secondlang">
                                                        <xsl:choose>
                                                                <xsl:when test="$language = 'en'">zh</xsl:when>
                                                                <xsl:when test="$language = 'zh'">en</xsl:when>
                                                        </xsl:choose>
                                                </xsl:variable>
                                                <xsl:if test="$secondlang = 'en'">
                                                        <xsl:attribute name="font-family">SimHei</xsl:attribute>
                                                </xsl:if>
                                                <xsl:call-template name="insertTitle">
                                                        <xsl:with-param name="lang" select="$secondlang"/>
                                                </xsl:call-template>
                                        </fo:block>
                                        <!-- (ISO 17301-1:2016, IDT) -->
                                        <fo:block font-size="14pt" margin-top="30pt">
                                                <xsl:text> </xsl:text>
                                                        <xsl:if test="/gb:gb-standard/gb:bibdata/gb:relation[@type='adoptedFrom']/gb:bibitem/gb:docidentifier">
                                                                <xsl:text>(</xsl:text>
                                                                        <xsl:value-of select="/gb:gb-standard/gb:bibdata/gb:relation[@type='adoptedFrom']/gb:bibitem/gb:docidentifier"/>
                                                                        <xsl:text>, </xsl:text>
                                                                        <xsl:text> IDT</xsl:text>
                                                                <xsl:text>)</xsl:text>
                                                        </xsl:if>
                                                <xsl:text> </xsl:text>
                                        </fo:block>
                                        <!-- (CD) -->
                                        <fo:block font-size="12pt" margin-top="30pt">
                                                <xsl:text>(</xsl:text>
                                                <xsl:value-of select="/gb:gb-standard/gb:bibdata/gb:status/gb:stage/@abbreviation"/>
                                                <xsl:text>)</xsl:text>
                                        </fo:block>
                                        <fo:block text-align="justify">
                                                <!-- When submitting feedback, please attach any relevant patents that you are aware of, together with supporting documents. -->
                                                <xsl:apply-templates select="/gb:gb-standard/gb:boilerplate/gb:legal-statement"/>
                                        </fo:block>
                                        <fo:block margin-top="9.05pt">
                                                <xsl:text>(</xsl:text>
                                                <xsl:variable name="title-completion-date">
                                                        <xsl:call-template name="getTitle">
                                                                <xsl:with-param name="name" select="'title-completion-date'"/>
                                                        </xsl:call-template>
                                                </xsl:variable>
                                                <xsl:value-of select="$title-completion-date"/>                                                 
                                                <xsl:text>: </xsl:text>
                                                        <xsl:value-of select="/gb:gb-standard/gb:bibdata/gb:version/gb:revision-date"/>
                                                <xsl:text>)</xsl:text>
                                        </fo:block>
                                </fo:block-container>
                                <fo:block-container position="absolute" left="0mm" top="239mm" width="170mm" border-bottom="1pt solid black">
                                        <fo:block font-family="SimHei" font-size="14pt" text-align-last="justify" margin-bottom="2.5mm">
                                                <xsl:variable name="title-issuance-date">
                                                        <xsl:call-template name="getTitle">
                                                                <xsl:with-param name="name" select="'title-issuance-date'"/>
                                                        </xsl:call-template>
                                                </xsl:variable>
                                                <xsl:value-of select="java:replaceAll(java:java.lang.String.new($title-issuance-date),'#',/gb:gb-standard/gb:bibdata/gb:date[@type='issued']/gb:on)"/>

                                                <fo:inline keep-together.within-line="always">
                                                        <fo:leader leader-pattern="space"/>
                                                </fo:inline>

                                                <xsl:variable name="title-implementation-date">
                                                        <xsl:call-template name="getTitle">
                                                                <xsl:with-param name="name" select="'title-implementation-date'"/>
                                                        </xsl:call-template>
                                                </xsl:variable>
                                                <xsl:value-of select="java:replaceAll(java:java.lang.String.new($title-implementation-date),'#',/gb:gb-standard/gb:bibdata/gb:date[@type='implemented']/gb:on)"/>

                                        </fo:block>
                                </fo:block-container>
                                <fo:block break-after="page"/>
                                <fo:block> </fo:block>
                        </fo:flow>
                </fo:page-sequence>

                <fo:page-sequence master-reference="preface" format="I" initial-page-number="1" force-page-count="no-force">
                        <xsl:call-template name="insertHeaderFooter"/>
                        <fo:flow flow-name="xsl-region-body">
                                <fo:block-container>

                                        <fo:block font-family="SimHei" font-size="16pt" margin-top="6pt" margin-bottom="32pt" text-align="center">
                                                <xsl:variable name="title-toc">
                                                        <xsl:call-template name="getTitle">
                                                                <xsl:with-param name="name" select="'title-toc'"/>
                                                        </xsl:call-template>
                                                </xsl:variable>
                                                <xsl:value-of select="$title-toc"/>
                                        </fo:block>

                                        <xsl:if test="$debug = 'true'">
                                                <xsl:text disable-output-escaping="yes">&lt;!--</xsl:text>
                                                        DEBUG
                                                        contents=<xsl:copy-of select="xalan:nodeset($contents)"/>
                                                <xsl:text disable-output-escaping="yes">--&gt;</xsl:text>
                                        </xsl:if>

                                        <fo:block line-height="220%">
                                                <xsl:variable name="margin-left">12</xsl:variable>
                                                <xsl:for-each select="xalan:nodeset($contents)//item[@display = 'true']"><!-- [@display = 'true'][not(@level = 2 and starts-with(@section, '0'))] skip clause from preface -->                                                  
                                                        <fo:block text-align-last="justify">
                                                                <xsl:if test="@level =2">
                                                                        <xsl:attribute name="margin-left">3.7mm</xsl:attribute>
                                                                </xsl:if>
                                                                <fo:basic-link internal-destination="{@id}" fox:alt-text="{title}">
                                                                        <xsl:if test="normalize-space(@section) != ''">
                                                                                <fo:inline>                                                                                             
                                                                                        <xsl:value-of select="@section"/>                                                                                       
                                                                                </fo:inline>
                                                                                <xsl:value-of select="$tab_zh"/>                                                                                        
                                                                        </xsl:if>
                                                                        <xsl:apply-templates select="title"/>
                                                                        <fo:inline keep-together.within-line="always">
                                                                                <fo:leader font-weight="normal" leader-pattern="dots"/>
                                                                                <fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
                                                                        </fo:inline>
                                                                </fo:basic-link>

                                                        </fo:block>

                                                </xsl:for-each>
                                        </fo:block>
                                </fo:block-container>

                                <!-- Foreword, Introduction -->
                                <fo:block line-height="150%">                                           
                                        <xsl:call-template name="processPrefaceSectionsDefault"/>                                               
                                </fo:block>

                        </fo:flow>
                </fo:page-sequence>

                <fo:page-sequence master-reference="document" format="1" initial-page-number="1" force-page-count="no-force">
                        <fo:static-content flow-name="xsl-footnote-separator">
                                <fo:block margin-left="7.4mm">
                                        <fo:leader leader-pattern="rule" leader-length="30%"/>
                                </fo:block>
                        </fo:static-content>
                        <xsl:call-template name="insertHeaderFooter"/>
                        <fo:flow flow-name="xsl-region-body">
                                <fo:block line-height="150%">

                                        <!-- Cereals and pulses—Specifications and test methods—Part 1: Rice -->
                                        <fo:block font-family="SimHei" font-size="16pt" text-align="center" line-height="130%" margin-bottom="18pt">
                                                <xsl:call-template name="insertTitle">
                                                        <xsl:with-param name="lang" select="$language"/>
                                                </xsl:call-template>
                                        </fo:block>

                                        <xsl:call-template name="processMainSectionsDefault"/>

                                </fo:block>
                        </fo:flow>
                </fo:page-sequence>

                <fo:page-sequence master-reference="last" force-page-count="no-force">
                        <fo:flow flow-name="xsl-region-body">
                                <fo:block-container font-size="12pt">
                                        <fo:block margin-top="14pt" margin-bottom="14pt">
                                                <xsl:value-of select="$standard-name"/>
                                        </fo:block>
                                        <fo:block margin-top="14pt" margin-bottom="14pt">
                                                <xsl:value-of select="/gb:gb-standard/gb:bibdata/gb:title[@language = 'zh' and @type = 'title-main']"/>
                                        </fo:block>
                                        <fo:block margin-top="14pt" margin-bottom="14pt">
                                                <xsl:value-of select="/gb:gb-standard/gb:bibdata/gb:docidentifier[@type = 'gb']"/>
                                        </fo:block>
                                </fo:block-container>
                        </fo:flow>                              
                </fo:page-sequence>

        </fo:root>
</xsl:template> 

<xsl:template name="insertTitle">
        <xsl:param name="lang" select="'en'"/>
        <xsl:variable name="delimeter">
                <xsl:choose>
                        <xsl:when test="$lang = 'zh'"> </xsl:when>
                        <xsl:otherwise>—</xsl:otherwise>
                </xsl:choose>
        </xsl:variable>

        <xsl:value-of select="/gb:gb-standard/gb:bibdata/gb:title[@language = $lang and @type='title-intro']"/>
        <xsl:variable name="title-main" select="/gb:gb-standard/gb:bibdata/gb:title[@language = $lang and @type = 'title-main']"/>
        <xsl:if test="normalize-space($title-main) != ''">
                <xsl:value-of select="$delimeter"/>
                <xsl:value-of select="$title-main"/>
        </xsl:if>
        <xsl:variable name="title-part" select="/gb:gb-standard/gb:bibdata/gb:title[@language = $lang and @type = 'title-part']"/>
        <xsl:if test="normalize-space($title-part) != ''">
                <xsl:value-of select="$delimeter"/>
                <xsl:if test="$part != ''">
                        <xsl:choose>
                                <xsl:when test="$lang = 'zh'">
                                        <xsl:value-of select="java:replaceAll(java:java.lang.String.new($titles/title-part[@lang='zh']),'#',$part)"/>
                                </xsl:when>
                                <xsl:otherwise>
                                        <xsl:value-of select="java:replaceAll(java:java.lang.String.new($titles/title-part[@lang='en']),'#',$part)"/>
                                </xsl:otherwise>
                        </xsl:choose>
                </xsl:if>
                <xsl:value-of select="$title-part"/>
        </xsl:if>               
</xsl:template> 

<xsl:template match="node()">           
        <xsl:apply-templates/>                  
</xsl:template>

<!-- ============================= -->
<!-- CONTENTS                                       -->
<!-- ============================= -->
<xsl:template match="node()" mode="contents">           
        <xsl:apply-templates mode="contents"/>                  
</xsl:template>

<!-- element with title -->
<xsl:template match="*[gb:title]" mode="contents">
        <xsl:variable name="level">
                <xsl:call-template name="getLevel">
                        <xsl:with-param name="depth" select="gb:title/@depth"/>
                </xsl:call-template>
        </xsl:variable>

        <xsl:variable name="display">
                <xsl:choose>                            
                        <xsl:when test="$level &lt;= 2">true</xsl:when>
                        <xsl:otherwise>false</xsl:otherwise>
                </xsl:choose>
        </xsl:variable>

        <xsl:variable name="skip">
                <xsl:choose>
                        <xsl:when test="ancestor-or-self::gb:bibitem">true</xsl:when>
                        <xsl:when test="ancestor-or-self::gb:term">true</xsl:when>      
                        <xsl:otherwise>false</xsl:otherwise>
                </xsl:choose>
        </xsl:variable>

        <xsl:if test="$skip = 'false'">         

                <xsl:variable name="section">
                        <xsl:call-template name="getSection"/>
                </xsl:variable>

                <xsl:variable name="title">
                        <xsl:call-template name="getName"/>
                </xsl:variable>

                <xsl:variable name="type">
                        <xsl:value-of select="local-name()"/>
                </xsl:variable>

                <item id="{@id}" level="{$level}" section="{$section}" type="{$type}" display="{$display}">
                        <title>
                                <xsl:apply-templates select="xalan:nodeset($title)" mode="contents_item"/>
                        </title>
                        <xsl:apply-templates mode="contents"/>
                </item>

        </xsl:if>       

</xsl:template>

<xsl:template name="getListItemFormat">
        <xsl:choose>
                <xsl:when test="local-name(..) = 'ul'">—</xsl:when> <!-- dash -->
                <xsl:otherwise> <!-- for ordered lists -->
                        <xsl:choose>
                                <xsl:when test="../@type = 'arabic'">
                                        <xsl:number format="a)"/>
                                </xsl:when>
                                <xsl:when test="../@type = 'alphabet'">
                                        <xsl:number format="a)"/>
                                </xsl:when>
                                <xsl:otherwise>
                                        <xsl:number format="1."/>
                                </xsl:otherwise>
                        </xsl:choose>
                </xsl:otherwise>
        </xsl:choose>
</xsl:template>

<!-- ============================= -->
<!-- ============================= -->

<xsl:template match="*[local-name() = 'tab']" priority="2">
        <fo:inline><xsl:value-of select="$tab_zh"/></fo:inline>
</xsl:template>

<xsl:template match="gb:license-statement//gb:title">
        <fo:block text-align="center" font-weight="bold">
                <xsl:apply-templates/>
        </fo:block>
</xsl:template>

<xsl:template match="gb:license-statement//gb:p">
        <fo:block margin-left="1.5mm" margin-right="1.5mm">
                <xsl:if test="following-sibling::gb:p">
                        <xsl:attribute name="margin-top">6pt</xsl:attribute>
                        <xsl:attribute name="margin-bottom">6pt</xsl:attribute>
                </xsl:if>
                <xsl:apply-templates/>
        </fo:block>
</xsl:template>

<!-- <fo:block margin-bottom="12pt">© ISO 2019, Published in Switzerland.</fo:block>
                <fo:block font-size="10pt" margin-bottom="12pt">All rights reserved. Unless otherwise specified, no part of this publication may be reproduced or utilized otherwise in any form or by any means, electronic or mechanical, including photocopying, or posting on the internet or an intranet, without prior written permission. Permission can be requested from either ISO at the address below or ISO’s member body in the country of the requester.</fo:block>
                <fo:block font-size="10pt" text-indent="7.1mm">
                        <fo:block>ISO copyright office</fo:block>
                        <fo:block>Ch. de Blandonnet 8 • CP 401</fo:block>
                        <fo:block>CH-1214 Vernier, Geneva, Switzerland</fo:block>
                        <fo:block>Tel.  + 41 22 749 01 11</fo:block>
                        <fo:block>Fax  + 41 22 749 09 47</fo:block>
                        <fo:block>copyright@iso.org</fo:block>
                        <fo:block>www.iso.org</fo:block>
                </fo:block> -->

<xsl:template match="gb:copyright-statement//gb:p">
        <fo:block>
                <xsl:if test="preceding-sibling::gb:p">
                        <!-- <xsl:attribute name="font-size">10pt</xsl:attribute> -->
                </xsl:if>
                <xsl:if test="following-sibling::gb:p">
                        <!-- <xsl:attribute name="margin-bottom">12pt</xsl:attribute> -->
                        <xsl:attribute name="margin-bottom">3pt</xsl:attribute>
                </xsl:if>
                <xsl:if test="contains(@id, 'address')"> <!-- not(following-sibling::gb:p) -->
                        <!-- <xsl:attribute name="margin-left">7.1mm</xsl:attribute> -->
                        <xsl:attribute name="margin-left">4mm</xsl:attribute>
                </xsl:if>
                <xsl:apply-templates/>
        </fo:block>
</xsl:template>

<!-- ====== -->
<!-- title      -->
<!-- ====== -->

<xsl:template match="gb:annex/gb:title">
        <xsl:variable name="level">
                <xsl:call-template name="getLevel"/>
        </xsl:variable>
        <xsl:variable name="font-family">
                <xsl:choose>
                        <xsl:when test="$level &gt;= 3">SimSun</xsl:when>
                        <xsl:otherwise>SimHei</xsl:otherwise>
                </xsl:choose>
        </xsl:variable>         
        <fo:block font-family="{$font-family}" font-size="10.5pt" text-align="center" margin-bottom="24pt" keep-with-next="always">                     
                <xsl:apply-templates/>
        </fo:block>
</xsl:template>

<!-- Bibliography -->
<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>

<xsl:template match="gb:title">

        <xsl:variable name="level">
                <xsl:call-template name="getLevel"/>
        </xsl:variable>

        <xsl:variable name="element-name">
                <xsl:choose>
                        <xsl:when test="../@inline-header = 'true'">fo:inline</xsl:when>
                        <xsl:otherwise>fo:block</xsl:otherwise>
                </xsl:choose>
        </xsl:variable>

        <xsl:variable name="font-family">
                <xsl:choose>
                        <xsl:when test="ancestor::gb:annex and $level &gt;= 3">SimSun</xsl:when>
                        <xsl:when test="$element-name = 'fo:inline'">SimSun</xsl:when>
                        <xsl:otherwise>SimHei</xsl:otherwise>
                </xsl:choose>
        </xsl:variable>

        <xsl:variable name="font-size">
                <xsl:choose>
                        <xsl:when test="ancestor::gb:preface">16pt</xsl:when>
                        <xsl:otherwise>10.5pt</xsl:otherwise>
                </xsl:choose>
        </xsl:variable>

        <xsl:element name="{$element-name}">
                <xsl:attribute name="font-size"><xsl:value-of select="$font-size"/></xsl:attribute>
                <xsl:attribute name="font-family"><xsl:value-of select="$font-family"/></xsl:attribute>
                <xsl:attribute name="margin-top">
                        <xsl:choose>
                                <xsl:when test="ancestor::gb:preface">8pt</xsl:when>
                                <xsl:when test="$level = 2 and ancestor::gb:annex">10pt</xsl:when>
                                <xsl:when test="$level = 1">16pt</xsl:when>
                                <xsl:when test="$level = ''">6pt</xsl:when>
                                <xsl:when test="$level &gt;= 5">6pt</xsl:when>
                                <xsl:otherwise>12pt</xsl:otherwise>
                        </xsl:choose>
                </xsl:attribute>
                <xsl:attribute name="margin-bottom">
                        <xsl:choose>
                                <xsl:when test="ancestor::gb:preface">24pt</xsl:when>
                                <xsl:when test="$level = 1">16pt</xsl:when>
                                <xsl:when test="$level &gt;= 5">6pt</xsl:when>
                                <xsl:otherwise>8pt</xsl:otherwise>
                        </xsl:choose>
                </xsl:attribute>

                <xsl:attribute name="keep-with-next">always</xsl:attribute>             
                <xsl:if test="ancestor::gb:preface">
                        <xsl:attribute name="text-align">center</xsl:attribute>
                        <xsl:attribute name="font-family">SimHei</xsl:attribute>
                </xsl:if>
                <xsl:if test="$element-name = 'fo:inline'">
                        <xsl:attribute name="padding-left">7.4mm</xsl:attribute>                                
                        <xsl:attribute name="font-weight">bold</xsl:attribute>                          
                </xsl:if>

                <xsl:apply-templates/>

                <xsl:if test="$element-name = 'fo:inline'">
                        <xsl:value-of select="$tab_zh"/>
                </xsl:if>

        </xsl:element>

        <xsl:if test="$element-name = 'fo:inline' and not(following-sibling::gb:p)">
                <!-- <fo:block> -->
                        <xsl:value-of select="$linebreak"/>
                <!-- </fo:block> -->
        </xsl:if>

</xsl:template> 
<!-- ====== -->
<!-- ====== -->

<xsl:template match="gb:p">             
        <xsl:variable name="previous-element" select="local-name(preceding-sibling::*[1])"/>
        <xsl:variable name="element-name">
                <xsl:choose>                            
                        <xsl:when test="../@inline-header = 'true' and $previous-element = 'title'">fo:inline</xsl:when> <!-- first paragraph after inline title -->                            
                        <xsl:otherwise>fo:block</xsl:otherwise>
                </xsl:choose>
        </xsl:variable>
        <xsl:element name="{$element-name}">
                <xsl:attribute name="text-align">
                        <xsl:choose>
                                <xsl:when test="@align"><xsl:value-of select="@align"/></xsl:when>
                                <xsl:when test="ancestor::gb:td/@align"><xsl:value-of select="ancestor::gb:td/@align"/></xsl:when>
                                <xsl:when test="ancestor::gb:th/@align"><xsl:value-of select="ancestor::gb:th/@align"/></xsl:when>
                                <xsl:otherwise>justify</xsl:otherwise>
                        </xsl:choose>
                </xsl:attribute>
                <xsl:attribute name="text-indent">
                        <xsl:choose>
                                <xsl:when test="parent::gb:li">0mm</xsl:when>
                                <xsl:when test="parent::gb:dd">0mm</xsl:when>
                                <xsl:otherwise>7.4mm</xsl:otherwise>
                        </xsl:choose>
                </xsl:attribute>
                <xsl:if test="parent::gb:dd and ancestor::*[local-name()='formula']">
                        <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:if>               
</xsl:template>

<xsl:template match="gb:li//gb:p//text()">
        <xsl:choose>
                <xsl:when test="contains(., '&#9;')">
                        <fo:inline white-space="pre"><xsl:value-of select="."/></fo:inline>
                </xsl:when>
                <xsl:otherwise>
                        <xsl:value-of select="."/>
                </xsl:otherwise>
        </xsl:choose>

</xsl:template>

<!--
<fn reference="1">
                <p id="_8e5cf917-f75a-4a49-b0aa-1714cb6cf954">Formerly denoted as 15 % (m/m).</p>
        </fn>
-->

<xsl:variable name="p_fn">
        <xsl:for-each select="//gb:p/gb:fn[generate-id(.)=generate-id(key('kfn',@reference)[1])]">
                <!-- copy unique fn -->
                <fn gen_id="{generate-id(.)}">
                        <xsl:copy-of select="@*"/>
                        <xsl:copy-of select="node()"/>
                </fn>
        </xsl:for-each>
</xsl:variable>

<xsl:template match="gb:p/gb:fn" priority="2">
        <xsl:variable name="gen_id" select="generate-id(.)"/>
        <xsl:variable name="reference" select="@reference"/>
        <xsl:variable name="number">
                <xsl:value-of select="count(xalan:nodeset($p_fn)//fn[@reference = $reference]/preceding-sibling::fn) + 1"/>
        </xsl:variable>
        <xsl:choose>
                <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[@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[@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>
                                </fo:footnote-body>
                        </fo:footnote>
                </xsl:when>
                <xsl:otherwise>
                        <fo:inline font-size="50%" 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="$number + count(//gb:bibitem/gb:note)"/>
                                </fo:basic-link>
                        </fo:inline>
                </xsl:otherwise>
        </xsl:choose>
</xsl:template>

<xsl:template match="gb:p/gb:fn/gb:p">
        <xsl:apply-templates/>
</xsl:template>

<xsl:template match="gb:bibitem">
        <fo:block id="{@id}" font-size="11pt" margin-bottom="12pt" text-indent="-11.7mm" margin-left="11.7mm"> <!-- 12 pt -->
                        <!-- gb:docidentifier -->
                <xsl:if test="gb:docidentifier">
                        <xsl:choose>
                                <xsl:when test="gb:docidentifier/@type = 'metanorma'"/>
                                <xsl:otherwise><fo:inline><xsl:value-of select="gb:docidentifier"/></fo:inline></xsl:otherwise>
                        </xsl:choose>
                </xsl:if>
                <xsl:apply-templates select="gb:note"/>
                <xsl:if test="gb:docidentifier">, </xsl:if>
                <fo:inline font-style="italic">
                        <xsl:choose>
                                <xsl:when test="gb:title[@type = 'main' and @language = 'en']">
                                        <xsl:value-of select="gb:title[@type = 'main' and @language = 'en']"/>
                                </xsl:when>
                                <xsl:otherwise>
                                        <xsl:value-of select="gb:title"/>
                                </xsl:otherwise>
                        </xsl:choose>
                </fo:inline>
        </fo:block>
</xsl:template>

<xsl:template match="gb:bibitem/gb:note" priority="2">
        <fo:footnote>
                <xsl:variable name="number">
                        <xsl:number level="any" count="gb:bibitem/gb:note"/>
                </xsl:variable>
                <fo:inline font-size="50%" keep-with-previous.within-line="always" baseline-shift="30%">
                        <fo:basic-link internal-destination="{generate-id()}" fox:alt-text="footnote {$number}">
                                <xsl:value-of select="$number"/>
                        </fo:basic-link>
                </fo:inline>
                <fo:footnote-body>
                        <fo:block font-size="9pt" margin-bottom="4pt" start-indent="0pt" text-indent="7.4mm">
                                <fo:inline font-size="50%" id="{generate-id()}" keep-with-next.within-line="always" baseline-shift="30%"><!-- alignment-baseline="hanging" font-size="60%"  -->
                                        <xsl:value-of select="$number"/>
                                </fo:inline>
                                <xsl:apply-templates/>
                        </fo:block>
                </fo:footnote-body>
        </fo:footnote>
</xsl:template>

<xsl:template match="gb:ul | gb:ol" mode="ul_ol">
        <fo:list-block margin-bottom="12pt" margin-left="7.4mm" provisional-distance-between-starts="4mm"> <!--   margin-bottom="8pt" -->
                <xsl:if test="local-name() = 'ol'">
                        <xsl:attribute name="provisional-distance-between-starts">7mm</xsl:attribute>
                </xsl:if>                       
                <xsl:apply-templates/>
        </fo:list-block>
        <xsl:for-each select="./gb:note">
                <xsl:call-template name="note"/>
        </xsl:for-each>
</xsl:template>

<xsl:template match="gb:ul//gb:note |  gb:ol//gb:note" priority="2"/>

<xsl:template match="gb:li">
        <fo:list-item id="{@id}">
                <fo:list-item-label end-indent="label-end()">
                        <fo:block>
                                <xsl:call-template name="getListItemFormat"/>
                        </fo:block>
                </fo:list-item-label>
                <fo:list-item-body start-indent="body-start()">
                        <fo:block>
                                <xsl:apply-templates/>
                                <xsl:apply-templates select=".//gb:note" mode="process"/>
                        </fo:block>
                </fo:list-item-body>
        </fo:list-item>
</xsl:template>

<xsl:template match="gb:note" mode="process">
        <xsl:call-template name="note"/>
</xsl:template>

<xsl:template match="gb:preferred" priority="2">

        <fo:inline font-family="SimHei" font-size="11pt">
                <xsl:if test="not(preceding-sibling::*[1][local-name() = 'preferred'])">
                        <xsl:attribute name="padding-left">7.4mm</xsl:attribute>
                </xsl:if>
                <xsl:apply-templates/><xsl:value-of select="$tab_zh"/>
        </fo:inline>

        <xsl:if test="not(following-sibling::*[1][local-name() = 'preferred'])">
                <xsl:value-of select="$linebreak"/>
        </xsl:if>

</xsl:template>

<xsl:template match="gb:admitted" priority="2">

        <fo:inline font-size="11pt">
                <xsl:if test="not(preceding-sibling::*[1][local-name() = 'admitted'])">
                        <xsl:attribute name="padding-left">7.4mm</xsl:attribute>
                </xsl:if>                       
                <xsl:apply-templates/><xsl:value-of select="$tab_zh"/>
        </fo:inline>

        <xsl:if test="not(following-sibling::*[1][local-name() = 'admitted'])">
                <xsl:value-of select="$linebreak"/>
        </xsl:if>

</xsl:template>

<xsl:template match="gb:deprecates" priority="2">               
        <fo:inline font-size="11pt">
                <xsl:if test="not(preceding-sibling::*[1][local-name() = 'deprecates'])">
                        <xsl:attribute name="padding-left">7.4mm</xsl:attribute>
                        <xsl:variable name="title-deprecated">
                                <xsl:call-template name="getTitle">
                                        <xsl:with-param name="name" select="'title-deprecated'"/>
                                </xsl:call-template>
                        </xsl:variable>
                        <fo:inline><xsl:value-of select="$title-deprecated"/>: </fo:inline>
                </xsl:if>
                <xsl:apply-templates/>
        </fo:inline>
        <xsl:if test="not(following-sibling::*[1][local-name() = 'deprecates'])">
                <xsl:value-of select="$linebreak"/>
        </xsl:if>               
</xsl:template>

<xsl:template match="gb:termnote" priority="2">
        <fo:block-container font-size="9pt" margin-left="7.4mm" margin-top="4pt" line-height="125%">
                <fo:block-container margin-left="0mm">
                        <fo:table table-layout="fixed" width="100%">
                                <fo:table-column column-width="27mm"/>
                                <fo:table-column column-width="138mm"/>
                                <fo:table-body>
                                        <fo:table-row>
                                                <fo:table-cell>
                                                        <fo:block font-family="SimHei">
                                                                <xsl:apply-templates select="gb:name" mode="presentation"/>                                                                     
                                                        </fo:block>
                                                </fo:table-cell>
                                                <fo:table-cell>
                                                        <fo:block>
                                                                <xsl:apply-templates/>
                                                        </fo:block>
                                                </fo:table-cell>
                                        </fo:table-row>
                                </fo:table-body>
                        </fo:table>
                </fo:block-container>
        </fo:block-container>
</xsl:template>

<!-- <xsl:template match="gb:references[@id = '_bibliography']"> -->
<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">
                <fo:block-container margin-left="63mm" width="42mm" border-bottom="2pt solid black">
                        <fo:block> </fo:block>
                </fo:block-container>
        </fo:block-container>
</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[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}">
                                                <xsl:number format="[1]"/>
                                        </fo:inline>
                                </fo:block>
                        </fo:list-item-label>
                        <fo:list-item-body start-indent="body-start()">
                                <fo:block text-align="justify">
                                        <xsl:variable name="docidentifier">
                                                <xsl:if test="gb:docidentifier">
                                                        <xsl:choose>
                                                                <xsl:when test="gb:docidentifier/@type = 'metanorma'"/>
                                                                <xsl:otherwise><xsl:value-of select="gb:docidentifier"/></xsl:otherwise>
                                                        </xsl:choose>
                                                </xsl:if>
                                        </xsl:variable>
                                        <fo:inline><xsl:value-of select="$docidentifier"/></fo:inline>
                                        <xsl:apply-templates select="gb:note"/>
                                        <xsl:if test="normalize-space($docidentifier) != ''">, </xsl:if>
                                        <xsl:choose>
                                                <xsl:when test="gb:title[@type = 'main' and @language = 'en']">
                                                        <xsl:apply-templates select="gb:title[@type = 'main' and @language = 'en']"/>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                        <xsl:apply-templates select="gb:title"/>
                                                </xsl:otherwise>
                                        </xsl:choose>
                                        <xsl:apply-templates select="gb:formattedref"/>
                                </fo:block>
                        </fo:list-item-body>
                </fo:list-item>
        </fo:list-block>
</xsl:template>

<!-- <xsl:template match="gb:references[@id = '_bibliography']/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[not(@normative='true')]/gb:bibitem/gb:title">
        <fo:inline font-style="italic">
                <xsl:apply-templates/>
        </fo:inline>
</xsl:template>

<xsl:template match="mathml:math" priority="2">
        <fo:inline font-family="Cambria Math">
                <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="gb:admonition">
        <xsl:variable name="title-caution">
                <xsl:call-template name="getTitle">
                        <xsl:with-param name="name" select="'title-caution'"/>
                </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="title-warning">
                <xsl:call-template name="getTitle">
                        <xsl:with-param name="name" select="'title-warning'"/>
                </xsl:call-template>
        </xsl:variable>
        <fo:block font-family="SimHei" text-align="center" margin-bottom="12pt" font-weight="bold">
                <xsl:choose>
                        <xsl:when test="@type = 'caution'"><xsl:value-of select="$title-caution"/></xsl:when>
                        <xsl:when test="@type = 'warning'"><xsl:value-of select="$title-warning"/></xsl:when>
                        <xsl:otherwise><xsl:value-of select="java:toUpperCase(java:java.lang.String.new(@type))"/></xsl:otherwise>
                </xsl:choose>                   
        </fo:block>
        <fo:block font-weight="bold">
                <xsl:apply-templates/>
        </fo:block>
</xsl:template>

<xsl:template match="gb:formula/gb:stem">
        <fo:block margin-top="14pt" margin-bottom="14pt">
                <xsl:if test="not(ancestor::*[local-name()='note'])">
                        <xsl:attribute name="font-size">11pt</xsl:attribute>
                </xsl:if>
                <fo:table table-layout="fixed" width="100%"> <!-- width="170mm" -->
                        <fo:table-column column-width="95%"/><!-- 165mm -->
                        <fo:table-column column-width="5%"/> <!-- 5mm -->
                        <fo:table-body>
                                <fo:table-row>
                                        <fo:table-cell display-align="center">
                                                <fo:block text-align="center">
                                                        <xsl:apply-templates/>
                                                </fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell display-align="center">
                                                <fo:block text-align="left">
                                                        <xsl:apply-templates select="../gb:name" mode="presentation"/>
                                                </fo:block>
                                        </fo:table-cell>
                                </fo:table-row>
                        </fo:table-body>
                </fo:table>                     
        </fo:block>
</xsl:template>

<xsl:template name="insertHeaderFooter">
        <fo:static-content flow-name="header">
                <fo:block-container height="30mm" display-align="after">
                        <fo:block font-family="SimHei" font-size="12pt">
                                <xsl:value-of select="/gb:gb-standard/gb:bibdata/gb:docidentifier[@type = 'gb']"/>
                                <xsl:text>—</xsl:text>
                                <xsl:value-of select="/gb:gb-standard/gb:bibdata/gb:copyright/gb:from"/>
                        </fo:block>
                </fo:block-container>
        </fo:static-content>
        <fo:static-content flow-name="footer-odd">
                <fo:block-container height="100%" display-align="after">
                        <fo:block-container height="14.5mm" display-align="before">
                                <fo:block font-size="9pt" text-align="right" margin-right="3.5mm">
                                        <fo:page-number/>
                                </fo:block>
                        </fo:block-container>
                </fo:block-container>
        </fo:static-content>
        <fo:static-content flow-name="footer-even">
                <fo:block-container height="100%" display-align="after">
                        <fo:block-container height="14.5mm" display-align="before">
                                <fo:block font-size="9pt">
                                        <fo:page-number/>
                                </fo:block>
                        </fo:block-container>
                </fo:block-container>
        </fo:static-content>
</xsl:template>

<xsl:template name="addLetterSpacing">
        <xsl:param name="text"/>
        <xsl:param name="letter-spacing" select="'0.15'"/>
        <xsl:if test="string-length($text) &gt; 0">
                <xsl:variable name="char" select="substring($text, 1, 1)"/>
                <fo:inline padding-right="{$letter-spacing}mm"><xsl:value-of select="$char"/></fo:inline>
                <xsl:call-template name="addLetterSpacing">
                        <xsl:with-param name="text" select="substring($text, 2)"/>
                        <xsl:with-param name="letter-spacing" select="$letter-spacing"/>
                </xsl:call-template>
        </xsl:if>
</xsl:template>

<xsl:variable name=“titles” select=“xalan:nodeset($titles_)”/><xsl:variable name=“titles_”>

              <title-annex lang="en">Annex </title-annex>
              <title-annex lang="fr">Annexe </title-annex>

                      <title-annex lang="zh">附件 </title-annex>                        

              <title-edition lang="en">

              </title-edition>

              <title-edition lang="fr">

              </title-edition>

              <title-toc lang="en">

                              <xsl:text>Table of contents</xsl:text>

              </title-toc>
              <title-toc lang="fr">

                              <xsl:text>Sommaire</xsl:text>

                      </title-toc>

                      <title-toc lang="zh">目次</title-toc>                     

              <title-page lang="en">Page</title-page>
              <title-page lang="fr">Page</title-page>

              <title-key lang="en">Key</title-key>
              <title-key lang="fr">Légende</title-key>

              <title-where lang="en">where</title-where>
              <title-where lang="fr">où</title-where>

              <title-descriptors lang="en">Descriptors</title-descriptors>

              <title-part lang="en">

                              <xsl:text>Part #: </xsl:text>

              </title-part>
              <title-part lang="fr">

                              <xsl:text>Partie #:  </xsl:text>

              </title-part>           
              <title-part lang="zh">第 # 部分:</title-part>

              <title-modified lang="en">modified</title-modified>
              <title-modified lang="fr">modifiée</title-modified>

                      <title-modified lang="zh">改写</title-modified>                   

              <title-source lang="en">

                              <xsl:text>SOURCE</xsl:text>

              </title-source>

              <title-keywords lang="en">Keywords</title-keywords>

              <title-deprecated lang="en">DEPRECATED</title-deprecated>
              <title-deprecated lang="fr">DEPRECATED</title-deprecated>

              <title-list-tables lang="en">List of Tables</title-list-tables>

              <title-list-figures lang="en">List of Figures</title-list-figures>

              <title-list-recommendations lang="en">List of Recommendations</title-list-recommendations>

              <title-acknowledgements lang="en">Acknowledgements</title-acknowledgements>

              <title-abstract lang="en">Abstract</title-abstract>

              <title-summary lang="en">Summary</title-summary>

              <title-in lang="en">in </title-in>

              <title-partly-supercedes lang="en">Partly Supercedes </title-partly-supercedes>
              <title-partly-supercedes lang="zh">部分代替 </title-partly-supercedes>

              <title-completion-date lang="en">Completion date for this manuscript</title-completion-date>
              <title-completion-date lang="zh">本稿完成日期</title-completion-date>

              <title-issuance-date lang="en">Issuance Date: #</title-issuance-date>
              <title-issuance-date lang="zh"># 发布</title-issuance-date>

              <title-implementation-date lang="en">Implementation Date: #</title-implementation-date>
              <title-implementation-date lang="zh"># 实施</title-implementation-date>

              <title-obligation-normative lang="en">normative</title-obligation-normative>
              <title-obligation-normative lang="zh">规范性附录</title-obligation-normative>

              <title-caution lang="en">CAUTION</title-caution>
              <title-caution lang="zh">注意</title-caution>

              <title-warning lang="en">WARNING</title-warning>
              <title-warning lang="zh">警告</title-warning>

              <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="tab_zh"> </xsl:variable><xsl:template name="getTitle">
              <xsl:param name="name"/>
              <xsl:param name="lang"/>
              <xsl:variable name="lang_">
                      <xsl:choose>
                              <xsl:when test="$lang != ''">
                                      <xsl:value-of select="$lang"/>
                              </xsl:when>
                              <xsl:otherwise>
                                      <xsl:call-template name="getLang"/>
                              </xsl:otherwise>
                      </xsl:choose>
              </xsl:variable>
              <xsl:variable name="language" select="normalize-space($lang_)"/>
              <xsl:variable name="title_" select="$titles/*[local-name() = $name][@lang = $language]"/>
              <xsl:choose>
                      <xsl:when test="normalize-space($title_) != ''">
                              <xsl:value-of select="$title_"/>
                      </xsl:when>
                      <xsl:otherwise>
                              <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>

                      <xsl:attribute name="font-family">Courier</xsl:attribute>                       
                      <xsl:attribute name="margin-bottom">12pt</xsl:attribute>

      </xsl:attribute-set><xsl:attribute-set name="permission-style">

      </xsl:attribute-set><xsl:attribute-set name="permission-name-style">

      </xsl:attribute-set><xsl:attribute-set name="permission-label-style">

      </xsl:attribute-set><xsl:attribute-set name="requirement-style">

      </xsl:attribute-set><xsl:attribute-set name="requirement-name-style">

      </xsl:attribute-set><xsl:attribute-set name="requirement-label-style">

      </xsl:attribute-set><xsl:attribute-set name="requirement-subject-style">
      </xsl:attribute-set><xsl:attribute-set name="requirement-inherit-style">
      </xsl:attribute-set><xsl:attribute-set name="recommendation-style">

      </xsl:attribute-set><xsl:attribute-set name="recommendation-name-style">

      </xsl:attribute-set><xsl:attribute-set name="recommendation-label-style">

      </xsl:attribute-set><xsl:attribute-set name="termexample-style">

                      <xsl:attribute name="font-size">9pt</xsl:attribute>
                      <xsl:attribute name="margin-top">14pt</xsl:attribute>
                      <xsl:attribute name="margin-bottom">14pt</xsl:attribute>
                      <xsl:attribute name="text-align">justify</xsl:attribute>

      </xsl:attribute-set><xsl:attribute-set name="example-style">

                      <xsl:attribute name="font-size">10pt</xsl:attribute>
                      <xsl:attribute name="margin-top">8pt</xsl:attribute>
                      <xsl:attribute name="margin-bottom">8pt</xsl:attribute>

      </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>

      </xsl:attribute-set><xsl:attribute-set name="example-p-style">

                      <xsl:attribute name="font-size">10pt</xsl:attribute>
                      <xsl:attribute name="margin-top">8pt</xsl:attribute>
                      <xsl:attribute name="margin-bottom">8pt</xsl:attribute>

      </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>                        

      </xsl:attribute-set><xsl:attribute-set name="table-name-style">
              <xsl:attribute name="keep-with-next">always</xsl:attribute>

                      <xsl:attribute name="text-align">center</xsl:attribute>
                      <xsl:attribute name="font-family">SimHei</xsl:attribute>
                      <xsl:attribute name="font-weight">normal</xsl:attribute>
                      <xsl:attribute name="margin-bottom">12pt</xsl:attribute>

      </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>
                      <xsl:attribute name="margin-bottom">12pt</xsl:attribute>

      </xsl:attribute-set><xsl:attribute-set name="appendix-example-style">

                      <xsl:attribute name="font-size">10pt</xsl:attribute>                    
                      <xsl:attribute name="margin-top">8pt</xsl:attribute>
                      <xsl:attribute name="margin-bottom">8pt</xsl:attribute>

      </xsl:attribute-set><xsl:attribute-set name="xref-style">

      </xsl:attribute-set><xsl:attribute-set name="eref-style">

      </xsl:attribute-set><xsl:attribute-set name="note-style">

                      <xsl:attribute name="font-size">9pt</xsl:attribute>
                      <xsl:attribute name="margin-left">7.4mm</xsl:attribute>
                      <xsl:attribute name="margin-top">4pt</xsl:attribute>
                      <xsl:attribute name="margin-bottom">4pt</xsl:attribute>
                      <xsl:attribute name="line-height">125%</xsl:attribute>

      </xsl:attribute-set><xsl:variable name="note-body-indent">10mm</xsl:variable><xsl:variable name="note-body-indent-table">5mm</xsl:variable><xsl:attribute-set name="note-name-style">

                      <xsl:attribute name="font-family">SimHei</xsl:attribute>

      </xsl:attribute-set><xsl:attribute-set name="note-p-style">

                      <xsl:attribute name="margin-top">4pt</xsl:attribute>
                      <xsl:attribute name="line-height">125%</xsl:attribute>
                      <xsl:attribute name="text-align">justify</xsl:attribute>                        

      </xsl:attribute-set><xsl:attribute-set name="termnote-style">

      </xsl:attribute-set><xsl:attribute-set name="termnote-name-style">              

      </xsl:attribute-set><xsl:attribute-set name="quote-style">              

                      <xsl:attribute name="margin-top">12pt</xsl:attribute>
                      <xsl:attribute name="margin-left">12mm</xsl:attribute>
                      <xsl:attribute name="margin-right">12mm</xsl:attribute>

      </xsl:attribute-set><xsl:attribute-set name="quote-source-style">               

                      <xsl:attribute name="text-align">right</xsl:attribute>                  

      </xsl:attribute-set><xsl:attribute-set name="termsource-style">

                      <xsl:attribute name="text-indent">7.4mm</xsl:attribute>

      </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">

                      <xsl:attribute name="font-family">SimHei</xsl:attribute>
                      <xsl:attribute name="text-align">center</xsl:attribute>
                      <xsl:attribute name="margin-top">12pt</xsl:attribute>
                      <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
                      <xsl:attribute name="keep-with-previous">always</xsl:attribute>

      </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>

      </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">100%</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>

      </xsl:attribute-set><xsl:attribute-set name="tt-style">

                      <xsl:attribute name="font-family">Courier</xsl:attribute>                       

      </xsl:attribute-set><xsl:attribute-set name="sourcecode-name-style">
              <xsl:attribute name="font-size">11pt</xsl:attribute>
              <xsl:attribute name="font-weight">bold</xsl:attribute>
              <xsl:attribute name="text-align">center</xsl:attribute>
              <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
              <xsl:attribute name="keep-with-previous">always</xsl:attribute>

      </xsl:attribute-set><xsl:attribute-set name="domain-style">

                      <xsl:attribute name="padding-left">7.4mm</xsl:attribute>

      </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: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"/> -->
              <xsl:call-template name="add-zero-spaces-java"/>
      </xsl:template><xsl:template match="*[local-name()='table']">

              <xsl:variable name="simple-table">      
                      <xsl:call-template name="getSimpleTable"/>                      
              </xsl:variable>

              <!-- $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: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: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:attribute name="font-size">10pt</xsl:attribute>

                      <xsl:variable name="table_attributes">
                              <attribute name="table-layout">fixed</attribute>
                              <attribute name="width">100%</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>

                      <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: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: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: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: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: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>-->

                              <xsl:apply-templates select="*[local-name()='note']" mode="process"/>

              </fo:block-container>
      </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">

                              <xsl:apply-templates/>                          
                      </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/*)"/>
              <xsl:variable name="sum-colspans" select="sum($table-row/*/@colspan)"/>
              <xsl:variable name="columns-with-colspan" select="count($table-row/*[@colspan])"/>
              <xsl:value-of select="$columns-count + $sum-colspans - $columns-with-colspan"/>
      </xsl:template><xsl:template name="calculate-column-widths">
              <xsl:param name="table"/>
              <xsl:param name="cols-count"/>
              <xsl:param name="curr-col" select="1"/>
              <xsl:param name="width" select="0"/>

              <xsl:if test="$curr-col &lt;= $cols-count">
                      <xsl:variable name="widths">
                              <xsl:choose>
                                      <xsl:when test="not($table)"><!-- this branch is not using in production, for debug only -->
                                              <xsl:for-each select="*[local-name()='thead']//*[local-name()='tr']">
                                                      <xsl:variable name="words">
                                                              <xsl:call-template name="tokenize">
                                                                      <xsl:with-param name="text" select="translate(*[local-name()='th'][$curr-col],'- —:', '    ')"/>
                                                              </xsl:call-template>
                                                      </xsl:variable>
                                                      <xsl:variable name="max_length">
                                                              <xsl:call-template name="max_length">
                                                                      <xsl:with-param name="words" select="xalan:nodeset($words)"/>
                                                              </xsl:call-template>
                                                      </xsl:variable>
                                                      <width>
                                                              <xsl:value-of select="$max_length"/>
                                                      </width>
                                              </xsl:for-each>
                                              <xsl:for-each select="*[local-name()='tbody']//*[local-name()='tr']">
                                                      <xsl:variable name="words">
                                                              <xsl:call-template name="tokenize">
                                                                      <xsl:with-param name="text" select="translate(*[local-name()='td'][$curr-col],'- —:', '    ')"/>
                                                              </xsl:call-template>
                                                      </xsl:variable>
                                                      <xsl:variable name="max_length">
                                                              <xsl:call-template name="max_length">
                                                                      <xsl:with-param name="words" select="xalan:nodeset($words)"/>
                                                              </xsl:call-template>
                                                      </xsl:variable>
                                                      <width>
                                                              <xsl:value-of select="$max_length"/>
                                                      </width>

                                              </xsl:for-each>
                                      </xsl:when>
                                      <xsl:otherwise>
                                              <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']">                                                                 
                                                                              <word><xsl:value-of select="normalize-space(.)"/></word>
                                                                      </xsl:for-each>
                                                              </xsl:if> -->

                                                      </xsl:variable>
                                                      <xsl:variable name="words">
                                                              <xsl:variable name="string_with_added_zerospaces">
                                                                      <xsl:call-template name="add-zero-spaces-java">
                                                                              <xsl:with-param name="text" select="$td_text"/>
                                                                      </xsl:call-template>
                                                              </xsl:variable>
                                                              <xsl:call-template name="tokenize">
                                                                      <!-- <xsl:with-param name="text" select="translate(td[$curr-col],'- —:', '    ')"/> -->
                                                                      <!-- 2009 thinspace -->
                                                                      <!-- <xsl:with-param name="text" select="translate(normalize-space($td_text),'- —:', '    ')"/> -->
                                                                      <xsl:with-param name="text" select="normalize-space(translate($string_with_added_zerospaces, '​', ' '))"/>
                                                              </xsl:call-template>
                                                      </xsl:variable>
                                                      <xsl:variable name="max_length">
                                                              <xsl:call-template name="max_length">
                                                                      <xsl:with-param name="words" select="xalan:nodeset($words)"/>
                                                              </xsl:call-template>
                                                      </xsl:variable>
                                                      <width>
                                                              <xsl:variable name="divider">
                                                                      <xsl:choose>
                                                                              <xsl:when test="td[$curr-col]/@divide">
                                                                                      <xsl:value-of select="td[$curr-col]/@divide"/>
                                                                              </xsl:when>
                                                                              <xsl:otherwise>1</xsl:otherwise>
                                                                      </xsl:choose>
                                                              </xsl:variable>
                                                              <xsl:value-of select="$max_length div $divider"/>
                                                      </width>

                                              </xsl:for-each>

                                      </xsl:otherwise>
                              </xsl:choose>
                      </xsl:variable>

                      <column>
                              <xsl:for-each select="xalan:nodeset($widths)//width">
                                      <xsl:sort select="." data-type="number" order="descending"/>
                                      <xsl:if test="position()=1">
                                                      <xsl:value-of select="."/>
                                      </xsl:if>
                              </xsl:for-each>
                      </column>
                      <xsl:call-template name="calculate-column-widths">
                              <xsl:with-param name="cols-count" select="$cols-count"/>
                              <xsl:with-param name="curr-col" select="$curr-col +1"/>
                              <xsl:with-param name="table" select="$table"/>
                      </xsl:call-template>
              </xsl:if>
      </xsl:template><xsl:template match="text()" mode="td_text">
              <xsl:variable name="zero-space">​</xsl:variable>
              <xsl:value-of select="translate(., $zero-space, ' ')"/><xsl:text> </xsl:text>
      </xsl:template><xsl:template match="*[local-name()='termsource']" mode="td_text">
              <xsl:value-of select="*[local-name()='origin']/@citeas"/>
      </xsl:template><xsl:template match="*[local-name()='link']" mode="td_text">
              <xsl:value-of select="@target"/>
      </xsl:template><xsl:template match="*[local-name()='math']" mode="td_text">
              <xsl:variable name="math_text" select="normalize-space(.)"/>
              <xsl:value-of select="translate($math_text, ' ', '#')"/><!-- mathml images as one 'word' without spaces -->
      </xsl:template><xsl:template match="*[local-name()='table2']"/><xsl:template match="*[local-name()='thead']"/><xsl:template match="*[local-name()='thead']" mode="process">
              <xsl:param name="cols-count"/>
              <!-- font-weight="bold" -->
              <fo:table-header>

                      <xsl:apply-templates/>
              </fo:table-header>
      </xsl:template><xsl:template name="table-header-title">
              <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: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>
                      </fo:table-cell>
              </fo:table-row>
      </xsl:template><xsl:template match="*[local-name()='thead']" mode="process_tbody">              
              <fo:table-body>
                      <xsl:apply-templates/>
              </fo:table-body>
      </xsl:template><xsl:template match="*[local-name()='tfoot']"/><xsl:template match="*[local-name()='tfoot']" mode="process">
              <xsl:apply-templates/>
      </xsl:template><xsl:template name="insertTableFooter">
              <xsl:param name="cols-count"/>
              <xsl:if test="../*[local-name()='tfoot']">
                      <fo:table-footer>                       
                              <xsl:apply-templates select="../*[local-name()='tfoot']" mode="process"/>
                      </fo:table-footer>
              </xsl:if>
      </xsl:template><xsl:template name="insertTableFooter2">
              <xsl:param name="cols-count"/>
              <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>
              <xsl:if test="../*[local-name()='tfoot'] or           $isNoteOrFnExist = 'true'">

                      <fo:table-footer>

                              <xsl:apply-templates select="../*[local-name()='tfoot']" mode="process"/>

                              <!-- if there are note(s) or fn(s) then create footer row -->
                              <xsl:if test="$isNoteOrFnExist = 'true'">

                                      <fo:table-row>
                                              <fo:table-cell border="solid black 1pt" padding-left="1mm" padding-right="1mm" padding-top="1mm" number-columns-spanned="{$cols-count}">

                                                              <xsl:attribute name="border-top">solid black 0pt</xsl:attribute>

                                                      <!-- fn will be processed inside 'note' processing -->

                                                      <!-- except gb -->

                                                      <!-- show Note under table in preface (ex. abstract) sections -->
                                                      <!-- empty, because notes show at page side in main sections -->
                                                      <!-- <xsl:if test="$namespace = 'bipm'">
                                                              <xsl:choose>
                                                                      <xsl:when test="ancestor::*[local-name()='preface']">                                                                           
                                                                              <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
                                                                      </xsl:when>
                                                                      <xsl:otherwise>                                                                         
                                                                      <fo:block/>
                                                                      </xsl:otherwise>
                                                              </xsl:choose>
                                                      </xsl:if> -->

                                                      <!-- horizontal row separator -->

                                                      <!-- fn processing -->
                                                      <xsl:call-template name="fn_display"/>

                                              </fo:table-cell>
                                      </fo:table-row>

                              </xsl:if>
                      </fo:table-footer>

              </xsl:if>
      </xsl:template><xsl:template name="insertTableFooterInSeparateTable">
              <xsl:param name="table_attributes"/>
              <xsl:param name="colwidths"/>

              <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ..//*[local-name()='fn'][local-name(..) != 'name']"/>

              <xsl:if test="$isNoteOrFnExist = 'true'">

                      <xsl:variable name="cols-count" select="count(xalan:nodeset($colwidths)//column)"/>

                      <fo:table keep-with-previous="always">
                              <xsl:for-each select="xalan:nodeset($table_attributes)/attribute">
                                      <xsl:choose>
                                              <xsl:when test="@name = 'border-top'">
                                                      <xsl:attribute name="{@name}">0pt solid black</xsl:attribute>
                                              </xsl:when>
                                              <xsl:when test="@name = 'border'">
                                                      <xsl:attribute name="{@name}"><xsl:value-of select="."/></xsl:attribute>
                                                      <xsl:attribute name="border-top">0pt solid black</xsl:attribute>
                                              </xsl:when>
                                              <xsl:otherwise>
                                                      <xsl:attribute name="{@name}"><xsl:value-of select="."/></xsl:attribute>
                                              </xsl:otherwise>
                                      </xsl:choose>
                              </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-body>
                                      <fo:table-row>
                                              <fo:table-cell border="solid black 1pt" padding-left="1mm" padding-right="1mm" padding-top="1mm" number-columns-spanned="{$cols-count}">

                                                              <xsl:attribute name="border-top">solid black 0pt</xsl:attribute>

                                                      <!-- fn will be processed inside 'note' processing -->

                                                      <!-- except gb  -->

                                                      <!-- <xsl:if test="$namespace = 'bipm'">
                                                              <xsl:choose>
                                                                      <xsl:when test="ancestor::*[local-name()='preface']">
                                                                              show Note under table in preface (ex. abstract) sections
                                                                              <xsl:apply-templates select="../*[local-name()='note']" mode="process"/>
                                                                      </xsl:when>
                                                                      <xsl:otherwise>
                                                                              empty, because notes show at page side in main sections
                                                                      <fo:block/>
                                                                      </xsl:otherwise>
                                                              </xsl:choose>
                                                      </xsl:if> -->

                                                      <!-- horizontal row separator -->

                                                      <!-- fn processing -->
                                                      <xsl:call-template name="fn_display"/>

                                              </fo:table-cell>
                                      </fo:table-row>
                              </fo:table-body>

                      </fo:table>
              </xsl:if>
      </xsl:template><xsl:template match="*[local-name()='tbody']">

              <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()='tr'][1]"/>
                                      </xsl:call-template>
                              </xsl:otherwise>
                      </xsl:choose>
              </xsl:variable>

              <xsl:apply-templates select="../*[local-name()='thead']" mode="process">
                      <xsl:with-param name="cols-count" select="$cols-count"/>
              </xsl:apply-templates>

              <xsl:call-template name="insertTableFooter">
                      <xsl:with-param name="cols-count" select="$cols-count"/>
              </xsl:call-template>

              <fo:table-body>

                      <xsl:apply-templates/>
                      <!-- <xsl:apply-templates select="../*[local-name()='tfoot']" mode="process"/> -->

              </fo:table-body>

      </xsl:template><xsl:template match="*[local-name()='tr']">
              <xsl:variable name="parent-name" select="local-name(..)"/>
              <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
              <fo:table-row min-height="4mm">
                              <xsl:if test="$parent-name = 'thead'">
                                      <xsl:attribute name="font-weight">bold</xsl:attribute>

                              </xsl:if>
                              <xsl:if test="$parent-name = 'tfoot'">

                              </xsl:if>

                                      <xsl:attribute name="min-height">0mm</xsl:attribute>
                                      <xsl:attribute name="line-height">110%</xsl:attribute>

                              <!-- <xsl:if test="$namespace = 'bipm'">
                                      <xsl:attribute name="height">8mm</xsl:attribute>
                              </xsl:if> -->

                      <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>
                      <xsl:if test="@rowspan">
                              <xsl:attribute name="number-rows-spanned">
                                      <xsl:value-of select="@rowspan"/>
                              </xsl:attribute>
                      </xsl:if>
                      <xsl:call-template name="display-align"/>
                      <fo:block>
                              <xsl:apply-templates/>
                      </fo:block>
              </fo:table-cell>
      </xsl:template><xsl:template name="display-align">
              <xsl:if test="@valign">
                      <xsl:attribute name="display-align">
                              <xsl:choose>
                                      <xsl:when test="@valign = 'top'">before</xsl:when>
                                      <xsl:when test="@valign = 'middle'">center</xsl:when>
                                      <xsl:when test="@valign = 'bottom'">after</xsl:when>
                                      <xsl:otherwise>before</xsl:otherwise>
                              </xsl:choose>                                   
                      </xsl:attribute>
              </xsl:if>
      </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']">
                                      <xsl:attribute name="border-bottom">solid black 0</xsl:attribute>
                              </xsl:if>

                      <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:call-template name="display-align"/>
                      <fo:block>                                                              
                              <xsl:apply-templates/>
                      </fo:block>                     
              </fo:table-cell>
      </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']" priority="2"/><xsl:template match="*[local-name()='table']/*[local-name()='note']" mode="process">

                      <fo:block font-size="10pt" margin-bottom="12pt">

                                      <xsl:attribute name="font-size">9pt</xsl:attribute>
                                      <xsl:attribute name="text-align">center</xsl:attribute>
                                      <xsl:attribute name="margin-bottom">6pt</xsl:attribute>

                              <fo:inline padding-right="2mm">

                                              <xsl:attribute name="font-family">SimHei</xsl:attribute>

                                      <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/>

                              </fo:inline>

                              <xsl:apply-templates mode="process"/>
                      </fo:block>

      </xsl:template><xsl:template match="*[local-name()='table']/*[local-name()='note']/*[local-name()='name']" mode="process"/><xsl:template match="*[local-name()='table']/*[local-name()='note']/*[local-name()='p']" mode="process">
              <xsl:apply-templates/>
      </xsl:template><xsl:template name="fn_display">
              <xsl:variable name="references">
                      <xsl:for-each select="..//*[local-name()='fn'][local-name(..) != 'name']">
                              <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">

                                      <xsl:apply-templates/>
                              </fn>
                      </xsl:for-each>
              </xsl:variable>
              <xsl:for-each select="xalan:nodeset($references)//fn">
                      <xsl:variable name="reference" select="@reference"/>
                      <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
                              <fo:block margin-bottom="12pt">

                                              <xsl:attribute name="text-indent">7.4mm</xsl:attribute>
                                              <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
                                              <xsl:attribute name="line-height">130%</xsl:attribute>

                                      <fo:inline font-size="80%" padding-right="5mm" id="{@id}">

                                                      <xsl:attribute name="vertical-align">super</xsl:attribute>

                                                      <xsl:attribute name="font-size">50%</xsl:attribute>                                                     

                                              <xsl:value-of select="@reference"/>

                                      </fo:inline>
                                      <fo:inline>

                                              <!-- <xsl:apply-templates /> -->
                                              <xsl:copy-of select="./node()"/>
                                      </fo:inline>
                              </fo:block>
                      </xsl:if>
              </xsl:for-each>
      </xsl:template><xsl:template name="fn_name_display">
              <!-- <xsl:variable name="references">
                      <xsl:for-each select="*[local-name()='name']//*[local-name()='fn']">
                              <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
                                      <xsl:apply-templates />
                              </fn>
                      </xsl:for-each>
              </xsl:variable>
              $references=<xsl:copy-of select="$references"/> -->
              <xsl:for-each select="*[local-name()='name']//*[local-name()='fn']">
                      <xsl:variable name="reference" select="@reference"/>
                      <fo:block id="{@reference}_{ancestor::*[@id][1]/@id}"><xsl:value-of select="@reference"/></fo:block>
                      <fo:block margin-bottom="12pt">
                              <xsl:apply-templates/>
                      </fo:block>
              </xsl:for-each>
      </xsl:template><xsl:template name="fn_display_figure">
              <xsl:variable name="key_iso">
                      true <!-- and (not(@class) or @class !='pseudocode') -->
              </xsl:variable>
              <xsl:variable name="references">
                      <xsl:for-each select=".//*[local-name()='fn'][not(parent::*[local-name()='name'])]">
                              <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}">
                                      <xsl:apply-templates/>
                              </fn>
                      </xsl:for-each>
              </xsl:variable>

              <!-- current hierarchy is 'figure' element -->
              <xsl:variable name="following_dl_colwidths">
                      <xsl:if test="*[local-name() = 'dl']"><!-- if there is a 'dl', then set the same columns width as for 'dl' -->
                              <xsl:variable name="html-table">
                                      <xsl:variable name="doc_ns">

                                      </xsl:variable>
                                      <xsl:variable name="ns">
                                              <xsl:choose>
                                                      <xsl:when test="normalize-space($doc_ns)  != ''">
                                                              <xsl:value-of select="normalize-space($doc_ns)"/>
                                                      </xsl:when>
                                                      <xsl:otherwise>
                                                              <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:for-each select="*[local-name() = 'dl'][1]">
                                                      <tbody>
                                                              <xsl:apply-templates mode="dl"/>
                                                      </tbody>
                                              </xsl:for-each>
                                      </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"/>
                              </xsl:call-template>

                      </xsl:if>
              </xsl:variable>

              <xsl:variable name="maxlength_dt">
                      <xsl:for-each select="*[local-name() = 'dl'][1]">
                              <xsl:call-template name="getMaxLength_dt"/>                     
                      </xsl:for-each>
              </xsl:variable>

              <xsl:if test="xalan:nodeset($references)//fn">
                      <fo:block>
                              <fo:table width="95%" table-layout="fixed">
                                      <xsl:if test="normalize-space($key_iso) = 'true'">
                                              <xsl:attribute name="font-size">10pt</xsl:attribute>

                                      </xsl:if>
                                      <xsl:choose>
                                              <!-- if there 'dl', then set same columns width -->
                                              <xsl:when test="xalan:nodeset($following_dl_colwidths)//column">
                                                      <xsl:call-template name="setColumnWidth_dl">
                                                              <xsl:with-param name="colwidths" select="$following_dl_colwidths"/>                                                             
                                                              <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>                                                            
                                                      </xsl:call-template>
                                              </xsl:when>
                                              <xsl:otherwise>
                                                      <fo:table-column column-width="15%"/>
                                                      <fo:table-column column-width="85%"/>
                                              </xsl:otherwise>
                                      </xsl:choose>
                                      <fo:table-body>
                                              <xsl:for-each select="xalan:nodeset($references)//fn">
                                                      <xsl:variable name="reference" select="@reference"/>
                                                      <xsl:if test="not(preceding-sibling::*[@reference = $reference])"> <!-- only unique reference puts in note-->
                                                              <fo:table-row>
                                                                      <fo:table-cell>
                                                                              <fo:block>
                                                                                      <fo:inline font-size="80%" padding-right="5mm" vertical-align="super" id="{@id}">

                                                                                              <xsl:value-of select="@reference"/>
                                                                                      </fo:inline>
                                                                              </fo:block>
                                                                      </fo:table-cell>
                                                                      <fo:table-cell>
                                                                              <fo:block text-align="justify" margin-bottom="12pt">

                                                                                      <xsl:if test="normalize-space($key_iso) = 'true'">
                                                                                              <xsl:attribute name="margin-bottom">0</xsl:attribute>
                                                                                      </xsl:if>

                                                                                      <!-- <xsl:apply-templates /> -->
                                                                                      <xsl:copy-of select="./node()"/>
                                                                              </fo:block>
                                                                      </fo:table-cell>
                                                              </fo:table-row>
                                                      </xsl:if>
                                              </xsl:for-each>
                                      </fo:table-body>
                              </fo:table>
                      </fo:block>
              </xsl:if>

      </xsl:template><xsl:template match="*[local-name()='fn']">
              <!-- <xsl:variable name="namespace" select="substring-before(name(/*), '-')"/> -->
              <fo:inline font-size="80%" keep-with-previous.within-line="always">

                              <xsl:attribute name="font-size">50%</xsl:attribute>
                              <xsl:attribute name="font-weight">normal</xsl:attribute>
                              <xsl:attribute name="vertical-align">super</xsl:attribute>

                      <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference   | ancestor::*[local-name()='clause'][1]/@id-->

                              <xsl:value-of select="@reference"/>

                      </fo:basic-link>
              </fo:inline>
      </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']">
              <fo:block-container margin-left="0mm">
                      <xsl:if test="parent::*[local-name() = 'note']">
                              <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>

                                      <xsl:attribute name="margin-left">0mm</xsl:attribute>

                      </xsl:if>
                      <fo:block-container margin-left="0mm">

                              <xsl:variable name="parent" select="local-name(..)"/>

                              <xsl:variable name="key_iso">

                                              <xsl:if test="$parent = 'figure' or $parent = 'formula'">true</xsl:if>
                                       <!-- and  (not(../@class) or ../@class !='pseudocode') -->
                              </xsl:variable>

                              <xsl:choose>
                                      <xsl:when test="$parent = 'formula' and count(*[local-name()='dt']) = 1"> <!-- only one component -->

                                                      <fo:block text-align="left">

                                                                      <xsl:attribute name="margin-left">7.4mm</xsl:attribute>

                                                              <xsl:variable name="title-where">
                                                                      <xsl:call-template name="getTitle">
                                                                              <xsl:with-param name="name" select="'title-where'"/>
                                                                      </xsl:call-template>
                                                              </xsl:variable>
                                                              <xsl:value-of select="$title-where"/>
                                                      </fo:block>
                                                      <fo:block>

                                                                      <xsl:attribute name="text-indent">7.4mm</xsl:attribute>

                                                              <xsl:apply-templates select="*[local-name()='dt']/*"/>
                                                              —
                                                              <xsl:text> </xsl:text>
                                                              <xsl:apply-templates select="*[local-name()='dd']/*" mode="inline"/>
                                                      </fo:block>

                                      </xsl:when>
                                      <xsl:when test="$parent = 'formula'"> <!-- a few components -->
                                              <fo:block margin-bottom="12pt" text-align="left">

                                                              <xsl:attribute name="margin-left">7.4mm</xsl:attribute>
                                                              <xsl:attribute name="margin-bottom">0pt</xsl:attribute>

                                                      <xsl:variable name="title-where">
                                                              <xsl:call-template name="getTitle">
                                                                      <xsl:with-param name="name" select="'title-where'"/>
                                                              </xsl:call-template>
                                                      </xsl:variable>
                                                      <xsl:value-of select="$title-where"/>
                                              </fo:block>
                                      </xsl:when>
                                      <xsl:when test="$parent = 'figure' and  (not(../@class) or ../@class !='pseudocode')">
                                              <fo:block font-weight="bold" text-align="left" margin-bottom="12pt" keep-with-next="always">

                                                              <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
                                                              <xsl:attribute name="text-indent">7.4mm</xsl:attribute>

                                                      <xsl:variable name="title-key">
                                                              <xsl:call-template name="getTitle">
                                                                      <xsl:with-param name="name" select="'title-key'"/>
                                                              </xsl:call-template>
                                                      </xsl:variable>
                                                      <xsl:value-of select="$title-key"/>
                                              </fo:block>
                                      </xsl:when>
                              </xsl:choose>

                              <!-- a few components -->
                              <xsl:if test="not($parent = 'formula' and count(*[local-name()='dt']) = 1)">
                                      <fo:block>

                                              <fo:block>

                                                              <xsl:attribute name="margin-left">7.4mm</xsl:attribute>
                                                              <xsl:if test="$parent = 'figure' and  (not(../@class) or ../@class !='pseudocode')">
                                                                      <xsl:attribute name="margin-left">15mm</xsl:attribute>
                                                              </xsl:if>

                                                      <fo:table width="95%" table-layout="fixed">

                                                                      <xsl:attribute name="margin-left">-3.7mm</xsl:attribute>

                                                              <xsl:choose>
                                                                      <xsl:when test="normalize-space($key_iso) = 'true' and $parent = 'formula'">
                                                                              <!-- <xsl:attribute name="font-size">11pt</xsl:attribute> -->
                                                                      </xsl:when>
                                                                      <xsl:when test="normalize-space($key_iso) = 'true'">
                                                                              <xsl:attribute name="font-size">10pt</xsl:attribute>

                                                                      </xsl:when>
                                                              </xsl:choose>
                                                              <!-- create virtual html table for dl/[dt and dd] -->
                                                              <xsl:variable name="html-table">
                                                                      <xsl:variable name="doc_ns">

                                                                      </xsl:variable>
                                                                      <xsl:variable name="ns">
                                                                              <xsl:choose>
                                                                                      <xsl:when test="normalize-space($doc_ns)  != ''">
                                                                                              <xsl:value-of select="normalize-space($doc_ns)"/>
                                                                                      </xsl:when>
                                                                                      <xsl:otherwise>
                                                                                              <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">
                                                                              <tbody>
                                                                                      <xsl:apply-templates mode="dl"/>
                                                                              </tbody>
                                                                      </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"/>
                                                                              <xsl:with-param name="table" select="$html-table"/>
                                                                      </xsl:call-template>
                                                              </xsl:variable>
                                                              <!-- colwidths=<xsl:value-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"/>                                                  
                                                                      <xsl:with-param name="maxlength_dt" select="$maxlength_dt"/>
                                                              </xsl:call-template>
                                                              <fo:table-body>
                                                                      <xsl:apply-templates>
                                                                              <xsl:with-param name="key_iso" select="normalize-space($key_iso)"/>
                                                                      </xsl:apply-templates>
                                                              </fo:table-body>
                                                      </fo:table>
                                              </fo:block>
                                      </fo:block>
                              </xsl:if>
                      </fo:block-container>
              </fo:block-container>
      </xsl:template><xsl:template name="setColumnWidth_dl">
              <xsl:param name="colwidths"/>           
              <xsl:param name="maxlength_dt"/>
              <xsl:choose>
                      <xsl:when test="ancestor::*[local-name()='dl']"><!-- second level, i.e. inlined table -->
                              <fo:table-column column-width="50%"/>
                              <fo:table-column column-width="50%"/>
                      </xsl:when>
                      <xsl:otherwise>
                              <xsl:choose>
                                      <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%"/>
                                      </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>
                                      <!-- <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">
                                              <fo:table-column column-width="50%"/>
                                              <fo:table-column column-width="50%"/>
                                      </xsl:when>
                                      <xsl:when test="xalan:nodeset($colwidths)/column[1] div xalan:nodeset($colwidths)/column[2] &gt; 0.5">
                                              <fo:table-column column-width="40%"/>
                                              <fo:table-column column-width="60%"/>
                                      </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>
                              <!-- <fo:table-column column-width="15%"/>
                              <fo:table-column column-width="85%"/> -->
                      </xsl:otherwise>
              </xsl:choose>
      </xsl:template><xsl:template name="getMaxLength_dt">
              <xsl:for-each select="*[local-name()='dt']">
                      <xsl:sort select="string-length(normalize-space(.))" data-type="number" order="descending"/>
                      <xsl:if test="position() = 1">
                              <xsl:value-of select="string-length(normalize-space(.))"/>
                      </xsl:if>
              </xsl:for-each>
      </xsl:template><xsl:template match="*[local-name()='dl']/*[local-name()='note']" priority="2">
              <xsl:param name="key_iso"/>

              <!-- <tr>
                      <td>NOTE</td>
                      <td>
                              <xsl:apply-templates />
                      </td>
              </tr>
               -->
              <fo:table-row>
                      <fo:table-cell>
                              <fo:block margin-top="6pt">
                                      <xsl:if test="normalize-space($key_iso) = 'true'">
                                              <xsl:attribute name="margin-top">0</xsl:attribute>
                                      </xsl:if>
                                      <xsl:apply-templates select="*[local-name() = 'name']" mode="presentation"/>
                              </fo:block>
                      </fo:table-cell>
                      <fo:table-cell>
                              <fo:block>
                                      <xsl:apply-templates/>
                              </fo:block>
                      </fo:table-cell>
              </fo:table-row>
      </xsl:template><xsl:template match="*[local-name()='dt']" mode="dl">
              <tr>
                      <td>
                              <xsl:apply-templates/>
                      </td>
                      <td>

                                      <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]" mode="process"/>

                      </td>
              </tr>

      </xsl:template><xsl:template match="*[local-name()='dt']">
              <xsl:param name="key_iso"/>

              <fo:table-row>

                      <fo:table-cell>

                              <fo:block margin-top="6pt">

                                      <xsl:if test="normalize-space($key_iso) = 'true'">
                                              <xsl:attribute name="margin-top">0</xsl:attribute>

                                      </xsl:if>

                                      <xsl:apply-templates/>
                                      <!-- <xsl:if test="$namespace = 'gb'">
                                              <xsl:if test="ancestor::*[local-name()='formula']">
                                                      <xsl:text>—</xsl:text>
                                              </xsl:if>
                                      </xsl:if> -->
                              </fo:block>
                      </fo:table-cell>
                      <fo:table-cell>
                              <fo:block>

                                      <!-- <xsl:if test="$namespace = 'nist-cswp'  or $namespace = 'nist-sp'">
                                              <xsl:if test="local-name(*[1]) != 'stem'">
                                                      <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]" mode="process"/>
                                              </xsl:if>
                                      </xsl:if> -->

                                              <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]" mode="process"/>

                              </fo:block>
                      </fo:table-cell>
              </fo:table-row>
              <!-- <xsl:if test="$namespace = 'nist-cswp'  or $namespace = 'nist-sp'">
                      <xsl:if test="local-name(*[1]) = 'stem'">
                              <fo:table-row>
                              <fo:table-cell>
                                      <fo:block margin-top="6pt">
                                              <xsl:if test="normalize-space($key_iso) = 'true'">
                                                      <xsl:attribute name="margin-top">0</xsl:attribute>
                                              </xsl:if>
                                              <xsl:text>&#xA0;</xsl:text>
                                      </fo:block>
                              </fo:table-cell>
                              <fo:table-cell>
                                      <fo:block>
                                              <xsl:apply-templates select="following-sibling::*[local-name()='dd'][1]" mode="process"/>
                                      </fo:block>
                              </fo:table-cell>
                      </fo:table-row>
                      </xsl:if>
              </xsl:if> -->
      </xsl:template><xsl:template match="*[local-name()='dd']" mode="dl"/><xsl:template match="*[local-name()='dd']" mode="dl_process">
              <xsl:apply-templates/>
      </xsl:template><xsl:template match="*[local-name()='dd']"/><xsl:template match="*[local-name()='dd']" mode="process">
              <xsl:apply-templates/>
      </xsl:template><xsl:template match="*[local-name()='dd']/*[local-name()='p']" mode="inline">
              <fo:inline><xsl:text> </xsl:text><xsl:apply-templates/></fo:inline>
      </xsl:template><xsl:template match="*[local-name()='em']">
              <fo:inline font-style="italic">
                      <xsl:apply-templates/>
              </fo:inline>
      </xsl:template><xsl:template match="*[local-name()='strong'] | *[local-name()='b']">
              <fo:inline font-weight="bold">
                      <xsl:apply-templates/>
              </fo:inline>
      </xsl:template><xsl:template match="*[local-name()='sup']">
              <fo:inline font-size="80%" vertical-align="super">
                      <xsl:apply-templates/>
              </fo:inline>
      </xsl:template><xsl:template match="*[local-name()='sub']">
              <fo:inline font-size="80%" vertical-align="sub">
                      <xsl:apply-templates/>
              </fo:inline>
      </xsl:template><xsl:template match="*[local-name()='tt']">
              <fo:inline xsl:use-attribute-sets="tt-style">
                      <xsl:variable name="_font-size">

                              10

                      </xsl:variable>
                      <xsl:variable name="font-size" select="normalize-space($_font-size)"/>          
                      <xsl:if test="$font-size != ''">
                              <xsl:attribute name="font-size">
                                      <xsl:choose>
                                              <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
                                              <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
                                      </xsl:choose>
                              </xsl:attribute>
                      </xsl:if>
                      <xsl:apply-templates/>
              </fo:inline>
      </xsl:template><xsl:template match="*[local-name()='del']">
              <fo:inline font-size="10pt" color="red" text-decoration="line-through">
                      <xsl:apply-templates/>
              </fo:inline>
      </xsl:template><xsl:template match="text()[ancestor::*[local-name()='smallcap']]">
              <xsl:variable name="text" select="normalize-space(.)"/>
              <fo:inline font-size="75%">
                              <xsl:if test="string-length($text) &gt; 0">
                                      <xsl:call-template name="recursiveSmallCaps">
                                              <xsl:with-param name="text" select="$text"/>
                                      </xsl:call-template>
                              </xsl:if>
                      </fo:inline> 
      </xsl:template><xsl:template name="recursiveSmallCaps">
  <xsl:param name="text"/>
  <xsl:variable name="char" select="substring($text,1,1)"/>
  <!-- <xsl:variable name="upperCase" select="translate($char, $lower, $upper)"/> -->
              <xsl:variable name="upperCase" select="java:toUpperCase(java:java.lang.String.new($char))"/>
  <xsl:choose>
    <xsl:when test="$char=$upperCase">
      <fo:inline font-size="{100 div 0.75}%">
        <xsl:value-of select="$upperCase"/>
      </fo:inline>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$upperCase"/>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:if test="string-length($text) &gt; 1">
    <xsl:call-template name="recursiveSmallCaps">
      <xsl:with-param name="text" select="substring($text,2)"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template><xsl:template name="tokenize">
              <xsl:param name="text"/>
              <xsl:param name="separator" select="' '"/>
              <xsl:choose>
                      <xsl:when test="not(contains($text, $separator))">
                              <word>
                                      <xsl:variable name="str_no_en_chars" select="normalize-space(translate($text, $en_chars, ''))"/>
                                      <xsl:variable name="len_str_no_en_chars" select="string-length($str_no_en_chars)"/>
                                      <xsl:variable name="len_str_tmp" select="string-length(normalize-space($text))"/>
                                      <xsl:variable name="len_str">
                                              <xsl:choose>
                                                      <xsl:when test="normalize-space(translate($text, $upper, '')) = ''"> <!-- english word in CAPITAL letters -->
                                                              <xsl:value-of select="$len_str_tmp * 1.5"/>
                                                      </xsl:when>
                                                      <xsl:otherwise>
                                                              <xsl:value-of select="$len_str_tmp"/>
                                                      </xsl:otherwise>
                                              </xsl:choose>
                                      </xsl:variable> 

                                      <!-- <xsl:if test="$len_str_no_en_chars div $len_str &gt; 0.8">
                                              <xsl:message>
                                                      div=<xsl:value-of select="$len_str_no_en_chars div $len_str"/>
                                                      len_str=<xsl:value-of select="$len_str"/>
                                                      len_str_no_en_chars=<xsl:value-of select="$len_str_no_en_chars"/>
                                              </xsl:message>
                                      </xsl:if> -->
                                      <!-- <len_str_no_en_chars><xsl:value-of select="$len_str_no_en_chars"/></len_str_no_en_chars>
                                      <len_str><xsl:value-of select="$len_str"/></len_str> -->
                                      <xsl:choose>
                                              <xsl:when test="$len_str_no_en_chars div $len_str &gt; 0.8"> <!-- means non-english string -->
                                                      <xsl:value-of select="$len_str - $len_str_no_en_chars"/>
                                              </xsl:when>
                                              <xsl:otherwise>
                                                      <xsl:value-of select="$len_str"/>
                                              </xsl:otherwise>
                                      </xsl:choose>
                              </word>
                      </xsl:when>
                      <xsl:otherwise>
                              <word>
                                      <xsl:value-of select="string-length(normalize-space(substring-before($text, $separator)))"/>
                              </word>
                              <xsl:call-template name="tokenize">
                                      <xsl:with-param name="text" select="substring-after($text, $separator)"/>
                              </xsl:call-template>
                      </xsl:otherwise>
              </xsl:choose>
      </xsl:template><xsl:template name="max_length">
              <xsl:param name="words"/>
              <xsl:for-each select="$words//word">
                              <xsl:sort select="." data-type="number" order="descending"/>
                              <xsl:if test="position()=1">
                                              <xsl:value-of select="."/>
                              </xsl:if>
              </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">
              <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>
              <xsl:variable name="zero-space-after-equal">=</xsl:variable>
              <xsl:variable name="zero-space-after-underscore">_</xsl:variable>
              <xsl:variable name="zero-space">​</xsl:variable>
              <xsl:choose>
                      <xsl:when test="contains($text, $zero-space-after-chars)">
                              <xsl:value-of select="substring-before($text, $zero-space-after-chars)"/>
                              <xsl:value-of select="$zero-space-after-chars"/>
                              <xsl:value-of select="$zero-space"/>
                              <xsl:call-template name="add-zero-spaces">
                                      <xsl:with-param name="text" select="substring-after($text, $zero-space-after-chars)"/>
                              </xsl:call-template>
                      </xsl:when>
                      <xsl:when test="contains($text, $zero-space-after-dot)">
                              <xsl:value-of select="substring-before($text, $zero-space-after-dot)"/>
                              <xsl:value-of select="$zero-space-after-dot"/>
                              <xsl:value-of select="$zero-space"/>
                              <xsl:call-template name="add-zero-spaces">
                                      <xsl:with-param name="text" select="substring-after($text, $zero-space-after-dot)"/>
                              </xsl:call-template>
                      </xsl:when>
                      <xsl:when test="contains($text, $zero-space-after-colon)">
                              <xsl:value-of select="substring-before($text, $zero-space-after-colon)"/>
                              <xsl:value-of select="$zero-space-after-colon"/>
                              <xsl:value-of select="$zero-space"/>
                              <xsl:call-template name="add-zero-spaces">
                                      <xsl:with-param name="text" select="substring-after($text, $zero-space-after-colon)"/>
                              </xsl:call-template>
                      </xsl:when>
                      <xsl:when test="contains($text, $zero-space-after-equal)">
                              <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
                              <xsl:value-of select="$zero-space-after-equal"/>
                              <xsl:value-of select="$zero-space"/>
                              <xsl:call-template name="add-zero-spaces">
                                      <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equal)"/>
                              </xsl:call-template>
                      </xsl:when>
                      <xsl:when test="contains($text, $zero-space-after-underscore)">
                              <xsl:value-of select="substring-before($text, $zero-space-after-underscore)"/>
                              <xsl:value-of select="$zero-space-after-underscore"/>
                              <xsl:value-of select="$zero-space"/>
                              <xsl:call-template name="add-zero-spaces">
                                      <xsl:with-param name="text" select="substring-after($text, $zero-space-after-underscore)"/>
                              </xsl:call-template>
                      </xsl:when>
                      <xsl:otherwise>
                              <xsl:value-of select="$text"/>
                      </xsl:otherwise>
              </xsl:choose>
      </xsl:template><xsl:template name="add-zero-spaces-equal">
              <xsl:param name="text" select="."/>
              <xsl:variable name="zero-space-after-equals">==========</xsl:variable>
              <xsl:variable name="zero-space-after-equal">=</xsl:variable>
              <xsl:variable name="zero-space">​</xsl:variable>
              <xsl:choose>
                      <xsl:when test="contains($text, $zero-space-after-equals)">
                              <xsl:value-of select="substring-before($text, $zero-space-after-equals)"/>
                              <xsl:value-of select="$zero-space-after-equals"/>
                              <xsl:value-of select="$zero-space"/>
                              <xsl:call-template name="add-zero-spaces-equal">
                                      <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equals)"/>
                              </xsl:call-template>
                      </xsl:when>
                      <xsl:when test="contains($text, $zero-space-after-equal)">
                              <xsl:value-of select="substring-before($text, $zero-space-after-equal)"/>
                              <xsl:value-of select="$zero-space-after-equal"/>
                              <xsl:value-of select="$zero-space"/>
                              <xsl:call-template name="add-zero-spaces-equal">
                                      <xsl:with-param name="text" select="substring-after($text, $zero-space-after-equal)"/>
                              </xsl:call-template>
                      </xsl:when>
                      <xsl:otherwise>
                              <xsl:value-of select="$text"/>
                      </xsl:otherwise>
              </xsl:choose>
      </xsl:template><xsl:template name="getSimpleTable">
              <xsl:variable name="simple-table">

                      <!-- Step 1. colspan processing -->
                      <xsl:variable name="simple-table-colspan">
                              <tbody>
                                      <xsl:apply-templates mode="simple-table-colspan"/>
                              </tbody>
                      </xsl:variable>

                      <!-- Step 2. rowspan processing -->
                      <xsl:variable name="simple-table-rowspan">
                              <xsl:apply-templates select="xalan:nodeset($simple-table-colspan)" mode="simple-table-rowspan"/>
                      </xsl:variable>

                      <xsl:copy-of select="xalan:nodeset($simple-table-rowspan)"/>

                      <!-- <xsl:choose>
                              <xsl:when test="current()//*[local-name()='th'][@colspan] or current()//*[local-name()='td'][@colspan] ">

                              </xsl:when>
                              <xsl:otherwise>
                                      <xsl:copy-of select="current()"/>
                              </xsl:otherwise>
                      </xsl:choose> -->
              </xsl:variable>
              <xsl:copy-of select="$simple-table"/>
      </xsl:template><xsl:template match="*[local-name()='thead'] | *[local-name()='tbody']" mode="simple-table-colspan">
              <xsl:apply-templates mode="simple-table-colspan"/>
      </xsl:template><xsl:template match="*[local-name()='fn']" mode="simple-table-colspan"/><xsl:template match="*[local-name()='th'] | *[local-name()='td']" mode="simple-table-colspan">
              <xsl:choose>
                      <xsl:when test="@colspan">
                              <xsl:variable name="td">
                                      <xsl:element name="td">
                                              <xsl:attribute name="divide"><xsl:value-of select="@colspan"/></xsl:attribute>
                                              <xsl:apply-templates select="@*" mode="simple-table-colspan"/>
                                              <xsl:apply-templates mode="simple-table-colspan"/>
                                      </xsl:element>
                              </xsl:variable>
                              <xsl:call-template name="repeatNode">
                                      <xsl:with-param name="count" select="@colspan"/>
                                      <xsl:with-param name="node" select="$td"/>
                              </xsl:call-template>
                      </xsl:when>
                      <xsl:otherwise>
                              <xsl:element name="td">
                                      <xsl:apply-templates select="@*" mode="simple-table-colspan"/>
                                      <xsl:apply-templates mode="simple-table-colspan"/>
                              </xsl:element>
                      </xsl:otherwise>
              </xsl:choose>
      </xsl:template><xsl:template match="@colspan" mode="simple-table-colspan"/><xsl:template match="*[local-name()='tr']" mode="simple-table-colspan">
              <xsl:element name="tr">
                      <xsl:apply-templates select="@*" mode="simple-table-colspan"/>
                      <xsl:apply-templates mode="simple-table-colspan"/>
              </xsl:element>
      </xsl:template><xsl:template match="@*|node()" mode="simple-table-colspan">
              <xsl:copy>
                              <xsl:apply-templates select="@*|node()" mode="simple-table-colspan"/>
              </xsl:copy>
      </xsl:template><xsl:template name="repeatNode">
              <xsl:param name="count"/>
              <xsl:param name="node"/>

              <xsl:if test="$count &gt; 0">
                      <xsl:call-template name="repeatNode">
                              <xsl:with-param name="count" select="$count - 1"/>
                              <xsl:with-param name="node" select="$node"/>
                      </xsl:call-template>
                      <xsl:copy-of select="$node"/>
              </xsl:if>
      </xsl:template><xsl:template match="@*|node()" mode="simple-table-rowspan">
              <xsl:copy>
                              <xsl:apply-templates select="@*|node()" mode="simple-table-rowspan"/>
              </xsl:copy>
      </xsl:template><xsl:template match="tbody" mode="simple-table-rowspan">
              <xsl:copy>
                              <xsl:copy-of select="tr[1]"/>
                              <xsl:apply-templates select="tr[2]" mode="simple-table-rowspan">
                                              <xsl:with-param name="previousRow" select="tr[1]"/>
                              </xsl:apply-templates>
              </xsl:copy>
      </xsl:template><xsl:template match="tr" mode="simple-table-rowspan">
              <xsl:param name="previousRow"/>
              <xsl:variable name="currentRow" select="."/>

              <xsl:variable name="normalizedTDs">
                              <xsl:for-each select="xalan:nodeset($previousRow)//td">
                                              <xsl:choose>
                                                              <xsl:when test="@rowspan &gt; 1">
                                                                              <xsl:copy>
                                                                                              <xsl:attribute name="rowspan">
                                                                                                              <xsl:value-of select="@rowspan - 1"/>
                                                                                              </xsl:attribute>
                                                                                              <xsl:copy-of select="@*[not(name() = 'rowspan')]"/>
                                                                                              <xsl:copy-of select="node()"/>
                                                                              </xsl:copy>
                                                              </xsl:when>
                                                              <xsl:otherwise>
                                                                              <xsl:copy-of select="$currentRow/td[1 + count(current()/preceding-sibling::td[not(@rowspan) or (@rowspan = 1)])]"/>
                                                              </xsl:otherwise>
                                              </xsl:choose>
                              </xsl:for-each>
              </xsl:variable>

              <xsl:variable name="newRow">
                              <xsl:copy>
                                              <xsl:copy-of select="$currentRow/@*"/>
                                              <xsl:copy-of select="xalan:nodeset($normalizedTDs)"/>
                              </xsl:copy>
              </xsl:variable>
              <xsl:copy-of select="$newRow"/>

              <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" select="//*[local-name()='bibdata']//*[local-name()='language']"/>
              <xsl:choose>
                      <xsl:when test="$language = 'English'">en</xsl:when>
                      <xsl:otherwise><xsl:value-of select="$language"/></xsl:otherwise>
              </xsl:choose>
      </xsl:template><xsl:template name="capitalizeWords">
              <xsl:param name="str"/>
              <xsl:variable name="str2" select="translate($str, '-', ' ')"/>
              <xsl:choose>
                      <xsl:when test="contains($str2, ' ')">
                              <xsl:variable name="substr" select="substring-before($str2, ' ')"/>
                              <!-- <xsl:value-of select="translate(substring($substr, 1, 1), $lower, $upper)"/>
                              <xsl:value-of select="substring($substr, 2)"/> -->
                              <xsl:call-template name="capitalize">
                                      <xsl:with-param name="str" select="$substr"/>
                              </xsl:call-template>
                              <xsl:text> </xsl:text>
                              <xsl:call-template name="capitalizeWords">
                                      <xsl:with-param name="str" select="substring-after($str2, ' ')"/>
                              </xsl:call-template>
                      </xsl:when>
                      <xsl:otherwise>
                              <!-- <xsl:value-of select="translate(substring($str2, 1, 1), $lower, $upper)"/>
                              <xsl:value-of select="substring($str2, 2)"/> -->
                              <xsl:call-template name="capitalize">
                                      <xsl:with-param name="str" select="$str2"/>
                              </xsl:call-template>
                      </xsl:otherwise>
              </xsl:choose>
      </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="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">
              <xsl:copy>
                              <xsl:apply-templates select="@*|node()" mode="mathml"/>
              </xsl:copy>
      </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="*[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:'))"/>
                              </xsl:when>
                              <xsl:otherwise>
                                      <xsl:value-of select="normalize-space(@target)"/>
                              </xsl:otherwise>
                      </xsl:choose>
              </xsl:variable>
              <fo:inline xsl:use-attribute-sets="link-style">
                      <xsl:choose>
                              <xsl:when test="$target = ''">
                                      <xsl:apply-templates/>
                              </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:when>
                                                      <xsl:otherwise>
                                                              <xsl:apply-templates/>
                                                      </xsl:otherwise>
                                              </xsl:choose>
                                      </fo:basic-link>
                              </xsl:otherwise>
                      </xsl:choose>
              </fo:inline>
      </xsl:template><xsl:template match="*[local-name()='bookmark']">
              <fo:inline id="{@id}"/>
      </xsl:template><xsl:template match="*[local-name()='appendix']">
              <fo:block id="{@id}" xsl:use-attribute-sets="appendix-style">
                      <xsl:apply-templates select="*[local-name()='title']" mode="process"/>
              </fo:block>
              <xsl:apply-templates/>
      </xsl:template><xsl:template match="*[local-name()='appendix']/*[local-name()='title']"/><xsl:template match="*[local-name()='appendix']/*[local-name()='title']" mode="process">
              <fo:inline><xsl:apply-templates/></fo:inline>
      </xsl:template><xsl:template match="*[local-name()='appendix']//*[local-name()='example']" priority="2">
              <fo:block id="{@id}" xsl:use-attribute-sets="appendix-example-style">                   
                      <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
              </fo:block>
              <xsl:apply-templates/>
      </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: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>
              </fo:block>             
      </xsl:template><xsl:template match="*[local-name() = 'annotation']/*[local-name() = 'p']">
              <xsl:param name="callout"/>
              <fo:inline id="{@id}">
                      <!-- for first p in annotation, put <x> -->
                      <xsl:if test="not(preceding-sibling::*[local-name() = 'p'])"><xsl:value-of select="$callout"/></xsl:if>
                      <xsl:apply-templates/>
              </fo:inline>            
      </xsl:template><xsl:template match="*[local-name() = 'modification']">
              <xsl:variable name="title-modified">
                      <xsl:call-template name="getTitle">
                              <xsl:with-param name="name" select="'title-modified'"/>
                      </xsl:call-template>
              </xsl:variable>
              <xsl:choose>
                      <xsl:when test="$lang = 'zh'"><xsl:text>、</xsl:text><xsl:value-of select="$title-modified"/><xsl:text>—</xsl:text></xsl:when>
                      <xsl:otherwise><xsl:text>, </xsl:text><xsl:value-of select="$title-modified"/><xsl:text> — </xsl:text></xsl:otherwise>
              </xsl:choose>
              <xsl:apply-templates/>
      </xsl:template><xsl:template match="*[local-name() = 'xref']">
              <fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">

                      <xsl:apply-templates/>
              </fo:basic-link>
      </xsl:template><xsl:template match="*[local-name() = 'formula']" name="formula">
              <fo:block-container margin-left="0mm">
                      <xsl:if test="parent::*[local-name() = 'note']">
                              <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>

                                      <xsl:attribute name="margin-left">0mm</xsl:attribute>

                      </xsl:if>
                      <fo:block-container margin-left="0mm">  
                              <fo:block id="{@id}" xsl:use-attribute-sets="formula-style">
                                      <xsl:apply-templates/>
                              </fo:block>
                      </fo:block-container>
              </fo:block-container>
      </xsl:template><xsl:template match="*[local-name() = 'formula']/*[local-name() = 'dt']/*[local-name() = 'stem']">
              <fo:inline>
                      <xsl:apply-templates/>
              </fo:inline>
      </xsl:template><xsl:template match="*[local-name() = 'admitted']/*[local-name() = 'stem']">
              <fo:inline>
                      <xsl:apply-templates/>
              </fo:inline>
      </xsl:template><xsl:template match="*[local-name() = 'formula']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'formula']/*[local-name() = 'name']" mode="presentation">
              <xsl:if test="normalize-space() != ''">
                      <xsl:text>(</xsl:text><xsl:apply-templates/><xsl:text>)</xsl:text>
              </xsl:if>
      </xsl:template><xsl:template match="*[local-name() = 'note']" name="note">

              <fo:block-container id="{@id}" xsl:use-attribute-sets="note-style">

                      <fo:block-container margin-left="0mm">

                                      <fo:table table-layout="fixed" width="100%">
                                              <fo:table-column column-width="10mm"/>
                                              <fo:table-column column-width="155mm"/>
                                              <fo:table-body>
                                                      <fo:table-row>
                                                              <fo:table-cell>
                                                                      <fo:block font-family="SimHei" xsl:use-attribute-sets="note-name-style">
                                                                              <xsl:apply-templates select="gb:name" mode="presentation"/>
                                                                      </fo:block>
                                                              </fo:table-cell>
                                                              <fo:table-cell>
                                                                      <fo:block text-align="justify">
                                                                              <xsl:apply-templates/>
                                                                      </fo:block>
                                                              </fo:table-cell>
                                                      </fo:table-row>
                                              </fo:table-body>
                                      </fo:table>

                      </fo:block-container>
              </fo:block-container>

      </xsl:template><xsl:template match="*[local-name() = 'note']/*[local-name() = 'p']">
              <xsl:variable name="num"><xsl:number/></xsl:variable>
              <xsl:choose>
                      <xsl:when test="$num = 1">
                              <fo:inline xsl:use-attribute-sets="note-p-style">
                                      <xsl:apply-templates/>
                              </fo:inline>
                      </xsl:when>
                      <xsl:otherwise>
                              <fo:block xsl:use-attribute-sets="note-p-style">                                                
                                      <xsl:apply-templates/>
                              </fo:block>
                      </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">
              <xsl:param name="sfx"/>
              <xsl:variable name="suffix">
                      <xsl:choose>
                              <xsl:when test="$sfx != ''">
                                      <xsl:value-of select="$sfx"/>                                   
                              </xsl:when>
                              <xsl:otherwise>

                                              <xsl:text>:</xsl:text>

                              </xsl:otherwise>
                      </xsl:choose>
              </xsl:variable>
              <xsl:if test="normalize-space() != ''">
                      <xsl:apply-templates/>
                      <xsl:value-of select="$suffix"/>
              </xsl:if>
      </xsl:template><xsl:template match="*[local-name() = 'termnote']/*[local-name() = 'name']" mode="presentation">
              <xsl:param name="sfx"/>
              <xsl:variable name="suffix">
                      <xsl:choose>
                              <xsl:when test="$sfx != ''">
                                      <xsl:value-of select="$sfx"/>                                   
                              </xsl:when>
                              <xsl:otherwise>

                                              <xsl:text>:</xsl:text>

                              </xsl:otherwise>
                      </xsl:choose>
              </xsl:variable>
              <xsl:if test="normalize-space() != ''">
                      <xsl:apply-templates/>
                      <xsl:value-of select="$suffix"/>
              </xsl:if>
      </xsl:template><xsl:template match="*[local-name() = 'termnote']/*[local-name() = 'p']">
              <fo:inline><xsl:apply-templates/></fo:inline>
      </xsl:template><xsl:template match="*[local-name() = 'terms']">
              <fo:block id="{@id}">
                      <xsl:apply-templates/>
              </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'term']">
              <fo:block id="{@id}" xsl:use-attribute-sets="term-style">

                              <fo:block font-family="SimHei" font-size="11pt" keep-with-next="always" margin-top="10pt" margin-bottom="8pt" line-height="1.1">
                                      <xsl:apply-templates select="gb:name" mode="presentation"/>
                              </fo:block>

                      <xsl:apply-templates/>
              </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'term']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'term']/*[local-name() = 'name']" mode="presentation">
              <xsl:if test="normalize-space() != ''">
                      <fo:inline>
                              <xsl:apply-templates/>
                              <!-- <xsl:if test="$namespace = 'gb' or $namespace = 'ogc'">
                                      <xsl:text>.</xsl:text>
                              </xsl:if> -->
                      </fo:inline>
              </xsl:if>
      </xsl:template><xsl:template match="*[local-name() = 'figure']">
              <fo:block-container id="{@id}">
                      <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"/>
              </fo:block-container>
      </xsl:template><xsl:template match="*[local-name() = 'figure'][@class = 'pseudocode']">
              <fo:block id="{@id}">
                      <xsl:apply-templates/>
              </fo:block>
      </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: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: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:value-of select="."/>
      </xsl:template><xsl:template match="*[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:apply-templates select="."/>
      </xsl:template><xsl:template match="*[local-name() = 'stem']" mode="bookmarks">
              <xsl:apply-templates mode="bookmarks"/>
      </xsl:template><xsl:template name="addBookmarks">
              <xsl:param name="contents"/>
              <xsl:if test="xalan:nodeset($contents)//item">
                      <fo:bookmark-tree>
                              <xsl:choose>
                                      <xsl:when test="xalan:nodeset($contents)/doc">
                                              <xsl:choose>
                                                      <xsl:when test="count(xalan:nodeset($contents)/doc) &gt; 1">
                                                              <xsl:for-each select="xalan:nodeset($contents)/doc">
                                                                      <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide">
                                                                              <fo:bookmark-title>
                                                                                      <xsl:variable name="bookmark-title_">
                                                                                              <xsl:call-template name="getLangVersion">
                                                                                                      <xsl:with-param name="lang" select="@lang"/>
                                                                                              </xsl:call-template>
                                                                                      </xsl:variable>
                                                                                      <xsl:choose>
                                                                                              <xsl:when test="normalize-space($bookmark-title_) != ''">
                                                                                                      <xsl:value-of select="normalize-space($bookmark-title_)"/>
                                                                                              </xsl:when>
                                                                                              <xsl:otherwise>
                                                                                                      <xsl:choose>
                                                                                                              <xsl:when test="@lang = 'en'">English</xsl:when>
                                                                                                              <xsl:when test="@lang = 'fr'">Français</xsl:when>
                                                                                                              <xsl:when test="@lang = 'de'">Deutsche</xsl:when>
                                                                                                              <xsl:otherwise><xsl:value-of select="@lang"/> version</xsl:otherwise>
                                                                                                      </xsl:choose>
                                                                                              </xsl:otherwise>
                                                                                      </xsl:choose>
                                                                              </fo:bookmark-title>
                                                                              <xsl:apply-templates select="contents/item" mode="bookmark"/>
                                                                      </fo:bookmark>

                                                              </xsl:for-each>
                                                      </xsl:when>
                                                      <xsl:otherwise>
                                                              <xsl:for-each select="xalan:nodeset($contents)/doc">
                                                                      <xsl:apply-templates select="contents/item" mode="bookmark"/>
                                                              </xsl:for-each>
                                                      </xsl:otherwise>
                                              </xsl:choose>
                                      </xsl:when>
                                      <xsl:otherwise>
                                              <xsl:apply-templates select="xalan:nodeset($contents)/contents/item" mode="bookmark"/>                          
                                      </xsl:otherwise>
                              </xsl:choose>

                      </fo:bookmark-tree>
              </xsl:if>
      </xsl:template><xsl:template name="getLangVersion">
              <xsl:param name="lang"/>
              <xsl:choose>
                      <xsl:when test="$lang = 'en'">

                              </xsl:when>
                      <xsl:when test="$lang = 'fr'">

                      </xsl:when>
                      <xsl:when test="$lang = 'de'">Deutsche</xsl:when>
                      <xsl:otherwise><xsl:value-of select="$lang"/> version</xsl:otherwise>
              </xsl:choose>
      </xsl:template><xsl:template match="item" mode="bookmark">
              <fo:bookmark internal-destination="{@id}" starting-state="hide">
                              <fo:bookmark-title>
                                      <xsl:if test="@section != ''">
                                              <xsl:value-of select="@section"/> 
                                              <xsl:text> </xsl:text>
                                      </xsl:if>
                                      <xsl:value-of select="normalize-space(title)"/>
                              </fo:bookmark-title>
                              <xsl:apply-templates mode="bookmark"/>                          
              </fo:bookmark>
      </xsl:template><xsl:template match="title" mode="bookmark"/><xsl:template match="text()" mode="bookmark"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'name'] |         *[local-name() = 'image']/*[local-name() = 'name']" mode="presentation">
              <xsl:if test="normalize-space() != ''">                 
                      <fo:block xsl:use-attribute-sets="figure-name-style">

                              <xsl:apply-templates/>
                      </fo:block>
              </xsl:if>
      </xsl:template><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'fn']" priority="2"/><xsl:template match="*[local-name() = 'figure']/*[local-name() = 'note']"/><xsl:template match="*[local-name() = 'title']" mode="contents_item">
              <xsl:apply-templates mode="contents_item"/>
              <!-- <xsl:text> </xsl:text> -->
      </xsl:template><xsl:template name="getSection">
              <xsl:value-of select="*[local-name() = 'title']/*[local-name() = 'tab'][1]/preceding-sibling::node()"/>
      </xsl:template><xsl:template name="getName">
              <xsl:choose>
                      <xsl:when test="*[local-name() = 'title']/*[local-name() = 'tab']">
                              <xsl:copy-of select="*[local-name() = 'title']/*[local-name() = 'tab'][1]/following-sibling::node()"/>
                      </xsl:when>
                      <xsl:otherwise>
                              <xsl:copy-of select="*[local-name() = 'title']/node()"/>
                      </xsl:otherwise>
              </xsl:choose>
      </xsl:template><xsl:template name="insertTitleAsListItem">
              <xsl:param name="provisional-distance-between-starts" select="'9.5mm'"/>
              <xsl:variable name="section">                                           
                      <xsl:for-each select="..">
                              <xsl:call-template name="getSection"/>
                      </xsl:for-each>
              </xsl:variable>                                                 
              <fo:list-block provisional-distance-between-starts="{$provisional-distance-between-starts}">                                            
                      <fo:list-item>
                              <fo:list-item-label end-indent="label-end()">
                                      <fo:block>
                                              <xsl:value-of select="$section"/>
                                      </fo:block>
                              </fo:list-item-label>
                              <fo:list-item-body start-indent="body-start()">
                                      <fo:block>                                              
                                              <xsl:choose>
                                                      <xsl:when test="*[local-name() = 'tab']">
                                                              <xsl:apply-templates select="*[local-name() = 'tab'][1]/following-sibling::node()"/>
                                                      </xsl:when>
                                                      <xsl:otherwise>
                                                              <xsl:apply-templates/>
                                                      </xsl:otherwise>
                                              </xsl:choose>
                                      </fo:block>
                              </fo:list-item-body>
                      </fo:list-item>
              </fo:list-block>
      </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>
                              <xsl:otherwise>
                                      <xsl:apply-templates/>
                              </xsl:otherwise>
                      </xsl:choose>
      </xsl:template><xsl:template match="*[local-name() = 'fn']" mode="contents"/><xsl:template match="*[local-name() = 'fn']" mode="bookmarks"/><xsl:template match="*[local-name() = 'fn']" mode="contents_item"/><xsl:template match="*[local-name() = 'tab']" mode="contents_item">
              <xsl:text> </xsl:text>
      </xsl:template><xsl:template match="*[local-name() = 'strong']" mode="contents_item">
              <xsl:copy>
                      <xsl:apply-templates mode="contents_item"/>
              </xsl:copy>             
      </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">
                      <xsl:if test="parent::*[local-name() = 'note']">
                              <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>

                                      <xsl:attribute name="margin-left">0mm</xsl:attribute>

                      </xsl:if>
                      <fo:block-container margin-left="0mm">

                              <fo:block xsl:use-attribute-sets="sourcecode-style">
                                      <xsl:variable name="_font-size">

                                              9

                              </xsl:variable>
                              <xsl:variable name="font-size" select="normalize-space($_font-size)"/>          
                              <xsl:if test="$font-size != ''">
                                      <xsl:attribute name="font-size">
                                              <xsl:choose>
                                                      <xsl:when test="ancestor::*[local-name()='note']"><xsl:value-of select="$font-size * 0.91"/>pt</xsl:when>
                                                      <xsl:otherwise><xsl:value-of select="$font-size"/>pt</xsl:otherwise>
                                              </xsl:choose>
                                      </xsl:attribute>
                              </xsl:if>
                                      <xsl:apply-templates/>                  
                              </fo:block>
                              <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>

                      </fo:block-container>
              </fo:block-container>
      </xsl:template><xsl:template match="*[local-name()='sourcecode']/text()" priority="2">
              <xsl:variable name="text">
                      <xsl:call-template name="add-zero-spaces-equal"/>
              </xsl:variable>
              <xsl:call-template name="add-zero-spaces-java">
                      <xsl:with-param name="text" select="$text"/>
              </xsl:call-template>
      </xsl:template><xsl:template match="*[local-name() = 'sourcecode']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'sourcecode']/*[local-name() = 'name']" mode="presentation">
              <xsl:if test="normalize-space() != ''">         
                      <fo:block xsl:use-attribute-sets="sourcecode-name-style">                               
                              <xsl:apply-templates/>
                      </fo:block>
              </xsl:if>
      </xsl:template><xsl:template match="*[local-name() = 'permission']">
              <fo:block id="{@id}" xsl:use-attribute-sets="permission-style">                 
                      <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
                      <xsl:apply-templates/>
              </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'permission']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'permission']/*[local-name() = 'name']" mode="presentation">
              <xsl:if test="normalize-space() != ''">
                      <fo:block xsl:use-attribute-sets="permission-name-style">
                              <xsl:apply-templates/>

                      </fo:block>
              </xsl:if>
      </xsl:template><xsl:template match="*[local-name() = 'permission']/*[local-name() = 'label']">
              <fo:block xsl:use-attribute-sets="permission-label-style">
                      <xsl:apply-templates/>
              </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'requirement']">
              <fo:block id="{@id}" xsl:use-attribute-sets="requirement-style">                        
                      <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
                      <xsl:apply-templates select="*[local-name()='label']" mode="presentation"/>
                      <xsl:apply-templates select="@obligation" mode="presentation"/>
                      <xsl:apply-templates select="*[local-name()='subject']" mode="presentation"/>
                      <xsl:apply-templates/>
              </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'name']" mode="presentation">
              <xsl:if test="normalize-space() != ''">
                      <fo:block xsl:use-attribute-sets="requirement-name-style">

                              <xsl:apply-templates/>

                      </fo:block>
              </xsl:if>
      </xsl:template><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'label']"/><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'label']" mode="presentation">
              <fo:block xsl:use-attribute-sets="requirement-label-style">
                      <xsl:apply-templates/>
              </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'requirement']/@obligation" mode="presentation">
                      <fo:block>
                              <fo:inline padding-right="3mm">Obligation</fo:inline><xsl:value-of select="."/>
                      </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'subject']"/><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'subject']" mode="presentation">
              <fo:block xsl:use-attribute-sets="requirement-subject-style">
                      <xsl:text>Target Type </xsl:text><xsl:apply-templates/>
              </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'requirement']/*[local-name() = 'inherit']">
              <fo:block xsl:use-attribute-sets="requirement-inherit-style">
                      <xsl:text>Dependency </xsl:text><xsl:apply-templates/>
              </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'recommendation']">
              <fo:block id="{@id}" xsl:use-attribute-sets="recommendation-style">                     
                      <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>
                      <xsl:apply-templates/>
              </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'recommendation']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'recommendation']/*[local-name() = 'name']" mode="presentation">
              <xsl:if test="normalize-space() != ''">
                      <fo:block xsl:use-attribute-sets="recommendation-name-style">
                              <xsl:apply-templates/>

                      </fo:block>
              </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">
                      <xsl:if test="ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
                              <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
                      </xsl:if>
                      <fo:block-container margin-left="0mm" margin-right="0mm">
                              <fo:table id="{@id}" table-layout="fixed" width="100%"> <!-- border="1pt solid black" -->
                                      <xsl:if test="ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
                                              <!-- <xsl:attribute name="border">0.5pt solid black</xsl:attribute> -->
                                      </xsl:if>
                                      <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"/> -->
                                              <fo:table-column column-width="30%"/>
                                              <fo:table-column column-width="70%"/>
                                      </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="1pt 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 height="7mm" border-bottom="0.5pt solid grey">                    
                      <xsl:if test="parent::*[local-name()='thead']"> <!-- and not(ancestor::*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']) -->
                              <!-- <xsl:attribute name="border">1pt solid black</xsl:attribute> -->
                              <xsl:attribute name="background-color">rgb(33, 55, 92)</xsl:attribute>
                      </xsl:if>
                      <xsl:if test="starts-with(*[local-name()='td'][1], 'Requirement ')">
                              <xsl:attribute name="background-color">rgb(252, 246, 222)</xsl:attribute>
                      </xsl:if>
                      <xsl:if test="starts-with(*[local-name()='td'][1], 'Recommendation ')">
                              <xsl:attribute name="background-color">rgb(233, 235, 239)</xsl:attribute>
                      </xsl:if>
                      <xsl:apply-templates mode="requirement"/>
              </fo:table-row>
      </xsl:template><xsl:template match="*[local-name()='th']" mode="requirement">
              <fo:table-cell text-align="{@align}" display-align="center" padding="1mm" padding-left="2mm"> <!-- border="0.5pt solid black" -->
                      <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:call-template name="display-align"/>

                      <!-- <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}" display-align="center" padding="1mm" padding-left="2mm"> <!-- border="0.5pt solid black" -->
                      <xsl:if test="*[local-name() = 'table'][@class = 'recommendation' or @class='requirement' or @class='permission']">
                              <xsl:attribute name="padding">0mm</xsl:attribute>
                              <xsl:attribute name="padding-left">0mm</xsl:attribute>
                      </xsl:if>
                      <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="following-sibling::*[local-name()='td'] and not(preceding-sibling::*[local-name()='td'])">
                              <xsl:attribute name="font-weight">bold</xsl:attribute>
                      </xsl:if>
                      <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:call-template name="display-align"/>

                      <!-- <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'])">
                                      <xsl:attribute name="background-color">rgb(201, 201, 201)</xsl:attribute>                                       
                              </xsl:if>
                      </xsl:if> -->
                      <!-- 2nd line and below -->

                      <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" color="rgb(237, 193, 35)"> <!-- font-weight="bold" margin-bottom="4pt" text-align="center"  -->
                      <xsl:apply-templates/>
              </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'p2'][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>
      </xsl:template><xsl:template match="*[local-name() = 'termexample']/*[local-name() = 'name']"/><xsl:template match="*[local-name() = 'termexample']/*[local-name() = 'name']" mode="presentation">
              <xsl:if test="normalize-space() != ''">
                      <fo:inline xsl:use-attribute-sets="termexample-name-style">
                              <xsl:apply-templates/>
                      </fo:inline>
              </xsl:if>
      </xsl:template><xsl:template match="*[local-name() = 'termexample']/*[local-name() = 'p']">
              <fo:inline><xsl:apply-templates/></fo:inline>
      </xsl:template><xsl:template match="*[local-name() = 'example']">
              <fo:block id="{@id}" xsl:use-attribute-sets="example-style">

                      <xsl:apply-templates select="*[local-name()='name']" mode="presentation"/>

                      <xsl:variable name="element">
                              block                           

                              <xsl:if test=".//*[local-name() = 'table']">block</xsl:if> 
                      </xsl:variable>

                      <xsl:choose>
                              <xsl:when test="contains(normalize-space($element), 'block')">
                                      <fo:block xsl:use-attribute-sets="example-body-style">
                                              <xsl:apply-templates/>
                                      </fo:block>
                              </xsl:when>
                              <xsl:otherwise>
                                      <fo:inline>
                                              <xsl:apply-templates/>
                                      </fo:inline>
                              </xsl:otherwise>
                      </xsl:choose>

              </fo:block>
      </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">

                      inline
              </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'">
                              <fo:block xsl:use-attribute-sets="example-name-style">
                                      <xsl:apply-templates/>
                              </fo:block>
                      </xsl:when>
                      <xsl:otherwise>
                              <fo:inline xsl:use-attribute-sets="example-name-style">
                                      <xsl:apply-templates/>
                              </fo:inline>
                      </xsl:otherwise>
              </xsl:choose>

      </xsl:template><xsl:template match="*[local-name() = 'example']/*[local-name() = 'p']">

              <xsl:variable name="element">
                      block

              </xsl:variable>         
              <xsl:choose>                    
                      <xsl:when test="normalize-space($element) = 'block'">
                              <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>
              </xsl:choose>   
      </xsl:template><xsl:template match="*[local-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:when>
                              <xsl:otherwise>                                 

                                              <xsl:text>[</xsl:text>

                                      <xsl:apply-templates/>                                  

                                              <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']">
              <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">

                      <fo:inline xsl:use-attribute-sets="origin-style">
                              <xsl:apply-templates/>
                      </fo:inline>
                      </fo:basic-link>
      </xsl:template><xsl:template match="*[local-name() = 'modification']/*[local-name() = 'p']">
              <fo:inline><xsl:apply-templates/></fo:inline>
      </xsl:template><xsl:template match="*[local-name() = 'modification']/text()">
              <xsl:if test="normalize-space() != ''">
                      <xsl:value-of select="."/>
              </xsl:if>
      </xsl:template><xsl:template match="*[local-name() = 'quote']">         
              <fo:block-container margin-left="0mm">
                      <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>

                              <xsl:attribute name="margin-left">0mm</xsl:attribute>

                      <fo:block-container margin-left="0mm">

                              <fo:block xsl:use-attribute-sets="quote-style">
                                      <xsl:apply-templates select=".//*[local-name() = 'p']"/>
                              </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']"/>
                                              <xsl:apply-templates select="*[local-name() = 'source']"/>                              
                                      </fo:block>
                              </xsl:if>

                      </fo:block-container>
              </fo:block-container>
      </xsl:template><xsl:template match="*[local-name() = 'source']">
              <xsl:if test="../*[local-name() = 'author']">
                      <xsl:text>, </xsl:text>
              </xsl:if>
              <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">
                      <xsl:apply-templates/>
              </fo:basic-link>
      </xsl:template><xsl:template match="*[local-name() = 'author']">
              <xsl:text>— </xsl:text>
              <xsl:apply-templates/>
      </xsl:template><xsl:template match="*[local-name() = 'eref']">
              <fo:inline xsl:use-attribute-sets="eref-style">
                      <xsl:if test="@type = 'footnote'">

                                      <xsl:attribute name="keep-together.within-line">always</xsl:attribute>
                                      <xsl:attribute name="font-size">50%</xsl:attribute>
                                      <xsl:attribute name="keep-with-previous.within-line">always</xsl:attribute>
                                      <xsl:attribute name="vertical-align">super</xsl:attribute>

                      </xsl:if>       

                      <fo:basic-link internal-destination="{@bibitemid}" fox:alt-text="{@citeas}">

                              <xsl:if test="@type = 'inline'">

                              </xsl:if>

                              <xsl:apply-templates/>
                      </fo:basic-link>
              </fo:inline>
      </xsl:template><xsl:template match="*[local-name() = 'tab']">
              <!-- zero-space char -->
              <xsl:variable name="depth">
                      <xsl:call-template name="getLevel">
                              <xsl:with-param name="depth" select="../@depth"/>
                      </xsl:call-template>
              </xsl:variable>

              <xsl:variable name="padding">

                      3

              </xsl:variable>

              <xsl:variable name="padding-right">
                      <xsl:choose>
                              <xsl:when test="normalize-space($padding) = ''">0</xsl:when>
                              <xsl:otherwise>
                                      <xsl:value-of select="normalize-space($padding)"/>
                              </xsl:otherwise>
                      </xsl:choose>
              </xsl:variable>

              <xsl:variable name="language" select="//*[local-name()='bibdata']//*[local-name()='language']"/>

              <xsl:choose>
                      <xsl:when test="$language = 'zh'">
                              <fo:inline><xsl:value-of select="$tab_zh"/></fo:inline>
                      </xsl:when>
                      <xsl:when test="../../@inline-header = 'true'">
                              <fo:inline font-size="90%">
                                      <xsl:call-template name="insertNonBreakSpaces">
                                              <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:otherwise>
              </xsl:choose>

      </xsl:template><xsl:template name="insertNonBreakSpaces">
              <xsl:param name="count"/>
              <xsl:if test="$count &gt; 0">
                      <xsl:text> </xsl:text>
                      <xsl:call-template name="insertNonBreakSpaces">
                              <xsl:with-param name="count" select="$count - 1"/>
                      </xsl:call-template>
              </xsl:if>
      </xsl:template><xsl:template match="*[local-name() = 'domain']">
              <fo:inline xsl:use-attribute-sets="domain-style">&lt;<xsl:apply-templates/>&gt;</fo:inline>
              <xsl:text> </xsl:text>
      </xsl:template><xsl:template match="*[local-name() = 'admitted']">
              <fo:block xsl:use-attribute-sets="admitted-style">
                      <xsl:apply-templates/>
              </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'deprecates']">
              <xsl:variable name="title-deprecated">
                      <xsl:call-template name="getTitle">
                              <xsl:with-param name="name" select="'title-deprecated'"/>
                      </xsl:call-template>
              </xsl:variable>
              <fo:block xsl:use-attribute-sets="deprecates-style">
                      <xsl:value-of select="$title-deprecated"/>: <xsl:apply-templates/>
              </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'definition']">
              <fo:block xsl:use-attribute-sets="definition-style">
                      <xsl:apply-templates/>
              </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'definition'][preceding-sibling::*[local-name() = 'domain']]">
              <xsl:apply-templates/>
      </xsl:template><xsl:template match="*[local-name() = 'definition'][preceding-sibling::*[local-name() = 'domain']]/*[local-name() = 'p']">
              <fo:inline> <xsl:apply-templates/></fo:inline>
              <fo:block> </fo:block>
      </xsl:template><xsl:template match="/*/*[local-name() = 'sections']/*" priority="2">

              <fo:block>
                      <xsl:call-template name="setId"/>

                              <xsl:variable name="pos"><xsl:number count="gb:sections/gb:clause | gb:sections/gb:terms"/></xsl:variable>
                              <xsl:if test="$pos &gt;= 2">
                                      <xsl:attribute name="space-before">18pt</xsl:attribute>
                              </xsl:if>

                      <xsl:apply-templates/>
              </fo:block>

      </xsl:template><xsl:template match="/*/*[local-name() = 'preface']/*" priority="2">
              <fo:block break-after="page"/>
              <fo:block>
                      <xsl:call-template name="setId"/>
                      <xsl:apply-templates/>
              </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'clause']">
              <fo:block>
                      <xsl:call-template name="setId"/>                       

                      <xsl:apply-templates/>
              </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'][@normative='true']">

              <fo:block id="{@id}">
                      <xsl:apply-templates/>
              </fo:block>
      </xsl:template><xsl:template match="*[local-name() = 'annex']">
              <fo:block break-after="page"/>
              <fo:block id="{@id}">

              </fo:block>
              <xsl:apply-templates/>
      </xsl:template><xsl:template match="*[local-name() = 'review']">
              <!-- comment 2019-11-29 -->
              <!-- <fo:block font-weight="bold">Review:</fo:block>
              <xsl:apply-templates /> -->
      </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']">
                              <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>

                                              <xsl:attribute name="margin-left">0mm</xsl:attribute>

                                      <fo:block-container margin-left="0mm">
                                              <fo:block>
                                                      <xsl:apply-templates select="." mode="ul_ol"/>
                                              </fo:block>
                                      </fo:block-container>
                              </fo:block-container>
                      </xsl:when>
                      <xsl:otherwise>
                              <fo:block>
                                      <xsl:apply-templates select="." mode="ul_ol"/>
                              </fo:block>
                      </xsl:otherwise>
              </xsl:choose>
      </xsl:template><xsl:template match="*[local-name() = 'errata']">
              <!-- <row>
                                      <date>05-07-2013</date>
                                      <type>Editorial</type>
                                      <change>Changed CA-9 Priority Code from P1 to P2 in <xref target="tabled2"/>.</change>
                                      <pages>D-3</pages>
                              </row>
              -->
              <fo:table table-layout="fixed" width="100%" font-size="10pt" border="1pt solid black">
                      <fo:table-column column-width="20mm"/>
                      <fo:table-column column-width="23mm"/>
                      <fo:table-column column-width="107mm"/>
                      <fo:table-column column-width="15mm"/>
                      <fo:table-body>
                              <fo:table-row font-family="Arial" text-align="center" font-weight="bold" background-color="black" color="white">
                                      <fo:table-cell border="1pt solid black"><fo:block>Date</fo:block></fo:table-cell>
                                      <fo:table-cell border="1pt solid black"><fo:block>Type</fo:block></fo:table-cell>
                                      <fo:table-cell border="1pt solid black"><fo:block>Change</fo:block></fo:table-cell>
                                      <fo:table-cell border="1pt solid black"><fo:block>Pages</fo:block></fo:table-cell>
                              </fo:table-row>
                              <xsl:apply-templates/>
                      </fo:table-body>
              </fo:table>
      </xsl:template><xsl:template match="*[local-name() = 'errata']/*[local-name() = 'row']">
              <fo:table-row>
                      <xsl:apply-templates/>
              </fo:table-row>
      </xsl:template><xsl:template match="*[local-name() = 'errata']/*[local-name() = 'row']/*">
              <fo:table-cell border="1pt solid black" padding-left="1mm" padding-top="0.5mm">
                      <fo:block><xsl:apply-templates/></fo:block>
              </fo:table-cell>
      </xsl:template><xsl:template name="processBibitem">

      </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"/>
                              <xsl:if test="$type != '' and not(contains($_doc_ident, $type))">
                                      <xsl:value-of select="$type"/><xsl:text> </xsl:text>
                              </xsl:if>
                              <xsl:value-of select="$_doc_ident"/>
                      </xsl:when>
                      <xsl:otherwise>
                              <xsl:variable name="type" select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]/@type"/>
                              <xsl:if test="$type != ''">
                                      <xsl:value-of select="$type"/><xsl:text> </xsl:text>
                              </xsl:if>
                              <xsl:value-of select="*[local-name() = 'docidentifier'][not(@type = 'metanorma')]"/>
                      </xsl:otherwise>
              </xsl:choose>
      </xsl:template><xsl:template name="processPersonalAuthor">
              <xsl:choose>
                      <xsl:when test="*[local-name() = 'name']/*[local-name() = 'completename']">
                              <author>
                                      <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'completename']"/>
                              </author>
                      </xsl:when>
                      <xsl:when test="*[local-name() = 'name']/*[local-name() = 'surname'] and *[local-name() = 'name']/*[local-name() = 'initial']">
                              <author>
                                      <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'surname']"/>
                                      <xsl:text> </xsl:text>
                                      <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'initial']" mode="strip"/>
                              </author>
                      </xsl:when>
                      <xsl:when test="*[local-name() = 'name']/*[local-name() = 'surname'] and *[local-name() = 'name']/*[local-name() = 'forename']">
                              <author>
                                      <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'surname']"/>
                                      <xsl:text> </xsl:text>
                                      <xsl:apply-templates select="*[local-name() = 'name']/*[local-name() = 'forename']" mode="strip"/>
                              </author>
                      </xsl:when>
                      <xsl:otherwise>
                              <xsl:apply-templates/>
                      </xsl:otherwise>
              </xsl:choose>
      </xsl:template><xsl:template name="renderDate">         
                      <xsl:if test="normalize-space(*[local-name() = 'on']) != ''">
                              <xsl:value-of select="*[local-name() = 'on']"/>
                      </xsl:if>
                      <xsl:if test="normalize-space(*[local-name() = 'from']) != ''">
                              <xsl:value-of select="concat(*[local-name() = 'from'], '–', *[local-name() = 'to'])"/>
                      </xsl:if>
      </xsl:template><xsl:template match="*[local-name() = 'name']/*[local-name() = 'initial']/text()" mode="strip">
              <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 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)"/>
              <xsl:variable name="day" select="substring($date, 9, 2)"/>
              <xsl:variable name="monthStr">
                      <xsl:choose>
                              <xsl:when test="$month = '01'">January</xsl:when>
                              <xsl:when test="$month = '02'">February</xsl:when>
                              <xsl:when test="$month = '03'">March</xsl:when>
                              <xsl:when test="$month = '04'">April</xsl:when>
                              <xsl:when test="$month = '05'">May</xsl:when>
                              <xsl:when test="$month = '06'">June</xsl:when>
                              <xsl:when test="$month = '07'">July</xsl:when>
                              <xsl:when test="$month = '08'">August</xsl:when>
                              <xsl:when test="$month = '09'">September</xsl:when>
                              <xsl:when test="$month = '10'">October</xsl:when>
                              <xsl:when test="$month = '11'">November</xsl:when>
                              <xsl:when test="$month = '12'">December</xsl:when>
                      </xsl:choose>
              </xsl:variable>
              <xsl:variable name="result">
                      <xsl:choose>
                              <xsl:when test="$format = 'short' or $day = ''">
                                      <xsl:value-of select="normalize-space(concat($monthStr, ' ', $year))"/>
                              </xsl:when>
                              <xsl:otherwise>
                                      <xsl:value-of select="normalize-space(concat($monthStr, ' ', $day, ', ' , $year))"/>
                              </xsl:otherwise>
                      </xsl:choose>
              </xsl:variable>
              <xsl:value-of select="$result"/>
      </xsl:template><xsl:template name="insertKeywords">
              <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: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: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:otherwise>
              </xsl:choose>
      </xsl:template><xsl:template name="insertKeyword">
              <xsl:param name="charAtEnd"/>
              <xsl:param name="charDelim"/>
              <xsl:apply-templates/>
              <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">
              <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>
                              </pdf:catalog>
                      <x:xmpmeta xmlns:x="adobe:ns:meta/">
                              <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' and @type = 'main']"/>

                                                      </xsl:variable>
                                                      <xsl:choose>
                                                              <xsl:when test="normalize-space($title) != ''">
                                                                      <xsl:value-of select="$title"/>
                                                              </xsl:when>
                                                              <xsl:otherwise>
                                                                      <xsl:text> </xsl:text>
                                                              </xsl:otherwise>
                                                      </xsl:choose>                                                   
                                              </dc:title>
                                              <dc:creator>

                                                              <xsl:value-of select="/*/*[local-name() = 'bibdata']/*[local-name() = 'contributor'][*[local-name() = 'role']/@type='author']/*[local-name() = 'organization']/*[local-name() = 'name']"/>

                                              </dc:creator>
                                              <dc:description>
                                                      <xsl:variable name="abstract">

                                                                      <xsl:copy-of select="/*/*[local-name() = 'bibliography']/*[local-name() = 'references']/*[local-name() = 'bibitem']/*[local-name() = 'abstract']//text()"/>

                                                      </xsl:variable>
                                                      <xsl:value-of select="normalize-space($abstract)"/>
                                              </dc:description>
                                              <pdf:Keywords>
                                                      <xsl:call-template name="insertKeywords"/>
                                              </pdf:Keywords>
                                      </rdf:Description>
                                      <rdf:Description xmlns:xmp="http://ns.adobe.com/xap/1.0/" rdf:about="">
                                              <!-- XMP properties go here -->
                                              <xmp:CreatorTool/>
                                      </rdf:Description>
                              </rdf:RDF>
                      </x:xmpmeta>
              </fo:declarations>
      </xsl:template><xsl:template name="getId">
              <xsl:choose>
                      <xsl:when test="../@id">
                              <xsl:value-of select="../@id"/>
                      </xsl:when>
                      <xsl:otherwise>
                              <!-- <xsl:value-of select="concat(local-name(..), '_', text())"/> -->
                              <xsl:value-of select="concat(generate-id(..), '_', text())"/>
                      </xsl:otherwise>
              </xsl:choose>
      </xsl:template><xsl:template name="getLevel">
              <xsl:param name="depth"/>
              <xsl:choose>
                      <xsl:when test="normalize-space(@depth) != ''">
                              <xsl:value-of select="@depth"/>
                      </xsl:when>
                      <xsl:when test="normalize-space($depth) != ''">
                              <xsl:value-of select="$depth"/>
                      </xsl:when>
                      <xsl:otherwise>
                              <xsl:variable name="level_total" select="count(ancestor::*)"/>
                              <xsl:variable name="level">
                                      <xsl:choose>
                                              <xsl:when test="parent::*[local-name() = 'preface']">
                                                      <xsl:value-of select="$level_total - 1"/>
                                              </xsl:when>
                                              <xsl:when test="ancestor::*[local-name() = 'preface']">
                                                      <xsl:value-of select="$level_total - 2"/>
                                              </xsl:when>
                                              <!-- <xsl:when test="parent::*[local-name() = 'sections']">
                                                      <xsl:value-of select="$level_total - 1"/>
                                              </xsl:when> -->
                                              <xsl:when test="ancestor::*[local-name() = 'sections']">
                                                      <xsl:value-of select="$level_total - 1"/>
                                              </xsl:when>
                                              <xsl:when test="ancestor::*[local-name() = 'bibliography']">
                                                      <xsl:value-of select="$level_total - 1"/>
                                              </xsl:when>
                                              <xsl:when test="parent::*[local-name() = 'annex']">
                                                      <xsl:value-of select="$level_total - 1"/>
                                              </xsl:when>
                                              <xsl:when test="ancestor::*[local-name() = 'annex']">
                                                      <xsl:value-of select="$level_total"/>
                                              </xsl:when>
                                              <xsl:when test="local-name() = 'annex'">1</xsl:when>
                                              <xsl:when test="local-name(ancestor::*[1]) = 'annex'">1</xsl:when>
                                              <xsl:otherwise>
                                                      <xsl:value-of select="$level_total - 1"/>
                                              </xsl:otherwise>
                                      </xsl:choose>
                              </xsl:variable>
                              <xsl:value-of select="$level"/>
                      </xsl:otherwise>
              </xsl:choose>
      </xsl:template><xsl:template name="split">
              <xsl:param name="pText" select="."/>
              <xsl:param name="sep" select="','"/>
              <xsl:if test="string-length($pText) &gt;0">
              <item>
                      <xsl:value-of select="normalize-space(substring-before(concat($pText, ','), $sep))"/>
              </item>
              <xsl:call-template name="split">
                      <xsl:with-param name="pText" select="substring-after($pText, $sep)"/>
                      <xsl:with-param name="sep" select="$sep"/>
              </xsl:call-template>
              </xsl:if>
      </xsl:template><xsl:template name="getDocumentId">              
              <xsl:call-template name="getLang"/><xsl:value-of select="//*[local-name() = 'p'][1]/@id"/>
      </xsl:template><xsl:template name="namespaceCheck">
              <xsl:variable name="documentNS" select="namespace-uri(/*)"/>
              <xsl:variable name="XSLNS">                     

                              <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">
              <xsl:param name="lang"/>                
              <xsl:variable name="language" select="java:toLowerCase(java:java.lang.String.new($lang))"/>
              <xsl:choose>
                      <xsl:when test="$language = 'en'">English</xsl:when>
                      <xsl:when test="$language = 'fr'">French</xsl:when>
                      <xsl:when test="$language = 'de'">Deutsch</xsl:when>
                      <xsl:when test="$language = 'cn'">Chinese</xsl:when>
                      <xsl:otherwise><xsl:value-of select="$language"/></xsl:otherwise>
              </xsl:choose>
      </xsl:template><xsl:template name="setId">
              <xsl:attribute name="id">
                      <xsl:choose>
                              <xsl:when test="@id">
                                      <xsl:value-of select="@id"/>
                              </xsl:when>
                              <xsl:otherwise>
                                      <xsl:value-of select="generate-id()"/>
                              </xsl:otherwise>
                      </xsl:choose>                                   
              </xsl:attribute>
      </xsl:template><xsl:template name="add-letter-spacing">
              <xsl:param name="text"/>
              <xsl:param name="letter-spacing" select="'0.15'"/>
              <xsl:if test="string-length($text) &gt; 0">
                      <xsl:variable name="char" select="substring($text, 1, 1)"/>
                      <fo:inline padding-right="{$letter-spacing}mm">
                              <xsl:if test="$char = '®'">
                                      <xsl:attribute name="font-size">58%</xsl:attribute>
                                      <xsl:attribute name="baseline-shift">30%</xsl:attribute>
                              </xsl:if>                               
                              <xsl:value-of select="$char"/>
                      </fo:inline>
                      <xsl:call-template name="add-letter-spacing">
                              <xsl:with-param name="text" select="substring($text, 2)"/>
                              <xsl:with-param name="letter-spacing" select="$letter-spacing"/>
                      </xsl:call-template>
              </xsl:if>
      </xsl:template></xsl:stylesheet>