Skip to content

Commit

Permalink
xslt update based on metanorma/mn-native-pdf@ec9071e
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelligent2013 authored Oct 27, 2024
1 parent 8ed8696 commit a024b4d
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 60 deletions.
84 changes: 54 additions & 30 deletions lib/isodoc/ieee/ieee.amendment.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -6697,6 +6697,7 @@
</xsl:if>

<fo:block xsl:use-attribute-sets="table-name-style" role="SKIP">

<xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
<xsl:with-param name="continued">true</xsl:with-param>
</xsl:apply-templates>
Expand Down Expand Up @@ -7233,10 +7234,14 @@
<xsl:variable name="fn_styles">
<xsl:choose>
<xsl:when test="ancestor::*[local-name() = 'bibitem']">
<fn_styles xsl:use-attribute-sets="bibitem-note-fn-style"/>
<fn_styles xsl:use-attribute-sets="bibitem-note-fn-style">

</fn_styles>
</xsl:when>
<xsl:otherwise>
<fn_styles xsl:use-attribute-sets="fn-num-style"/>
<fn_styles xsl:use-attribute-sets="fn-num-style">

</fn_styles>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Expand Down Expand Up @@ -10099,6 +10104,7 @@
<xsl:if test="string-length(normalize-space()) &lt; 30 and not(contains(normalize-space(), 'http://')) and not(contains(normalize-space(), 'https://')) and not(ancestor::*[local-name() = 'table' or local-name() = 'dl'])">
<xsl:attribute name="keep-together.within-line">always</xsl:attribute>
</xsl:if>

<xsl:if test="parent::*[local-name() = 'add']">
<xsl:call-template name="append_add-style"/>
</xsl:if>
Expand Down Expand Up @@ -10207,44 +10213,44 @@

<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'note']" name="note">

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

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

<xsl:call-template name="refine_note-style"/>
<xsl:call-template name="refine_note-style"/>

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

<fo:block>
<fo:block>

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

<fo:inline xsl:use-attribute-sets="note-name-style" role="SKIP">
<fo:inline xsl:use-attribute-sets="note-name-style" role="SKIP">

<xsl:call-template name="refine_note-name-style"/>
<xsl:call-template name="refine_note-name-style"/>

<!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
<!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
<xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
<xsl:call-template name="append_add-style"/>
</xsl:if>
<!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
<!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
<xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
<xsl:call-template name="append_add-style"/>
</xsl:if>

<!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
<xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
<xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
<xsl:with-param name="skip">false</xsl:with-param>
</xsl:apply-templates>
</xsl:if>
<!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
<xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
<xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
<xsl:with-param name="skip">false</xsl:with-param>
</xsl:apply-templates>
</xsl:if>

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

</fo:inline>
</fo:inline>

<xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
</fo:block>
<xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
</fo:block>

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

</xsl:template>

Expand Down Expand Up @@ -12652,6 +12658,7 @@
</xsl:when>
<xsl:when test="contains(normalize-space($fo_element), 'block')">
<fo:block xsl:use-attribute-sets="example-name-style">

<xsl:apply-templates/>
</fo:block>
</xsl:when>
Expand All @@ -12667,6 +12674,7 @@

