lib/isodoc/itu/itu.resolution.xsl in metanorma-itu-2.5.3 vs lib/isodoc/itu/itu.resolution.xsl in metanorma-itu-2.5.4

- old
+ new

@@ -5992,10 +5992,11 @@ </xsl:otherwise> </xsl:choose> --> <fo:block role="SKIP"> <xsl:apply-templates/> + <xsl:if test="$isGenerateTableIF = 'false' and count(node()) = 0"> </xsl:if> </fo:block> </fo:table-cell> </xsl:template> <!-- cell in table header row - 'th' --> <xsl:template name="setTableCellAttributes"> @@ -6055,10 +6056,12 @@ <xsl:apply-templates/> <xsl:if test="$isGenerateTableIF = 'true'"> <fo:inline id="{@id}_end">end</fo:inline></xsl:if> <!-- to determine width of text --> <!-- <xsl:value-of select="$hair_space"/> --> + <xsl:if test="$isGenerateTableIF = 'false' and count(node()) = 0"> </xsl:if> + </fo:block> </fo:table-cell> </xsl:template> <!-- td --> <xsl:template match="*[local-name()='table']/*[local-name()='note' or local-name() = 'example']" priority="2"> @@ -8890,18 +8893,20 @@ <xsl:variable name="pdfAttachmentsList" select="xalan:nodeset($pdfAttachmentsList_)"/> <xsl:template match="*[local-name()='link']" name="link"> <xsl:variable name="target_normalized" select="translate(@target, '\', '/')"/> <xsl:variable name="target_attachment_name" select="substring-after($target_normalized, '_attachments/')"/> + <xsl:variable name="isLinkToEmbeddedFile" select="normalize-space(@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target])"/> <xsl:variable name="target"> <xsl:choose> <xsl:when test="@updatetype = 'true'"> <xsl:value-of select="concat(normalize-space(@target), '.pdf')"/> </xsl:when> <!-- link to the PDF attachment --> - <xsl:when test="@attachment = 'true' and $pdfAttachmentsList//attachment[@filename = current()/@target]"> - <xsl:value-of select="concat('url(embedded-file:', @target, ')')"/> + <xsl:when test="$isLinkToEmbeddedFile = 'true'"> + <xsl:variable name="target_file" select="java:org.metanorma.fop.Util.getFilenameFromPath(@target)"/> + <xsl:value-of select="concat('url(embedded-file:', $target_file, ')')"/> </xsl:when> <!-- <xsl:when test="starts-with($target_normalized, '_') and contains($target_normalized, '_attachments/') and $pdfAttachmentsList//attachment[@filename = $target_attachment_name]"> <xsl:value-of select="concat('url(embedded-file:', $target_attachment_name, ')')"/> </xsl:when> <xsl:when test="contains(@target, concat('_', $inputxml_filename_prefix, '_attachments'))"> @@ -8928,20 +8933,28 @@ <xsl:if test="starts-with(normalize-space(@target), 'mailto:') and not(ancestor::*[local-name() = 'td'])"> <xsl:attribute name="keep-together.within-line">always</xsl:attribute> </xsl:if> + <xsl:if test="$isLinkToEmbeddedFile = 'true'"> + <xsl:attribute name="color">inherit</xsl:attribute> + <xsl:attribute name="text-decoration">none</xsl:attribute> + </xsl:if> + <xsl:call-template name="refine_link-style"/> <xsl:choose> <xsl:when test="$target_text = ''"> <xsl:apply-templates/> </xsl:when> <xsl:otherwise> <xsl:call-template name="insert_basic_link"> <xsl:with-param name="element"> <fo:basic-link external-destination="{$target}" fox:alt-text="{$target}"> + <xsl:if test="$isLinkToEmbeddedFile = 'true'"> + <xsl:attribute name="role">Annot</xsl:attribute> + </xsl:if> <xsl:choose> <xsl:when test="normalize-space(.) = ''"> <xsl:call-template name="add-zero-spaces-link-java"> <xsl:with-param name="text" select="$target_text"/> </xsl:call-template> @@ -8950,10 +8963,14 @@ <!-- output text from <link>text</link> --> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> </fo:basic-link> + <xsl:if test="$isLinkToEmbeddedFile = 'true'"> + <!-- reserve space at right for PaperClip icon --> + <fo:inline keep-with-previous.within-line="always">        </fo:inline> + </xsl:if> </xsl:with-param> </xsl:call-template> </xsl:otherwise> </xsl:choose> </fo:inline> @@ -14501,13 +14518,18 @@ </rdf:Description> </rdf:RDF> </x:xmpmeta> <!-- add attachments --> <xsl:for-each select="//*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'attachment']"> - <xsl:variable name="description" select="normalize-space(//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]/*[local-name() = 'formattedref'])"/> + <xsl:variable name="bibitem_attachment_" select="//*[local-name() = 'bibitem'][@hidden = 'true'][*[local-name() = 'uri'][@type = 'attachment'] = current()/@name]"/> + <xsl:variable name="bibitem_attachment" select="xalan:nodeset($bibitem_attachment_)"/> + <xsl:variable name="description" select="normalize-space($bibitem_attachment/*[local-name() = 'formattedref'])"/> + <xsl:variable name="filename" select="java:org.metanorma.fop.Util.getFilenameFromPath(@name)"/> + <!-- Todo: need update --> + <xsl:variable name="afrelationship" select="normalize-space($bibitem_attachment//*[local-name() = 'span'][@class = 'pdf-AFRelationship'])"/> - <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" filename="{@name}"> + <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" filename="{$filename}" link-as-file-annotation="true"> <xsl:attribute name="src"> <xsl:choose> <xsl:when test="normalize-space() != ''"> <xsl:variable name="src_attachment" select="java:replaceAll(java:java.lang.String.new(.),'(&#13;&#10;|&#13;|&#10;)', '')"/> <!-- remove line breaks --> <xsl:value-of select="$src_attachment"/> @@ -14519,22 +14541,31 @@ </xsl:choose> </xsl:attribute> <xsl:if test="$description != ''"> <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute> </xsl:if> + <xsl:if test="$afrelationship != ''"> + <xsl:attribute name="afrelationship"><xsl:value-of select="$afrelationship"/></xsl:attribute> + </xsl:if> </pdf:embedded-file> </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="attachment_name" select="java:org.metanorma.fop.Util.getFilenameFromPath($attachment_path)"/> <xsl:variable name="url" select="concat('url(file:///',$basepath, $attachment_path, ')')"/> <xsl:variable name="description" select="normalize-space(*[local-name() = 'formattedref'])"/> - <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$attachment_path}"> + <!-- Todo: need update --> + <xsl:variable name="afrelationship" select="normalize-space(.//*[local-name() = 'span'][@class = 'pdf-AFRelationship'])"/> + <pdf:embedded-file xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf" src="{$url}" filename="{$attachment_name}" link-as-file-annotation="true"> <xsl:if test="$description != ''"> <xsl:attribute name="description"><xsl:value-of select="$description"/></xsl:attribute> </xsl:if> + <xsl:if test="$afrelationship != ''"> + <xsl:attribute name="afrelationship"><xsl:value-of select="$afrelationship"/></xsl:attribute> + </xsl:if> </pdf:embedded-file> </xsl:for-each> </xsl:if> </xsl:template> <!-- addPDFUAmeta --> @@ -14550,10 +14581,16 @@ </xsl:template> <!-- Get or calculate depth of the element --> <xsl:template name="getLevel"> <xsl:param name="depth"/> + <!-- <xsl:message> + <xsl:choose> + <xsl:when test="local-name() = 'title'">title=<xsl:value-of select="."/></xsl:when> + <xsl:when test="local-name() = 'clause'">clause/title=<xsl:value-of select="*[local-name() = 'title']"/></xsl:when> + </xsl:choose> + </xsl:message> --> <xsl:choose> <xsl:when test="normalize-space(@depth) != ''"> <xsl:value-of select="@depth"/> </xsl:when> <xsl:when test="normalize-space($depth) != ''"> @@ -14570,19 +14607,49 @@ <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="ancestor::*[local-name() = 'sections'] and self::*[local-name() = 'title']"> + <xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/> + <xsl:choose> + <xsl:when test="string(number($upper_clause_depth)) != 'NaN'"> + <xsl:value-of select="number($upper_clause_depth + 1)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$level_total - 2"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> <xsl:when test="ancestor::*[local-name() = 'sections']"> - <xsl:value-of select="$level_total - 1"/> + <xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][1]/*[local-name() = 'title']/@depth)"/> + <xsl:choose> + <xsl:when test="string(number($upper_clause_depth)) != 'NaN'"> + <xsl:value-of select="number($upper_clause_depth + 1)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$level_total - 1"/> + </xsl:otherwise> + </xsl:choose> </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'] and self::*[local-name() = 'title']"> + <xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/> + <xsl:choose> + <xsl:when test="string(number($upper_clause_depth)) != 'NaN'"> + <xsl:value-of select="number($upper_clause_depth + 1)"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$level_total - 1"/> + </xsl:otherwise> + </xsl:choose> + </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> @@ -14937,10 +15004,24 @@ </xsl:choose> </xsl:template> <!-- END: insert cover page image --> + <xsl:template name="insertVerticalChar"> + <xsl:param name="str"/> + <xsl:if test="string-length($str) &gt; 0"> + <fo:inline-container writing-mode="lr-tb" text-align="center" alignment-baseline="central" reference-orientation="90" width="1em" margin="0" padding="0" text-indent="0mm" last-line-end-indent="0mm" start-indent="0mm" end-indent="0mm"> + <fo:block-container width="1em"> + <fo:block line-height="1em"><xsl:value-of select="substring($str,1,1)"/></fo:block> + </fo:block-container> + </fo:inline-container> + <xsl:call-template name="insertVerticalChar"> + <xsl:with-param name="str" select="substring($str, 2)"/> + </xsl:call-template> + </xsl:if> + </xsl:template> + <xsl:template name="number-to-words"> <xsl:param name="number"/> <xsl:param name="first"/> <xsl:if test="$number != ''"> <xsl:variable name="words"> @@ -15222,8 +15303,22 @@ <xsl:text>&lt;/</xsl:text> <xsl:value-of select="local-name()"/> <xsl:text>&gt;</xsl:text> </fo:block> </xsl:if> + </xsl:template> + + <xsl:template match="@*|node()" mode="set_table_role_skip"> + <xsl:copy> + <xsl:apply-templates select="@*|node()" mode="set_table_role_skip"/> + </xsl:copy> + </xsl:template> + + <xsl:template match="*[starts-with(local-name(), 'table')]" mode="set_table_role_skip"> + <xsl:copy> + <xsl:apply-templates select="@*" mode="set_table_role_skip"/> + <xsl:attribute name="role">SKIP</xsl:attribute> + <xsl:apply-templates select="node()" mode="set_table_role_skip"/> + </xsl:copy> </xsl:template> </xsl:stylesheet> \ No newline at end of file