lib/isodoc/cc/cc.standard.xsl in metanorma-cc-2.4.9 vs lib/isodoc/cc/cc.standard.xsl in metanorma-cc-2.4.10

- old
+ new

@@ -236,16 +236,16 @@ <xsl:call-template name="updateXML"/> </xsl:variable> <xsl:for-each select="xalan:nodeset($updated_xml)/*"> - <xsl:variable name="updated_xml_with_pages_preface"> - <xsl:call-template name="processPrefaceSectionsDefault_items"/> + <xsl:variable name="updated_xml_with_pages"> + <xsl:call-template name="processPrefaceAndMainSectionsDefault_items"/> </xsl:variable> - <xsl:for-each select="xalan:nodeset($updated_xml_with_pages_preface)"> <!-- set context to preface --> - <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]"> + <xsl:for-each select="xalan:nodeset($updated_xml_with_pages)"> <!-- set context to preface/sections --> + <xsl:for-each select=".//*[local-name() = 'page_sequence'][parent::*[local-name() = 'preface']][normalize-space() != '' or .//image or .//svg]"> <!-- Copyright, Content, Foreword, etc. pages --> <fo:page-sequence master-reference="preface" format="i"> <xsl:attribute name="master-reference"> @@ -303,19 +303,13 @@ <fo:block/> <!-- for prevent empty preface --> </fo:flow> </fo:page-sequence> </xsl:for-each> - </xsl:for-each> - <xsl:variable name="updated_xml_with_pages_main"> - <xsl:call-template name="processMainSectionsDefault_items"/> - </xsl:variable> + <xsl:for-each select=".//*[local-name() = 'page_sequence'][not(parent::*[local-name() = 'preface'])][normalize-space() != '' or .//image or .//svg]"> - <xsl:for-each select="xalan:nodeset($updated_xml_with_pages_main)"> <!-- set context to preface --> - <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]"> - <!-- Document Pages --> <fo:page-sequence master-reference="document" format="1" force-page-count="no-force"> <xsl:attribute name="master-reference"> <xsl:text>document</xsl:text> @@ -682,10 +676,12 @@ <xsl:strip-space elements="csd:xref"/> <xsl:variable name="namespace_full" select="namespace-uri(/*)"/> <!-- example: https://www.metanorma.org/ns/iso --> <xsl:variable name="root_element" select="local-name(/*)"/> <!-- example: iso-standard --> + <xsl:variable name="document_scheme" select="normalize-space(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = 'document-scheme']/*[local-name() = 'value'])"/> + <!-- external parameters --> <xsl:param name="svg_images"/> <!-- svg images array --> <xsl:variable name="images" select="document($svg_images)"/> <xsl:param name="basepath"/> <!-- base path for images --> @@ -2319,60 +2315,13 @@ <xsl:sort select="@displayorder" data-type="number"/> <xsl:apply-templates select="."/> </xsl:for-each> </xsl:template> - <xsl:template name="processPrefaceSectionsDefault_items"> - - <xsl:variable name="updated_xml_step_move_pagebreak"> - - <xsl:element name="{$root_element}" namespace="{$namespace_full}"> - - <xsl:call-template name="copyCommonElements"/> - - <xsl:element name="preface" namespace="{$namespace_full}"> <!-- save context element --> - <xsl:element name="page_sequence" namespace="{$namespace_full}"> - <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]"> - <xsl:sort select="@displayorder" data-type="number"/> - <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/> - </xsl:for-each> - </xsl:element> - </xsl:element> - </xsl:element> - </xsl:variable> - - <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_preface_', java:getTime(java:java.util.Date.new()), '.xml')"/> - <!-- <xsl:message>updated_xml_step_move_pagebreak_filename=<xsl:value-of select="$updated_xml_step_move_pagebreak_filename"/></xsl:message> - <xsl:message>start write updated_xml_step_move_pagebreak_filename</xsl:message> --> - <redirect:write file="{$updated_xml_step_move_pagebreak_filename}"> - <xsl:copy-of select="$updated_xml_step_move_pagebreak"/> - </redirect:write> - <!-- <xsl:message>end write updated_xml_step_move_pagebreak_filename</xsl:message> --> - - <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/> - - <!-- TODO: instead of - <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]"> - in each template, add removing empty page_sequence here - --> - - <xsl:if test="$debug = 'true'"> - <redirect:write file="page_sequence_preface.xml"> - <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/> - </redirect:write> - </xsl:if> - - <!-- <xsl:message>start delete updated_xml_step_move_pagebreak_filename</xsl:message> --> - <xsl:call-template name="deleteFile"> - <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/> - </xsl:call-template> - <!-- <xsl:message>end delete updated_xml_step_move_pagebreak_filename</xsl:message> --> - </xsl:template> <!-- END: processPrefaceSectionsDefault_items --> - <xsl:template name="copyCommonElements"> <!-- copy bibdata, localized-strings, metanorma-extension and boilerplate --> - <xsl:copy-of select="/*/*[local-name() != 'preface' and local-name() != 'sections' and local-name() != 'annex' and local-name() != 'bibliography']"/> + <xsl:copy-of select="/*/*[local-name() != 'preface' and local-name() != 'sections' and local-name() != 'annex' and local-name() != 'bibliography' and local-name() != 'indexsect']"/> </xsl:template> <xsl:template name="processMainSectionsDefault"> <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']"> <xsl:sort select="@displayorder" data-type="number"/> @@ -2389,12 +2338,20 @@ <xsl:sort select="@displayorder" data-type="number"/> <xsl:apply-templates select="."/> </xsl:for-each> </xsl:template><!-- END: processMainSectionsDefault --> - <!-- Example: + <!-- Example: <iso-standard> + <preface> + <page_sequence> + <clause... + </page_sequence> + <page_sequence> + <clause... + </page_sequence> + </preface> <sections> <page_sequence> <clause... </page_sequence> <page_sequence> @@ -2407,65 +2364,205 @@ <page_sequence> <annex .. </page_sequence> </iso-standard> --> - <xsl:template name="processMainSectionsDefault_items"> + <xsl:template name="processPrefaceAndMainSectionsDefault_items"> <xsl:variable name="updated_xml_step_move_pagebreak"> - <xsl:element name="{$root_element}" namespace="{$namespace_full}"> - <xsl:call-template name="copyCommonElements"/> + <xsl:call-template name="insertPrefaceSectionsPageSequences"/> + <xsl:call-template name="insertMainSectionsPageSequences"/> + </xsl:element> + </xsl:variable> - <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element --> - <xsl:element name="page_sequence" namespace="{$namespace_full}"> - <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']"> - <xsl:sort select="@displayorder" data-type="number"/> - <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/> + <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/> - </xsl:for-each> - </xsl:element> + <redirect:write file="{$updated_xml_step_move_pagebreak_filename}"> + <xsl:copy-of select="$updated_xml_step_move_pagebreak"/> + </redirect:write> + + <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/> + + <xsl:if test="$debug = 'true'"> + <redirect:write file="page_sequence_preface_and_main.xml"> + <xsl:copy-of select="$updated_xml_step_move_pagebreak"/> + </redirect:write> + </xsl:if> + + <xsl:call-template name="deleteFile"> + <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/> + </xsl:call-template> + </xsl:template> <!-- END: processPrefaceAndMainSectionsDefault_items --> + + <xsl:template name="insertPrefaceSectionsPageSequences"> + <xsl:element name="preface" namespace="{$namespace_full}"> <!-- save context element --> + <xsl:element name="page_sequence" namespace="{$namespace_full}"> + <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]"> + <xsl:sort select="@displayorder" data-type="number"/> + <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/> + </xsl:for-each> + </xsl:element> + </xsl:element> + </xsl:template> <!-- END: insertPrefaceSectionsPageSequences --> + + <xsl:template name="insertMainSectionsPageSequences"> + <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element --> + <xsl:element name="page_sequence" namespace="{$namespace_full}"> + <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']"> + <xsl:sort select="@displayorder" data-type="number"/> + <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/> + + </xsl:for-each> + </xsl:element> + </xsl:element> + + <xsl:element name="page_sequence" namespace="{$namespace_full}"> + <xsl:for-each select="/*/*[local-name()='annex']"> + <xsl:sort select="@displayorder" data-type="number"/> + <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/> + </xsl:for-each> + </xsl:element> + + <xsl:element name="page_sequence" namespace="{$namespace_full}"> + <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element --> + <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]"> + <xsl:sort select="@displayorder" data-type="number"/> + <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/> + </xsl:for-each> + </xsl:element> + </xsl:element> + </xsl:template> <!-- END: insertMainSectionsPageSequences --> + + <xsl:template name="insertMainSectionsInSeparatePageSequences"> + <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element --> + <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']"> + <xsl:sort select="@displayorder" data-type="number"/> + <xsl:element name="page_sequence" namespace="{$namespace_full}"> + <xsl:attribute name="main_page_sequence"/> + <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/> </xsl:element> + </xsl:for-each> + </xsl:element> + <xsl:call-template name="insertAnnexInSeparatePageSequences"/> + + <xsl:call-template name="insertBibliographyInSeparatePageSequences"/> + + <!-- <xsl:call-template name="insertIndexInSeparatePageSequences"/> --> + </xsl:template> <!-- END: insertMainSectionsInSeparatePageSequences --> + + <xsl:template name="insertAnnexInSeparatePageSequences"> + <xsl:for-each select="/*/*[local-name()='annex']"> + <xsl:sort select="@displayorder" data-type="number"/> + <xsl:element name="page_sequence" namespace="{$namespace_full}"> + <xsl:attribute name="main_page_sequence"/> + <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/> + </xsl:element> + </xsl:for-each> + </xsl:template> + <xsl:template name="insertBibliographyInSeparatePageSequences"> + <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element --> + <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]"> + <xsl:sort select="@displayorder" data-type="number"/> <xsl:element name="page_sequence" namespace="{$namespace_full}"> - <xsl:for-each select="/*/*[local-name()='annex']"> - <xsl:sort select="@displayorder" data-type="number"/> - <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/> - </xsl:for-each> + <xsl:attribute name="main_page_sequence"/> + <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/> </xsl:element> + </xsl:for-each> + </xsl:element> + </xsl:template> + <xsl:template name="insertIndexInSeparatePageSequences"> + <xsl:for-each select="/*/*[local-name()='indexsect']"> + <xsl:sort select="@displayorder" data-type="number"/> + <xsl:element name="page_sequence" namespace="{$namespace_full}"> + <xsl:attribute name="main_page_sequence"/> + <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/> + </xsl:element> + </xsl:for-each> + </xsl:template> + <xsl:template name="processAllSectionsDefault_items"> + <xsl:variable name="updated_xml_step_move_pagebreak"> + <xsl:element name="{$root_element}" namespace="{$namespace_full}"> + <xsl:call-template name="copyCommonElements"/> <xsl:element name="page_sequence" namespace="{$namespace_full}"> - <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element --> - <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]"> - <xsl:sort select="@displayorder" data-type="number"/> - <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"/> - </xsl:for-each> - </xsl:element> + <xsl:call-template name="insertPrefaceSections"/> + <xsl:call-template name="insertMainSections"/> </xsl:element> </xsl:element> </xsl:variable> - <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_main_', java:getTime(java:java.util.Date.new()), '.xml')"/> - + <xsl:variable name="updated_xml_step_move_pagebreak_filename" select="concat($output_path,'_preface_and_main_', java:getTime(java:java.util.Date.new()), '.xml')"/> + <!-- <xsl:message>updated_xml_step_move_pagebreak_filename=<xsl:value-of select="$updated_xml_step_move_pagebreak_filename"/></xsl:message> + <xsl:message>start write updated_xml_step_move_pagebreak_filename</xsl:message> --> <redirect:write file="{$updated_xml_step_move_pagebreak_filename}"> <xsl:copy-of select="$updated_xml_step_move_pagebreak"/> </redirect:write> + <!-- <xsl:message>end write updated_xml_step_move_pagebreak_filename</xsl:message> --> <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/> + <!-- TODO: instead of + <xsl:for-each select=".//*[local-name() = 'page_sequence'][normalize-space() != '' or .//image or .//svg]"> + in each template, add removing empty page_sequence here + --> + <xsl:if test="$debug = 'true'"> - <redirect:write file="page_sequence_main.xml"> - <xsl:copy-of select="document($updated_xml_step_move_pagebreak_filename)"/> + <redirect:write file="page_sequence_preface_and_main.xml"> + <xsl:copy-of select="$updated_xml_step_move_pagebreak"/> </redirect:write> </xsl:if> + <!-- <xsl:message>start delete updated_xml_step_move_pagebreak_filename</xsl:message> --> <xsl:call-template name="deleteFile"> <xsl:with-param name="filepath" select="$updated_xml_step_move_pagebreak_filename"/> </xsl:call-template> - </xsl:template> <!-- END: processMainSectionsDefault_items --> + <!-- <xsl:message>end delete updated_xml_step_move_pagebreak_filename</xsl:message> --> + </xsl:template> <!-- END: processAllSectionsDefault_items --> + <xsl:template name="insertPrefaceSections"> + <xsl:element name="preface" namespace="{$namespace_full}"> <!-- save context element --> + <xsl:for-each select="/*/*[local-name()='preface']/*[not(local-name() = 'note' or local-name() = 'admonition')]"> + <xsl:sort select="@displayorder" data-type="number"/> + <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"> + <xsl:with-param name="page_sequence_at_top">true</xsl:with-param> + </xsl:apply-templates> + </xsl:for-each> + </xsl:element> + </xsl:template> + + <xsl:template name="insertMainSections"> + <xsl:element name="sections" namespace="{$namespace_full}"> <!-- save context element --> + + <xsl:for-each select="/*/*[local-name()='sections']/* | /*/*[local-name()='bibliography']/*[local-name()='references'][@normative='true']"> + <xsl:sort select="@displayorder" data-type="number"/> + <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"> + <xsl:with-param name="page_sequence_at_top">true</xsl:with-param> + </xsl:apply-templates> + + </xsl:for-each> + </xsl:element> + + <xsl:for-each select="/*/*[local-name()='annex']"> + <xsl:sort select="@displayorder" data-type="number"/> + <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"> + <xsl:with-param name="page_sequence_at_top">true</xsl:with-param> + </xsl:apply-templates> + </xsl:for-each> + + <xsl:element name="bibliography" namespace="{$namespace_full}"> <!-- save context element --> + <xsl:for-each select="/*/*[local-name()='bibliography']/*[not(@normative='true')] | /*/*[local-name()='bibliography']/*[local-name()='clause'][*[local-name()='references'][not(@normative='true')]]"> + <xsl:sort select="@displayorder" data-type="number"/> + <xsl:apply-templates select="." mode="update_xml_step_move_pagebreak"> + <xsl:with-param name="page_sequence_at_top">true</xsl:with-param> + </xsl:apply-templates> + </xsl:for-each> + </xsl:element> + </xsl:template> + <xsl:template name="deleteFile"> <xsl:param name="filepath"/> <xsl:variable name="xml_file" select="java:java.io.File.new($filepath)"/> <xsl:variable name="xml_file_path" select="java:toPath($xml_file)"/> <xsl:variable name="deletefile" select="java:java.nio.file.Files.deleteIfExists($xml_file_path)"/> @@ -2505,13 +2602,20 @@ <xsl:choose> <xsl:when test="contains($text, $tag_open)"> <xsl:value-of select="substring-before($text, $tag_open)"/> <!-- <xsl:text disable-output-escaping="yes">&lt;fo:inline keep-together.within-line="always"&gt;</xsl:text> --> <xsl:variable name="text_after" select="substring-after($text, $tag_open)"/> - <fo:inline keep-together.within-line="always"> - <xsl:value-of select="substring-before($text_after, $tag_close)"/> - </fo:inline> + <xsl:choose> + <xsl:when test="local-name(..) = 'keep-together_within-line'"> <!-- prevent two nested <fo:inline keep-together.within-line="always"><fo:inline keep-together.within-line="always" --> + <xsl:value-of select="substring-before($text_after, $tag_close)"/> + </xsl:when> + <xsl:otherwise> + <fo:inline keep-together.within-line="always" role="SKIP"> + <xsl:value-of select="substring-before($text_after, $tag_close)"/> + </fo:inline> + </xsl:otherwise> + </xsl:choose> <!-- <xsl:text disable-output-escaping="yes">&lt;/fo:inline&gt;</xsl:text> --> <xsl:call-template name="replace_fo_inline_tags"> <xsl:with-param name="tag_open" select="$tag_open"/> <xsl:with-param name="tag_close" select="$tag_close"/> <xsl:with-param name="text" select="substring-after($text_after, $tag_close)"/> @@ -3674,10 +3778,12 @@ <fo:table-cell xsl:use-attribute-sets="table-header-cell-style"> <!-- text-align="{@align}" --> <xsl:call-template name="setTextAlignment"> <xsl:with-param name="default">center</xsl:with-param> </xsl:call-template> + <xsl:copy-of select="@keep-together.within-line"/> + <xsl:call-template name="refine_table-header-cell-style"/> <!-- experimental feature, see https://github.com/metanorma/metanorma-plateau/issues/30#issuecomment-2145461828 --> <!-- <xsl:choose> <xsl:when test="count(node()) = 1 and *[local-name() = 'span'][contains(@style, 'text-orientation')]"> @@ -3732,10 +3838,12 @@ <fo:table-cell xsl:use-attribute-sets="table-cell-style"> <!-- text-align="{@align}" --> <xsl:call-template name="setTextAlignment"> <xsl:with-param name="default">left</xsl:with-param> </xsl:call-template> + <xsl:copy-of select="@keep-together.within-line"/> + <xsl:call-template name="refine_table-cell-style"/> <xsl:if test=".//*[local-name() = 'table']"> <!-- if there is nested table --> <xsl:attribute name="padding-right">1mm</xsl:attribute> </xsl:if> @@ -3762,10 +3870,11 @@ </xsl:template> <!-- td --> <xsl:template match="*[local-name()='table']/*[local-name()='note' or local-name() = 'example']" priority="2"> <fo:block xsl:use-attribute-sets="table-note-style"> + <xsl:copy-of select="@id"/> <xsl:call-template name="refine_table-note-style"/> <!-- Table's note/example name (NOTE, for example) --> <fo:inline xsl:use-attribute-sets="table-note-name-style"> @@ -3855,11 +3964,11 @@ <xsl:for-each select="xalan:nodeset($fn_styles)/fn_styles/@*"> <xsl:copy-of select="."/> </xsl:for-each> - <xsl:if test="following-sibling::*[1][local-name() = 'fn']"> + <xsl:if test="following-sibling::node()[normalize-space() != ''][1][local-name() = 'fn']"> <xsl:attribute name="padding-right">0.5mm</xsl:attribute> </xsl:if> <xsl:call-template name="insert_basic_link"> <xsl:with-param name="element"> @@ -3922,11 +4031,11 @@ <fn gen_id="{generate-id(.)}"> <xsl:copy-of select="@*"/> <xsl:copy-of select="node()"/> </fn> </xsl:for-each> - <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='boilerplate']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]/*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='bibliography']/*"> + <xsl:for-each select="ancestor::*[contains(local-name(), '-standard')]/*[local-name()='boilerplate']/* | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='preface']/* | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='sections']/* | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='annex'] | ancestor::*[contains(local-name(), '-standard')]//*[local-name()='bibliography']/*"> <xsl:sort select="@displayorder" data-type="number"/> <!-- commented: .//*[local-name() = 'bibitem'][ancestor::*[local-name() = 'references']]/*[local-name() = 'note'] | because 'fn' there is in biblio-tag --> <xsl:for-each select=".//*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure')] and not(ancestor::*[local-name() = 'name']))][generate-id(.)=generate-id(key('kfn',@reference)[1])]"> @@ -3996,10 +4105,15 @@ </xsl:for-each> </xsl:template> <xsl:template name="create_fn"> <fn reference="{@reference}" id="{@reference}_{ancestor::*[@id][1]/@id}"> + <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> <!-- for footnotes in tables --> + <xsl:attribute name="id"> + <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/> + </xsl:attribute> + </xsl:if> <xsl:apply-templates/> </fn> </xsl:template> @@ -4139,10 +4253,15 @@ <fo:inline xsl:use-attribute-sets="fn-reference-style"> <xsl:call-template name="refine_fn-reference-style"/> <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id--> + <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> <!-- for footnotes in tables --> + <xsl:attribute name="internal-destination"> + <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/> + </xsl:attribute> + </xsl:if> <xsl:value-of select="@reference"/> </fo:basic-link> </fo:inline> @@ -5183,11 +5302,11 @@ </fo:inline> </xsl:template> <xsl:template name="recursiveSmallCaps"> <xsl:param name="text"/> - <xsl:param name="ratio"/> + <xsl:param name="ratio">0.75</xsl:param> <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"> @@ -7283,10 +7402,12 @@ </xsl:when> <xsl:otherwise>Figure</xsl:otherwise> </xsl:choose> </xsl:variable> + <xsl:variable name="isPrecedingTitle" select="normalize-space(ancestor::*[local-name() = 'figure']/preceding-sibling::*[1][local-name() = 'title'] and 1 = 1)"/> + <xsl:choose> <xsl:when test=".//*[local-name() = 'a'][*[local-name() = 'rect'] or *[local-name() = 'polygon'] or *[local-name() = 'circle'] or *[local-name() = 'ellipse']]"> <fo:block> <xsl:variable name="width" select="@width"/> <xsl:variable name="height" select="@height"/> @@ -7429,11 +7550,18 @@ </xsl:choose> </xsl:variable> <xsl:variable name="scale_y"> <xsl:choose> <xsl:when test="$svg_height * $scale_x &gt; $height_effective_px"> - <xsl:value-of select="$height_effective_px div ($svg_height * $scale_x)"/> + <xsl:variable name="height_effective_px_"> + <xsl:choose> + <!-- title is 'keep-with-next' with following figure --> + <xsl:when test="$isPrecedingTitle = 'true'"><xsl:value-of select="$height_effective_px - 80"/></xsl:when> + <xsl:otherwise><xsl:value-of select="$height_effective_px"/></xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:value-of select="$height_effective_px_ div ($svg_height * $scale_x)"/> </xsl:when> <xsl:otherwise>1</xsl:otherwise> </xsl:choose> </xsl:variable> @@ -7848,11 +7976,11 @@ <fo:bookmark-title>collection.pdf</fo:bookmark-title> </fo:bookmark> </xsl:if> <xsl:for-each select="$contents_nodes/doc"> - <fo:bookmark internal-destination="{contents/item[1]/@id}" starting-state="hide"> + <fo:bookmark internal-destination="{contents/item[@display = 'true'][1]/@id}" starting-state="hide"> <xsl:if test="@bundle = 'true'"> <xsl:attribute name="internal-destination"><xsl:value-of select="@firstpage_id"/></xsl:attribute> </xsl:if> <fo:bookmark-title> <xsl:choose> @@ -9061,13 +9189,21 @@ </xsl:apply-templates> </fo:block> <fo:block-container xsl:use-attribute-sets="example-body-style" role="SKIP"> <fo:block-container margin-left="0mm" margin-right="0mm" role="SKIP"> - <xsl:apply-templates select="node()[not(local-name() = 'name')]"> - <xsl:with-param name="fo_element" select="$fo_element"/> - </xsl:apply-templates> + <xsl:variable name="example_body"> + <xsl:apply-templates select="node()[not(local-name() = 'name')]"> + <xsl:with-param name="fo_element" select="$fo_element"/> + </xsl:apply-templates> + </xsl:variable> + <xsl:choose> + <xsl:when test="xalan:nodeset($example_body)/*"> + <xsl:copy-of select="$example_body"/> + </xsl:when> + <xsl:otherwise><fo:block/><!-- prevent empty block-container --></xsl:otherwise> + </xsl:choose> </fo:block-container> </fo:block-container> </xsl:when> <!-- end block --> <xsl:when test="contains(normalize-space($fo_element), 'list')"> @@ -9607,13 +9743,28 @@ </xsl:template> <!-- note: @top-level added in mode=" update_xml_step_move_pagebreak" --> <xsl:template match="*[local-name() = 'sections']/*[local-name() = 'page_sequence']/*[not(@top-level)]" priority="2"> - <xsl:call-template name="sections_node"/> + <xsl:choose> + <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/> + <xsl:otherwise> + <xsl:call-template name="sections_node"/> + </xsl:otherwise> + </xsl:choose> </xsl:template> + <!-- page_sequence/sections/clause --> + <xsl:template match="*[local-name() = 'page_sequence']/*[local-name() = 'sections']/*[not(@top-level)]" priority="2"> + <xsl:choose> + <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/> + <xsl:otherwise> + <xsl:call-template name="sections_node"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + <xsl:template name="sections_element_style"> <xsl:variable name="pos"><xsl:number count="csd:sections/*/csd:clause | csd:sections/*/csd:terms"/></xsl:variable> <xsl:if test="$pos &gt;= 2"> <xsl:attribute name="space-before">18pt</xsl:attribute> @@ -9629,14 +9780,30 @@ <xsl:call-template name="setId"/> <xsl:apply-templates/> </fo:block> </xsl:template> - <xsl:template match="*[local-name() = 'preface']/*[local-name() = 'page_sequence']/*" priority="2"> <!-- /*/*[local-name() = 'preface']/* --> - <xsl:call-template name="preface_node"/> + <!-- preface/ page_sequence/clause --> + <xsl:template match="*[local-name() = 'preface']/*[local-name() = 'page_sequence']/*[not(@top-level)]" priority="2"> <!-- /*/*[local-name() = 'preface']/* --> + <xsl:choose> + <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/> + <xsl:otherwise> + <xsl:call-template name="preface_node"/> + </xsl:otherwise> + </xsl:choose> </xsl:template> + <!-- page_sequence/preface/clause --> + <xsl:template match="*[local-name() = 'page_sequence']/*[local-name() = 'preface']/*[not(@top-level)]" priority="2"> <!-- /*/*[local-name() = 'preface']/* --> + <xsl:choose> + <xsl:when test="local-name() = 'clause' and normalize-space() = '' and count(*) = 0"/> + <xsl:otherwise> + <xsl:call-template name="preface_node"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + <xsl:template match="*[local-name() = 'clause'][normalize-space() != '' or *[local-name() = 'figure'] or @id]" name="template_clause"> <!-- if clause isn't empty --> <fo:block> <xsl:if test="parent::*[local-name() = 'copyright-statement']"> <xsl:attribute name="role">SKIP</xsl:attribute> </xsl:if> @@ -10940,11 +11107,18 @@ <!-- <redirect:write file="updated_xml_step3_{java:getTime(java:java.util.Date.new())}.xml"> <xsl:copy-of select="$updated_xml_step3"/> </redirect:write> --> </xsl:if> + <!-- <xsl:if test="$debug = 'true'"><xsl:message>START copying updated_xml_step3</xsl:message></xsl:if> + <xsl:variable name="startTime4" select="java:getTime(java:java.util.Date.new())"/> --> <xsl:copy-of select="$updated_xml_step3"/> + <!-- <xsl:variable name="endTime4" select="java:getTime(java:java.util.Date.new())"/> + <xsl:if test="$debug = 'true'"> + <xsl:message>DEBUG: processing time <xsl:value-of select="$endTime4 - $startTime4"/> msec.</xsl:message> + <xsl:message>END copying updated_xml_step3</xsl:message> + </xsl:if> --> </xsl:template> <!-- =========================================================================== --> <!-- STEP1: --> @@ -11122,18 +11296,21 @@ <!-- =========================================================================== --> <!-- STEP MOVE PAGEBREAK: move <pagebreak/> at top level under 'preface' and 'sections' --> <!-- =========================================================================== --> <xsl:template match="@*|node()" mode="update_xml_step_move_pagebreak"> + <xsl:param name="page_sequence_at_top">false</xsl:param> <xsl:copy> - <xsl:apply-templates select="@*|node()" mode="update_xml_step_move_pagebreak"/> + <xsl:apply-templates select="@*|node()" mode="update_xml_step_move_pagebreak"> + <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/> + </xsl:apply-templates> </xsl:copy> </xsl:template> <!-- replace 'pagebreak' by closing tags + page_sequence and opening page_sequence + tags --> <xsl:template match="*[local-name() = 'pagebreak'][not(following-sibling::*[1][local-name() = 'pagebreak'])]" mode="update_xml_step_move_pagebreak"> - + <xsl:param name="page_sequence_at_top"/> <!-- <xsl:choose> <xsl:when test="ancestor::*[local-name() = 'sections']"> </xsl:when> <xsl:when test="ancestor::*[local-name() = 'annex']"> @@ -11153,11 +11330,13 @@ <xsl:if test="contains($isLast, 'false')"> <xsl:variable name="orientation" select="normalize-space(@orientation)"/> <xsl:variable name="tree_"> - <xsl:call-template name="makeAncestorsElementsTree"/> + <xsl:call-template name="makeAncestorsElementsTree"> + <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/> + </xsl:call-template> </xsl:variable> <xsl:variable name="tree" select="xalan:nodeset($tree_)"/> <!-- close fo:page-sequence (closing preceding fo elements) --> <xsl:call-template name="insertClosingElements"> @@ -11175,16 +11354,30 @@ </xsl:if> </xsl:template> <xsl:template name="makeAncestorsElementsTree"> - <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]"> - <element pos="{position()}"> - <xsl:copy-of select="@*[local-name() != 'id']"/> - <xsl:value-of select="name()"/> - </element> - </xsl:for-each> + <xsl:param name="page_sequence_at_top"/> + + <xsl:choose> + <xsl:when test="$page_sequence_at_top = 'true'"> + <xsl:for-each select="ancestor::*[ancestor::*[contains(local-name(), '-standard')]]"> + <element pos="{position()}"> + <xsl:copy-of select="@*[local-name() != 'id']"/> + <xsl:value-of select="name()"/> + </element> + </xsl:for-each> + </xsl:when> + <xsl:otherwise> + <xsl:for-each select="ancestor::*[ancestor::*[local-name() = 'preface'] or ancestor::*[local-name() = 'sections'] or ancestor-or-self::*[local-name() = 'annex']]"> + <element pos="{position()}"> + <xsl:copy-of select="@*[local-name() != 'id']"/> + <xsl:value-of select="name()"/> + </element> + </xsl:for-each> + </xsl:otherwise> + </xsl:choose> </xsl:template> <xsl:template name="insertClosingElements"> <xsl:param name="tree"/> <xsl:for-each select="$tree//element"> @@ -11218,15 +11411,18 @@ </xsl:for-each> </xsl:template> <!-- move full page width figures, tables at top level --> <xsl:template match="*[local-name() = 'figure' or local-name() = 'table'][normalize-space(@width) != 'text-width']" mode="update_xml_step_move_pagebreak"> + <xsl:param name="page_sequence_at_top">false</xsl:param> <xsl:choose> <xsl:when test="$layout_columns != 1"> <xsl:variable name="tree_"> - <xsl:call-template name="makeAncestorsElementsTree"/> + <xsl:call-template name="makeAncestorsElementsTree"> + <xsl:with-param name="page_sequence_at_top" select="$page_sequence_at_top"/> + </xsl:call-template> </xsl:variable> <xsl:variable name="tree" select="xalan:nodeset($tree_)"/> <xsl:call-template name="insertClosingElements"> <xsl:with-param name="tree" select="$tree"/> @@ -11266,85 +11462,144 @@ </xsl:copy> </xsl:template> <xsl:variable name="express_reference_separators">_.\</xsl:variable> <xsl:variable name="express_reference_characters" select="concat($upper,$lower,'1234567890',$express_reference_separators)"/> + <xsl:variable name="regex_express_reference">(^([A-Za-z0-9_.\\]+)$)</xsl:variable> <xsl:variable name="element_name_keep-together_within-line">keep-together_within-line</xsl:variable> + <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable> + <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable> - <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or ancestor::*[local-name() = 'svg'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line"> + <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) --> + <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> --> + <!-- add &lt; and &gt; to \S --> + <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable> + <xsl:variable name="regex_solidus_units">((\b((<xsl:value-of select="$regex_S"/>{1,3}\/<xsl:value-of select="$regex_S"/>+)|(<xsl:value-of select="$regex_S"/>+\/<xsl:value-of select="$regex_S"/>{1,3}))\b)|(\/<xsl:value-of select="$regex_S"/>{1,3})\b)</xsl:variable> - <!-- enclose standard's number into tag 'keep-together_within-line' --> - <xsl:variable name="tag_keep-together_within-line_open">###<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable> - <xsl:variable name="tag_keep-together_within-line_close">###/<xsl:value-of select="$element_name_keep-together_within-line"/>###</xsl:variable> - <xsl:variable name="text__" select="java:replaceAll(java:java.lang.String.new(.), $regex_standard_reference, concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/> - <xsl:variable name="text_"> - <xsl:choose> - <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:value-of select="."/></xsl:when> <!-- no need enclose standard's number into tag 'keep-together_within-line' in table cells --> - <xsl:otherwise><xsl:value-of select="$text__"/></xsl:otherwise> - </xsl:choose> - </xsl:variable> - <xsl:variable name="text"><text><xsl:call-template name="replace_text_tags"> + <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable> + <xsl:variable name="regex_dots_units">((\b((<xsl:value-of select="$non_white_space"/>{1,3}\.<xsl:value-of select="$non_white_space"/>+)|(<xsl:value-of select="$non_white_space"/>+\.<xsl:value-of select="$non_white_space"/>{1,3}))\b)|(\.<xsl:value-of select="$non_white_space"/>{1,3})\b)</xsl:variable> + + <xsl:template match="text()[not(ancestor::*[local-name() = 'bibdata'] or ancestor::*[local-name() = 'link'][not(contains(.,' '))] or ancestor::*[local-name() = 'sourcecode'] or ancestor::*[local-name() = 'math'] or ancestor::*[local-name() = 'svg'] or starts-with(., 'http://') or starts-with(., 'https://') or starts-with(., 'www.') or normalize-space() = '' )]" name="keep_together_standard_number" mode="update_xml_enclose_keep-together_within-line"> + + <xsl:variable name="parent" select="local-name(..)"/> + + <xsl:if test="1 = 2"> <!-- alternative variant --> + + <xsl:variable name="regexs"> + <!-- enclose standard's number into tag 'keep-together_within-line' --> + <xsl:if test="not(ancestor::*[local-name() = 'table'])"><regex><xsl:value-of select="$regex_standard_reference"/></regex></xsl:if> + <!-- if EXPRESS reference --> + + <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b --> + <regex><xsl:value-of select="$regex_solidus_units"/></regex> + <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY --> + <xsl:if test="ancestor::*[local-name() = 'td' or local-name() = 'th']"> + <regex><xsl:value-of select="$regex_dots_units"/></regex> + </xsl:if> + </xsl:variable> + + <xsl:variable name="regex_replacement"><xsl:text>(</xsl:text> + <xsl:for-each select="xalan:nodeset($regexs)/regex"> + <xsl:value-of select="."/> + <xsl:if test="position() != last()">|</xsl:if> + </xsl:for-each> + <xsl:text>)</xsl:text> + </xsl:variable> + + <!-- regex_replacement='<xsl:value-of select="$regex_replacement"/>' --> + + <xsl:variable name="text_replaced" select="java:replaceAll(java:java.lang.String.new(.), $regex_replacement, concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/> + + <!-- text_replaced='<xsl:value-of select="$text_replaced"/>' --> + + <xsl:call-template name="replace_text_tags"> <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/> <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/> - <xsl:with-param name="text" select="$text_"/> - </xsl:call-template></text></xsl:variable> + <xsl:with-param name="text" select="$text_replaced"/> + </xsl:call-template> + </xsl:if> - <xsl:variable name="parent" select="local-name(..)"/> + <xsl:if test="1 = 1"> + <!-- enclose standard's number into tag 'keep-together_within-line' --> + <xsl:variable name="text"> + <xsl:element name="text" namespace="{$namespace_full}"> + <xsl:choose> + <xsl:when test="ancestor::*[local-name() = 'table']"><xsl:value-of select="."/></xsl:when> <!-- no need enclose standard's number into tag 'keep-together_within-line' in table cells --> + <xsl:otherwise> + <xsl:variable name="text_" select="java:replaceAll(java:java.lang.String.new(.), $regex_standard_reference, concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/> + <!-- <xsl:value-of select="$text__"/> --> + + <xsl:call-template name="replace_text_tags"> + <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/> + <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/> + <xsl:with-param name="text" select="$text_"/> + </xsl:call-template> + + </xsl:otherwise> + </xsl:choose> + </xsl:element> + </xsl:variable> + <xsl:variable name="text2"> - <text><xsl:for-each select="xalan:nodeset($text)/text/node()"> + <xsl:element name="text" namespace="{$namespace_full}"> + <xsl:for-each select="xalan:nodeset($text)/*[local-name() = 'text']/node()"> <xsl:copy-of select="."/> - </xsl:for-each></text> + </xsl:for-each> + </xsl:element> </xsl:variable> <!-- keep-together_within-line for: a/b, aaa/b, a/bbb, /b --> - <!-- \S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ]) --> - <!-- <xsl:variable name="regex_solidus_units">((\b((\S{1,3}\/\S+)|(\S+\/\S{1,3}))\b)|(\/\S{1,3})\b)</xsl:variable> --> - <!-- add &lt; and &gt; to \S --> - <xsl:variable name="regex_S">[^\r\n\t\f\v \&lt;&gt;\u3000-\u9FFF]</xsl:variable> - <xsl:variable name="regex_solidus_units">((\b((<xsl:value-of select="$regex_S"/>{1,3}\/<xsl:value-of select="$regex_S"/>+)|(<xsl:value-of select="$regex_S"/>+\/<xsl:value-of select="$regex_S"/>{1,3}))\b)|(\/<xsl:value-of select="$regex_S"/>{1,3})\b)</xsl:variable> <xsl:variable name="text3"> - <text><xsl:for-each select="xalan:nodeset($text2)/text/node()"> - <xsl:choose> - <xsl:when test="self::text()"> - <xsl:variable name="text_units_" select="java:replaceAll(java:java.lang.String.new(.),$regex_solidus_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/> - <xsl:variable name="text_units"><text><xsl:call-template name="replace_text_tags"> - <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/> - <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/> - <xsl:with-param name="text" select="$text_units_"/> - </xsl:call-template></text></xsl:variable> - <xsl:copy-of select="xalan:nodeset($text_units)/text/node()"/> - </xsl:when> - <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... --> - </xsl:choose> - </xsl:for-each></text> + <xsl:element name="text" namespace="{$namespace_full}"> + <xsl:for-each select="xalan:nodeset($text2)/*[local-name() = 'text']/node()"> + <xsl:choose> + <xsl:when test="self::text()"> + <xsl:variable name="text_units" select="java:replaceAll(java:java.lang.String.new(.),$regex_solidus_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/> + <!-- <xsl:variable name="text_units"> + <xsl:element name="text" namespace="{$namespace_full}"> --> + <xsl:call-template name="replace_text_tags"> + <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/> + <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/> + <xsl:with-param name="text" select="$text_units"/> + </xsl:call-template> + <!-- </xsl:element> + </xsl:variable> + <xsl:copy-of select="xalan:nodeset($text_units)/*[local-name() = 'text']/node()"/> --> + </xsl:when> + <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... --> + </xsl:choose> + </xsl:for-each> + </xsl:element> </xsl:variable> <xsl:choose> <xsl:when test="ancestor::*[local-name() = 'td' or local-name() = 'th']"> <!-- keep-together_within-line for: a.b, aaa.b, a.bbb, .b in table's cell ONLY --> - <xsl:variable name="non_white_space">[^\s\u3000-\u9FFF]</xsl:variable> - <xsl:variable name="regex_dots_units">((\b((<xsl:value-of select="$non_white_space"/>{1,3}\.<xsl:value-of select="$non_white_space"/>+)|(<xsl:value-of select="$non_white_space"/>+\.<xsl:value-of select="$non_white_space"/>{1,3}))\b)|(\.<xsl:value-of select="$non_white_space"/>{1,3})\b)</xsl:variable> - <xsl:for-each select="xalan:nodeset($text3)/text/node()"> + <xsl:for-each select="xalan:nodeset($text3)/*[local-name() = 'text']/node()"> <xsl:choose> <xsl:when test="self::text()"> - <xsl:variable name="text_dots_" select="java:replaceAll(java:java.lang.String.new(.),$regex_dots_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/> - <xsl:variable name="text_dots"><text><xsl:call-template name="replace_text_tags"> - <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/> - <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/> - <xsl:with-param name="text" select="$text_dots_"/> - </xsl:call-template></text></xsl:variable> - <xsl:copy-of select="xalan:nodeset($text_dots)/text/node()"/> + <xsl:variable name="text_dots" select="java:replaceAll(java:java.lang.String.new(.),$regex_dots_units,concat($tag_keep-together_within-line_open,'$1',$tag_keep-together_within-line_close))"/> + <!-- <xsl:variable name="text_dots"> + <xsl:element name="text" namespace="{$namespace_full}"> --> + <xsl:call-template name="replace_text_tags"> + <xsl:with-param name="tag_open" select="$tag_keep-together_within-line_open"/> + <xsl:with-param name="tag_close" select="$tag_keep-together_within-line_close"/> + <xsl:with-param name="text" select="$text_dots"/> + </xsl:call-template> + <!-- </xsl:element> + </xsl:variable> + <xsl:copy-of select="xalan:nodeset($text_dots)/*[local-name() = 'text']/node()"/> --> </xsl:when> <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise> <!-- copy 'as-is' for <fo:inline keep-together.within-line="always" ... --> </xsl:choose> </xsl:for-each> </xsl:when> - <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/text/node()"/></xsl:otherwise> + <xsl:otherwise><xsl:copy-of select="xalan:nodeset($text3)/*[local-name() = 'text']/node()"/></xsl:otherwise> </xsl:choose> - + </xsl:if> </xsl:template> <xsl:template match="*[local-name() = 'stem'] | *[local-name() = 'image']" mode="update_xml_enclose_keep-together_within-line"> <xsl:copy-of select="."/> </xsl:template> @@ -11863,9 +12118,18 @@ <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, '_', $inputxml_filename_prefix, '_attachments', '/', @name, ')')"/> <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{@name}"/> </xsl:otherwise> </xsl:choose> </xsl:for-each> + <!-- references to external attachments (no binary-encoded within the Metanorma XML file) --> + <xsl:if test="not(//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment'])"> + <xsl:for-each select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment']]"> + <xsl:variable name="attachment_path" select="*[local-name() = 'uri'][@type = 'attachment']"/> + <xsl:variable name="url" select="concat('url(file:///',$inputxml_basepath, $attachment_path, ')')"/> + <xsl:variable name="filename_embedded" select="substring-after($attachment_path, concat('_', $inputxml_filename_prefix, '_attachments', '/'))"/> + <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$filename_embedded}"/> + </xsl:for-each> + </xsl:if> </xsl:template> <!-- addPDFUAmeta --> <xsl:template name="getId"> <xsl:choose> <xsl:when test="../@id"> \ No newline at end of file