[xsl] selecting a section element which parent element doesn't have any element other than title element

Subject: [xsl] selecting a section element which parent element doesn't have any element other than title element
From: <srinivasan.p@xxxxxxxxxx>
Date: Thu, 6 Aug 2009 14:51:28 +0530
Hi Team,

I need the following output from the following input. In the following
Input1 example, "..." means any opening and closing tag can be present.

Input1:

<book>
<section>
<title>Section 1 title Present here</title>
...
<section>
<title>Section 2 title present here</title>
</section>
</section>
</book>

Output1:

<book>
<section role="H1">
<title>Section 1 title Present here</title>
...
<section role="H2">
<title>Section 2 title present here</title>
</section>
</section>
</book>


Input2:

<book>
<section>
<title>Section 1 title Present here</title>
<section>
<title>Section 2 title present here</title>
</section>
</section>
</book>

Output2:

<book>
<section role="H1">
<title>Section 1 title Present here</title>
<section role="H2H1">
<title>Section 2 title present here</title>
</section>
</section>
</book>           

I am using the same style sheet to achieve these two outputs. I dont have
any issues in achieving output1. The problem is in output2. I need to select
the "section" element which parent is "section" that doesn't contain any
tags other than "title" element.

Can you please anyone suggest to me how to achieve this in XSLT 2.0?

Thanks in advance.

Thanks
Srinivasan
 

Current Thread