I have this structure in XML:
<report>
<text>
<chapter>1</chapter>
<chapter>2
<section>2.1</section>
</chapter>
<chapter>3</chapter>
</text>
</report>
In my DTD, I have:
<!ELEMENT text (#PCDATA | chapter |section)*>
Because of this, in my XSL, i want the garantee that I don't have a chapter
and a section
in the same level, before doing the transformation. So, i can't have this
<report>
<text>
<chapter>1</chapter>
<chapter>2
<section>2.1</section>
</chapter>
<section>3</section>
</text>
</report>
My XSL
<xsl:template match="chapter">
<div class="chapter">
<h2>
<xsl:apply-templates select="chapter-title"/>
</h2>
<hr/>
<xsl:apply-templates select="text() | section "/>
</div>
</xsl:template>
<xsl:template match="section">
<div class="section">
<h3>
<xsl:apply-templates select="section-title"/>
</h3>
<xsl:apply-templates select="text()"/>
</div>
</xsl:template>
How can I check if a section and a chapter are at the same level, in XSL? Thanks.