@@ -19918,18 +19918,39 @@
19918
19918
<xsl:value-of select="$level_total - 2"/>
19919
19919
</xsl:when>
19920
19920
<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> -->
19922
19932
<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)"/>
19925
19946
</xsl:when>
19926
19947
<xsl:otherwise>
19927
19948
<xsl:value-of select="$level_total - 2"/>
19928
19949
</xsl:otherwise>
19929
19950
</xsl:choose>
19930
19951
</xsl:when>
19931
19952
<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)"/>
19933
19954
<xsl:choose>
19934
19955
<xsl:when test="string(number($upper_clause_depth)) != 'NaN'">
19935
19956
<xsl:value-of select="number($upper_clause_depth + 1)"/>
0 commit comments