<!-- These xpath expressions are really hairy. The trick is to pick sections -->
<!-- that are not first children and are not the children of first children -->
- <xsl:variable name="prev"
- select="(preceding::book[1]
- |preceding::preface[1]
- |preceding::chapter[1]
- |preceding::appendix[1]
- |preceding::part[1]
- |preceding::reference[1]
- |preceding::refentry[1]
- |preceding::colophon[1]
+ <!-- Break these variables into pieces to work around
+ http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6063 -->
- |preceding::sect1[$chunk.section.depth > 0
+ <xsl:variable name="prev-v1"
+ select="(ancestor::sect1[$chunk.section.depth > 0
and preceding-sibling::sect1][1]
- |preceding::sect2[$chunk.section.depth > 1
+ |ancestor::sect2[$chunk.section.depth > 1
and preceding-sibling::sect2
and parent::sect1[preceding-sibling::sect1]][1]
- |preceding::sect3[$chunk.section.depth > 2
+ |ancestor::sect3[$chunk.section.depth > 2
and preceding-sibling::sect3
and parent::sect2[preceding-sibling::sect2]
and ancestor::sect1[preceding-sibling::sect1]][1]
- |preceding::sect4[$chunk.section.depth > 3
+ |ancestor::sect4[$chunk.section.depth > 3
and preceding-sibling::sect4
and parent::sect3[preceding-sibling::sect2]
and ancestor::sect2[preceding-sibling::sect2]
and ancestor::sect1[preceding-sibling::sect1]][1]
- |preceding::sect5[$chunk.section.depth > 4
+ |ancestor::sect5[$chunk.section.depth > 4
and preceding-sibling::sect5
and parent::sect4[preceding-sibling::sect4]
and ancestor::sect3[preceding-sibling::sect3]
and ancestor::sect2[preceding-sibling::sect2]
and ancestor::sect1[preceding-sibling::sect1]][1]
- |preceding::section[$chunk.section.depth > count(ancestor::section)
- and preceding-sibling::section
- and not(ancestor::section[not(preceding-sibling::section)])][1]
-
- |preceding::article[1]
- |preceding::bibliography[1]
- |preceding::glossary[1]
- |preceding::index[1]
- |preceding::setindex[1]
- |ancestor::set
- |ancestor::book[1]
- |ancestor::preface[1]
- |ancestor::chapter[1]
- |ancestor::appendix[1]
+ |ancestor::section[$chunk.section.depth > count(ancestor::section)
+ and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
- |ancestor::sect1[$chunk.section.depth > 0
+ <xsl:variable name="prev-v2"
+ select="(preceding::sect1[$chunk.section.depth > 0
and preceding-sibling::sect1][1]
- |ancestor::sect2[$chunk.section.depth > 1
+ |preceding::sect2[$chunk.section.depth > 1
and preceding-sibling::sect2
and parent::sect1[preceding-sibling::sect1]][1]
- |ancestor::sect3[$chunk.section.depth > 2
+ |preceding::sect3[$chunk.section.depth > 2
and preceding-sibling::sect3
and parent::sect2[preceding-sibling::sect2]
and ancestor::sect1[preceding-sibling::sect1]][1]
- |ancestor::sect4[$chunk.section.depth > 3
+ |preceding::sect4[$chunk.section.depth > 3
and preceding-sibling::sect4
and parent::sect3[preceding-sibling::sect2]
and ancestor::sect2[preceding-sibling::sect2]
and ancestor::sect1[preceding-sibling::sect1]][1]
- |ancestor::sect5[$chunk.section.depth > 4
+ |preceding::sect5[$chunk.section.depth > 4
and preceding-sibling::sect5
and parent::sect4[preceding-sibling::sect4]
and ancestor::sect3[preceding-sibling::sect3]
and ancestor::sect2[preceding-sibling::sect2]
and ancestor::sect1[preceding-sibling::sect1]][1]
- |ancestor::section[$chunk.section.depth > count(ancestor::section)
- and not(ancestor::section[not(preceding-sibling::section)])][1]
+ |preceding::section[$chunk.section.depth > count(ancestor::section)
+ and preceding-sibling::section
+ and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
+ <xsl:variable name="prev"
+ select="(preceding::book[1]
+ |preceding::preface[1]
+ |preceding::chapter[1]
+ |preceding::appendix[1]
+ |preceding::part[1]
+ |preceding::reference[1]
+ |preceding::refentry[1]
+ |preceding::colophon[1]
+ |preceding::article[1]
+ |preceding::bibliography[1]
+ |preceding::glossary[1]
+ |preceding::index[1]
+ |preceding::setindex[1]
+ |ancestor::set
+ |ancestor::book[1]
+ |ancestor::preface[1]
+ |ancestor::chapter[1]
+ |ancestor::appendix[1]
|ancestor::part[1]
|ancestor::reference[1]
- |ancestor::article[1])[last()]"/>
+ |ancestor::article[1])[last()]
+ |$prev-v1|$prev-v2"/>
- <xsl:variable name="next"
- select="(following::book[1]
- |following::preface[1]
- |following::chapter[1]
- |following::appendix[1]
- |following::part[1]
- |following::reference[1]
- |following::refentry[1]
- |following::colophon[1]
-
- |following::sect1[$chunk.section.depth > 0
+ <xsl:variable name="next-v1"
+ select="(following::sect1[$chunk.section.depth > 0
and preceding-sibling::sect1][1]
|following::sect2[$chunk.section.depth > 1
|following::section[$chunk.section.depth > count(ancestor::section)
and preceding-sibling::section
- and not(ancestor::section[not(preceding-sibling::section)])][1]
+ and not(ancestor::section[not(preceding-sibling::section)])][1])[1]"/>
- |following::bibliography[1]
- |following::glossary[1]
- |following::index[1]
- |following::article[1]
- |following::setindex[1]
- |descendant::book[1]
- |descendant::preface[1]
- |descendant::chapter[1]
- |descendant::appendix[1]
- |descendant::article[1]
- |descendant::bibliography[1]
- |descendant::glossary[1]
- |descendant::index[1]
- |descendant::colophon[1]
- |descendant::setindex[1]
- |descendant::part[1]
- |descendant::reference[1]
- |descendant::refentry[1]
-
- |descendant::sect1[$chunk.section.depth > 0
+ <xsl:variable name="next-v2"
+ select="(descendant::sect1[$chunk.section.depth > 0
and preceding-sibling::sect1][1]
|descendant::sect2[$chunk.section.depth > 1
|descendant::section[$chunk.section.depth > count(ancestor::section)
and preceding-sibling::section
- and not(ancestor::section[not(preceding-sibling::section)])])[1]
-"/>
+ and not(ancestor::section[not(preceding-sibling::section)])])[1]"/>
+
+ <xsl:variable name="next"
+ select="(following::book[1]
+ |following::preface[1]
+ |following::chapter[1]
+ |following::appendix[1]
+ |following::part[1]
+ |following::reference[1]
+ |following::refentry[1]
+ |following::colophon[1]
+ |following::bibliography[1]
+ |following::glossary[1]
+ |following::index[1]
+ |following::article[1]
+ |following::setindex[1]
+ |descendant::book[1]
+ |descendant::preface[1]
+ |descendant::chapter[1]
+ |descendant::appendix[1]
+ |descendant::article[1]
+ |descendant::bibliography[1]
+ |descendant::glossary[1]
+ |descendant::index[1]
+ |descendant::colophon[1]
+ |descendant::setindex[1]
+ |descendant::part[1]
+ |descendant::reference[1]
+ |descendant::refentry[1])[1]
+ |$next-v1|$next-v2"/>
<xsl:call-template name="process-chunk">
<xsl:with-param name="prev" select="$prev"/>
</xsl:template>
<xsl:template name="chunk-all-sections">
+ <xsl:variable name="prev-v1"
+ select="(preceding::sect1[$chunk.section.depth > 0][1]
+ |preceding::sect2[$chunk.section.depth > 1][1]
+ |preceding::sect3[$chunk.section.depth > 2][1]
+ |preceding::sect4[$chunk.section.depth > 3][1]
+ |preceding::sect5[$chunk.section.depth > 4][1]
+ |preceding::section[$chunk.section.depth > count(ancestor::section)][1])[last()]"/>
+
+ <xsl:variable name="prev-v2"
+ select="(ancestor::sect1[$chunk.section.depth > 0][1]
+ |ancestor::sect2[$chunk.section.depth > 1][1]
+ |ancestor::sect3[$chunk.section.depth > 2][1]
+ |ancestor::sect4[$chunk.section.depth > 3][1]
+ |ancestor::sect5[$chunk.section.depth > 4][1]
+ |ancestor::section[$chunk.section.depth > count(ancestor::section)][1])[last()]"/>
+
<xsl:variable name="prev"
select="(preceding::book[1]
|preceding::preface[1]
|preceding::reference[1]
|preceding::refentry[1]
|preceding::colophon[1]
-
- |preceding::sect1[$chunk.section.depth > 0][1]
- |preceding::sect2[$chunk.section.depth > 1][1]
- |preceding::sect3[$chunk.section.depth > 2][1]
- |preceding::sect4[$chunk.section.depth > 3][1]
- |preceding::sect5[$chunk.section.depth > 4][1]
- |preceding::section[$chunk.section.depth > count(ancestor::section)][1]
-
|preceding::article[1]
|preceding::bibliography[1]
|preceding::glossary[1]
|ancestor::appendix[1]
|ancestor::part[1]
|ancestor::reference[1]
- |ancestor::article[1]
- |ancestor::sect1[$chunk.section.depth > 0][1]
- |ancestor::sect2[$chunk.section.depth > 1][1]
- |ancestor::sect3[$chunk.section.depth > 2][1]
- |ancestor::sect4[$chunk.section.depth > 3][1]
- |ancestor::sect5[$chunk.section.depth > 4][1]
- |ancestor::section[$chunk.section.depth > count(ancestor::section)][1])[last()]"/>
+ |ancestor::article[1])[last()]
+ |$prev-v1|$prev-v2"/>
+
+ <xsl:variable name="next-v1"
+ select="(following::sect1[$chunk.section.depth > 0][1]
+ |following::sect2[$chunk.section.depth > 1][1]
+ |following::sect3[$chunk.section.depth > 2][1]
+ |following::sect4[$chunk.section.depth > 3][1]
+ |following::sect5[$chunk.section.depth > 4][1]
+ |following::section[$chunk.section.depth > count(ancestor::section)][1])[1]"/>
+
+ <xsl:variable name="next-v2"
+ select="(descendant::sect1[$chunk.section.depth > 0][1]
+ |descendant::sect2[$chunk.section.depth > 1][1]
+ |descendant::sect3[$chunk.section.depth > 2][1]
+ |descendant::sect4[$chunk.section.depth > 3][1]
+ |descendant::sect5[$chunk.section.depth > 4][1]
+ |descendant::section[$chunk.section.depth
+ > count(ancestor::section)][1])[1]"/>
<xsl:variable name="next"
select="(following::book[1]
|following::reference[1]
|following::refentry[1]
|following::colophon[1]
-
- |following::sect1[$chunk.section.depth > 0][1]
- |following::sect2[$chunk.section.depth > 1][1]
- |following::sect3[$chunk.section.depth > 2][1]
- |following::sect4[$chunk.section.depth > 3][1]
- |following::sect5[$chunk.section.depth > 4][1]
- |following::section[$chunk.section.depth > count(ancestor::section)][1]
-
|following::bibliography[1]
|following::glossary[1]
|following::index[1]
|descendant::setindex[1]
|descendant::part[1]
|descendant::reference[1]
- |descendant::refentry[1]
-
- |descendant::sect1[$chunk.section.depth > 0][1]
- |descendant::sect2[$chunk.section.depth > 1][1]
- |descendant::sect3[$chunk.section.depth > 2][1]
- |descendant::sect4[$chunk.section.depth > 3][1]
- |descendant::sect5[$chunk.section.depth > 4][1]
- |descendant::section[$chunk.section.depth
- > count(ancestor::section)][1])[1]"/>
+ |descendant::refentry[1])[1]
+ |$next-v1|$next-v2"/>
<xsl:call-template name="process-chunk">
<xsl:with-param name="prev" select="$prev"/>