como extrair o elemento filho de tags aninhadas usando xslt

I have a scenario in xml :

    <body>
        <div><i>italic</i>
            <div id ="88">
                <div id="4545">
                    <h3>hey h3</h3>
                    <xyz>XYZ</xyz>
                </div>
            </div>
        </div>
        <div  id="123">
            <h1>Example</h1>
                <div  id="1234">
                    <h1>heading 1</h1>
                    <p>computer</p>
                    <div>
                        <i>italic 2</i>
                        <div>
                            <h3>heading 3</h3>
                        </div>
                    </div>    
                </div>
            <div  id="12345">
                <h1>heading 1</h1>
            </div>
        </div>
    </body>

I need to apply the rule that div converted to section and the div in which h1 value is Example ,delete that h1 tag and add attribute class=<value of that h1> to section tag .

expected output:
    <body>
        <section>
            <i>italic<i>
        </section>
        <section class="hey h3">

             <xyz>XYZ</xyz>
        </section>
        <section class="example">
            <title>heading 1</title>
            <p>computer</p>
        </section>
        <section>
            <i>italic 2</i>
        </section>
        <section>
        <h3>heading 3</h3>
        </section>
        <section >
            <title>heading 1</title>
        </section>
    </body>

my xslt:
<xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="div[h1='Example']">
        <xsl:apply-templates select="node()[not(self::h1)]"/>
    </xsl:template>

    <xsl:template match="div/h1">
        <title>
            <xsl:apply-templates/>
        </title>
    </xsl:template>

    <xsl:template match="div[h3='hey h3']">
        <xsl:apply-templates select="node()[not(self::h3)]"/>
    </xsl:template>

    <xsl:template match="div/h3">
        <title>
            <xsl:apply-templates/>
        </title>
    </xsl:template>

    <xsl:template match="div[not(h1='Example')]">
        <section>
            <xsl:if test="preceding-sibling::*[1][self::h1[.='Example']]">
                <xsl:attribute name="class">example</xsl:attribute>
            </xsl:if>
            <xsl:apply-templates select="node()[not(self::div)]"/>
        </section>
        <xsl:apply-templates select="node()[self::div]"/>
    </xsl:template>

    <xsl:template match="div[not(h3='hey h3')]">
        <section>
            <xsl:if test="preceding-sibling::*[1][self::h3[.='hey h3']]">
                <xsl:attribute name="class">richi rich</xsl:attribute>
            </xsl:if>
            <xsl:apply-templates select="node()[not(self::div)]"/>
        </section>
        <xsl:apply-templates select="node()[self::div]"/>
    </xsl:template>



actual output:
    <body>
        <section>
            <i>italic</i>
        </section>
        <section/>
        <section>
            <title>hey h3</title>
            <xyz>XYZ</xyz>
        </section>
        <section>
            <title>Example</title>
        </section>
        <section>
            <title>heading 1</title>
            <p>computer</p>
        </section>
        <section>
            <i>italic 2</i>
        </section>
        <section>
            <title>heading 3</title>
        </section>
        <section>
            <title>heading 1</title>
        </section>
    </body>

Na verdade, existem dois cenários: 1. a seção aninhada não deve estar presente e 2. a condição de que o que está tendo como "cabeçalho 1" exclua essa tag da div e adicione o atributo à div com o valor da tag.

Você poderia sugerir o que devo fazer aqui para obter a saída esperad

questionAnswers(1)

yourAnswerToTheQuestion