<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'table']/*[local-name() = 'example']/*[local-name() = 'name']">
<fo:inline xsl:use-attribute-sets="example-name-style">

<xsl:apply-templates/>
</fo:inline>
</xsl:template>
Expand Down Expand Up @@ -13033,12 +13041,14 @@

<xsl:if test="parent::*[local-name() = 'term'] and not(preceding-sibling::*[local-name() = 'preferred'])"> <!-- if first preffered in term, then display term's name -->
<fo:block xsl:use-attribute-sets="term-name-style" role="SKIP">

<xsl:apply-templates select="ancestor::*[local-name() = 'term'][1]/*[local-name() = 'name']"/>
</fo:block>
</xsl:if>

<fo:block xsl:use-attribute-sets="preferred-term-style" role="SKIP">
<xsl:call-template name="setStyle_preferred"/>

<xsl:apply-templates/>
</fo:block>
</fo:block>
Expand Down Expand Up @@ -16148,9 +16158,10 @@
<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertBackgroundPageImage">
<xsl:param name="number">1</xsl:param>
<xsl:param name="name">coverpage-image</xsl:param>
<xsl:param name="suffix"/>
<xsl:variable name="num" select="number($number)"/>
<!-- background image -->
<fo:block-container absolute-position="fixed" left="0mm" top="0mm" font-size="0" id="__internal_layout__coverpage_{$name}_{$number}_{generate-id()}">
<fo:block-container absolute-position="fixed" left="0mm" top="0mm" font-size="0" id="__internal_layout__coverpage{$suffix}_{$name}_{$number}_{generate-id()}">
<fo:block>
<xsl:for-each select="/*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = $name][1]/*[local-name() = 'value']/*[local-name() = 'image'][$num]">
<xsl:choose>
Expand Down Expand Up @@ -16216,16 +16227,29 @@

<!-- END: insert cover page image -->

<xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_ja_spec">[\uFF08\uFF09]</xsl:variable>
<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertVerticalChar">
<xsl:param name="str"/>
<xsl:param name="writing-mode">lr-tb</xsl:param>
<xsl:param name="reference-orientation">90</xsl:param>
<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:inline-container text-align="center" alignment-baseline="central" width="1em" margin="0" padding="0" text-indent="0mm" last-line-end-indent="0mm" start-indent="0mm" end-indent="0mm">
<xsl:if test="normalize-space($writing-mode) != ''">
<xsl:attribute name="writing-mode"><xsl:value-of select="$writing-mode"/></xsl:attribute>
<xsl:attribute name="reference-orientation">90</xsl:attribute>
</xsl:if>
<xsl:variable name="char" select="substring($str,1,1)"/>
<xsl:if test="normalize-space(java:matches(java:java.lang.String.new($char), concat('(', $regex_ja_spec, '{1,})'))) = 'true'">
<xsl:attribute name="reference-orientation">0</xsl:attribute>
</xsl:if>
<fo:block-container width="1em">
<fo:block line-height="1em"><xsl:value-of select="substring($str,1,1)"/></fo:block>
<fo:block line-height="1em"><xsl:value-of select="$char"/></fo:block>
</fo:block-container>
</fo:inline-container>
<xsl:call-template name="insertVerticalChar">
<xsl:with-param name="str" select="substring($str, 2)"/>
<xsl:with-param name="writing-mode" select="$writing-mode"/>
<xsl:with-param name="reference-orientation" select="$reference-orientation"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
Expand Down
84 changes: 54 additions & 30 deletions lib/isodoc/ieee/ieee.standard.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -6697,6 +6697,7 @@
</xsl:if>

<fo:block xsl:use-attribute-sets="table-name-style" role="SKIP">

<xsl:apply-templates select="ancestor::*[local-name()='table']/*[local-name()='name']">
<xsl:with-param name="continued">true</xsl:with-param>
</xsl:apply-templates>
Expand Down Expand Up @@ -7233,10 +7234,14 @@
<xsl:variable name="fn_styles">
<xsl:choose>
<xsl:when test="ancestor::*[local-name() = 'bibitem']">
<fn_styles xsl:use-attribute-sets="bibitem-note-fn-style"/>
<fn_styles xsl:use-attribute-sets="bibitem-note-fn-style">

</fn_styles>
</xsl:when>
<xsl:otherwise>
<fn_styles xsl:use-attribute-sets="fn-num-style"/>
<fn_styles xsl:use-attribute-sets="fn-num-style">

</fn_styles>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Expand Down Expand Up @@ -10099,6 +10104,7 @@
<xsl:if test="string-length(normalize-space()) &lt; 30 and not(contains(normalize-space(), 'http://')) and not(contains(normalize-space(), 'https://')) and not(ancestor::*[local-name() = 'table' or local-name() = 'dl'])">
<xsl:attribute name="keep-together.within-line">always</xsl:attribute>
</xsl:if>

<xsl:if test="parent::*[local-name() = 'add']">
<xsl:call-template name="append_add-style"/>
</xsl:if>
Expand Down Expand Up @@ -10207,44 +10213,44 @@

<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'note']" name="note">

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

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

<xsl:call-template name="refine_note-style"/>
<xsl:call-template name="refine_note-style"/>

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

<fo:block>
<fo:block>

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

<fo:inline xsl:use-attribute-sets="note-name-style" role="SKIP">
<fo:inline xsl:use-attribute-sets="note-name-style" role="SKIP">

<xsl:call-template name="refine_note-name-style"/>
<xsl:call-template name="refine_note-name-style"/>

<!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
<!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
<xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
<xsl:call-template name="append_add-style"/>
</xsl:if>
<!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
<!-- <xsl:if test="*[not(local-name()='name')][1][node()[normalize-space() != ''][1][local-name() = 'add'] and node()[normalize-space() != ''][last()][local-name() = 'add']]"> -->
<xsl:if test="*[not(local-name()='name')][1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
<xsl:call-template name="append_add-style"/>
</xsl:if>

<!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
<xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
<xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
<xsl:with-param name="skip">false</xsl:with-param>
</xsl:apply-templates>
</xsl:if>
<!-- if note contains only one element and first and last childs are `add` ace-tag, then move start ace-tag before NOTE's name-->
<xsl:if test="count(*[not(local-name() = 'name')]) = 1 and *[not(local-name() = 'name')]/node()[last()][local-name() = 'add'][starts-with(text(), $ace_tag)]">
<xsl:apply-templates select="*[not(local-name() = 'name')]/node()[1][local-name() = 'add'][starts-with(text(), $ace_tag)]">
<xsl:with-param name="skip">false</xsl:with-param>
</xsl:apply-templates>
</xsl:if>

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

</fo:inline>
</fo:inline>

<xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
</fo:block>
<xsl:apply-templates select="node()[not(local-name() = 'name')]"/>
</fo:block>

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

</xsl:template>

Expand Down Expand Up @@ -12652,6 +12658,7 @@
</xsl:when>
<xsl:when test="contains(normalize-space($fo_element), 'block')">
<fo:block xsl:use-attribute-sets="example-name-style">

<xsl:apply-templates/>
</fo:block>
</xsl:when>
Expand All @@ -12667,6 +12674,7 @@

<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" match="*[local-name() = 'table']/*[local-name() = 'example']/*[local-name() = 'name']">
<fo:inline xsl:use-attribute-sets="example-name-style">

<xsl:apply-templates/>
</fo:inline>
</xsl:template>
Expand Down Expand Up @@ -13033,12 +13041,14 @@

<xsl:if test="parent::*[local-name() = 'term'] and not(preceding-sibling::*[local-name() = 'preferred'])"> <!-- if first preffered in term, then display term's name -->
<fo:block xsl:use-attribute-sets="term-name-style" role="SKIP">

<xsl:apply-templates select="ancestor::*[local-name() = 'term'][1]/*[local-name() = 'name']"/>
</fo:block>
</xsl:if>

<fo:block xsl:use-attribute-sets="preferred-term-style" role="SKIP">
<xsl:call-template name="setStyle_preferred"/>

<xsl:apply-templates/>
</fo:block>
</fo:block>
Expand Down Expand Up @@ -16148,9 +16158,10 @@
<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertBackgroundPageImage">
<xsl:param name="number">1</xsl:param>
<xsl:param name="name">coverpage-image</xsl:param>
<xsl:param name="suffix"/>
<xsl:variable name="num" select="number($number)"/>
<!-- background image -->
<fo:block-container absolute-position="fixed" left="0mm" top="0mm" font-size="0" id="__internal_layout__coverpage_{$name}_{$number}_{generate-id()}">
<fo:block-container absolute-position="fixed" left="0mm" top="0mm" font-size="0" id="__internal_layout__coverpage{$suffix}_{$name}_{$number}_{generate-id()}">
<fo:block>
<xsl:for-each select="/*[contains(local-name(), '-standard')]/*[local-name() = 'metanorma-extension']/*[local-name() = 'presentation-metadata'][*[local-name() = 'name'] = $name][1]/*[local-name() = 'value']/*[local-name() = 'image'][$num]">
<xsl:choose>
Expand Down Expand Up @@ -16216,16 +16227,29 @@

<!-- END: insert cover page image -->

<xsl:variable xmlns:redirect="http://xml.apache.org/xalan/redirect" name="regex_ja_spec">[\uFF08\uFF09]</xsl:variable>
<xsl:template xmlns:redirect="http://xml.apache.org/xalan/redirect" name="insertVerticalChar">
<xsl:param name="str"/>
<xsl:param name="writing-mode">lr-tb</xsl:param>
<xsl:param name="reference-orientation">90</xsl:param>
<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:inline-container text-align="center" alignment-baseline="central" width="1em" margin="0" padding="0" text-indent="0mm" last-line-end-indent="0mm" start-indent="0mm" end-indent="0mm">
<xsl:if test="normalize-space($writing-mode) != ''">
<xsl:attribute name="writing-mode"><xsl:value-of select="$writing-mode"/></xsl:attribute>
<xsl:attribute name="reference-orientation">90</xsl:attribute>
</xsl:if>
<xsl:variable name="char" select="substring($str,1,1)"/>
<xsl:if test="normalize-space(java:matches(java:java.lang.String.new($char), concat('(', $regex_ja_spec, '{1,})'))) = 'true'">
<xsl:attribute name="reference-orientation">0</xsl:attribute>
</xsl:if>
<fo:block-container width="1em">
<fo:block line-height="1em"><xsl:value-of select="substring($str,1,1)"/></fo:block>
<fo:block line-height="1em"><xsl:value-of select="$char"/></fo:block>
</fo:block-container>
</fo:inline-container>
<xsl:call-template name="insertVerticalChar">
<xsl:with-param name="str" select="substring($str, 2)"/>
<xsl:with-param name="writing-mode" select="$writing-mode"/>
<xsl:with-param name="reference-orientation" select="$reference-orientation"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
Expand Down

0 comments on commit a024b4d

Please sign in to comment.