Skip to content

Commit 333c9b9

Browse files
Merge pull request #751 from metanorma/pdf_ua1
common.xsl updated for H levels, metanorma/mn2pdf#289
2 parents bf2f0bc + 245389d commit 333c9b9

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

xslt_src/common.xsl

+25-4
Original file line numberDiff line numberDiff line change
@@ -19918,18 +19918,39 @@
1991819918
<xsl:value-of select="$level_total - 2"/>
1991919919
</xsl:when>
1992019920
<xsl:when test="ancestor::*[local-name() = 'sections'] and self::*[local-name() = 'title']">
19921-
<xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/>
19921+
<!-- determine 'depth' depends on upper clause with title/@depth -->
19922+
<!-- <xsl:message>title=<xsl:value-of select="."/></xsl:message> -->
19923+
<xsl:variable name="clause_with_depth_depth" select="ancestor::*[local-name() = 'clause'][*[local-name() = 'title']/@depth][1]/*[local-name() = 'title']/@depth"/>
19924+
<!-- <xsl:message>clause_with_depth_depth=<xsl:value-of select="$clause_with_depth_depth"/></xsl:message> -->
19925+
<xsl:variable name="clause_with_depth_level" select="count(ancestor::*[local-name() = 'clause'][*[local-name() = 'title']/@depth][1]/ancestor::*)"/>
19926+
<!-- <xsl:message>clause_with_depth_level=<xsl:value-of select="$clause_with_depth_level"/></xsl:message> -->
19927+
<xsl:variable name="curr_level" select="count(ancestor::*) - 1"/>
19928+
<!-- <xsl:message>curr_level=<xsl:value-of select="$curr_level"/></xsl:message> -->
19929+
<!-- <xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][2]/*[local-name() = 'title']/@depth)"/> -->
19930+
<xsl:variable name="curr_clause_depth" select="number($clause_with_depth_depth) + (number($curr_level) - number($clause_with_depth_level)) "/>
19931+
<!-- <xsl:message>curr_clause_depth=<xsl:value-of select="$curr_clause_depth"/></xsl:message> -->
1992219932
<xsl:choose>
19923-
<xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
19924-
<xsl:value-of select="number($upper_clause_depth + 1)"/>
19933+
<xsl:when test="string(number($curr_clause_depth)) != 'NaN'">
19934+
<xsl:value-of select="number($curr_clause_depth)"/>
19935+
</xsl:when>
19936+
<xsl:otherwise>
19937+
<xsl:value-of select="$level_total - 2"/>
19938+
</xsl:otherwise>
19939+
</xsl:choose>
19940+
</xsl:when>
19941+
<xsl:when test="ancestor::*[local-name() = 'sections'] and self::*[local-name() = 'name'] and parent::*[local-name() = 'term']">
19942+
<xsl:variable name="upper_terms_depth" select="normalize-space(ancestor::*[local-name() = 'terms'][1]/*[local-name() = 'title']/@depth)"/>
19943+
<xsl:choose>
19944+
<xsl:when test="string(number($upper_terms_depth)) != 'NaN'">
19945+
<xsl:value-of select="number($upper_terms_depth + 1)"/>
1992519946
</xsl:when>
1992619947
<xsl:otherwise>
1992719948
<xsl:value-of select="$level_total - 2"/>
1992819949
</xsl:otherwise>
1992919950
</xsl:choose>
1993019951
</xsl:when>
1993119952
<xsl:when test="ancestor::*[local-name() = 'sections']">
19932-
<xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause'][1]/*[local-name() = 'title']/@depth)"/>
19953+
<xsl:variable name="upper_clause_depth" select="normalize-space(ancestor::*[local-name() = 'clause' or local-name() = 'terms'][1]/*[local-name() = 'title']/@depth)"/>
1993319954
<xsl:choose>
1993419955
<xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
1993519956
<xsl:value-of select="number($upper_clause_depth + 1)"/>

0 commit comments

Comments
 (0)