xsl: для каждой группы требуется помощь

я прошел сквозьПримеры группировки XSLT а такжеИспользование для каждой группы для высокой производительности XSLT , У меня проблема с каждой группой.

My XML

<?xml version="1.0" encoding="UTF-8"?>
<body>
   <p name="h-title" other="main">Introduction</p>
   <p name="h1-title " other="other-h1">XSLT and XQuery</p>
   <p name="h2-title" other=" other-h2">XSLT</p>
   <p name="">
      <p1 name="bold"> XSLT is used to write stylesheets.</p1>
   </p>
   <p name="h2-title " name="other-h2">XQuery</p>
   <p name="">
      <p1 name="bold"> XQuery is used to query XML databases.</p1>
   </p>
   <p name="h3-title" name="other-h3">XQuery and stylesheets</p>
   <p name="">
      <p1 name="bold"> XQuery is used to query XML databases.</p1>
   </p>
   <p name="h1-title " other="other-h1">XSLT and XQuery</p>
   <p name="h2-title " other=" other-h2">XSLT</p>
</body>

& # X2003;

My Wanted Output

<?xml version="1.0" encoding="UTF-8"?>
<body>
   <p name="h-title " other="main">Introduction</p>
   <h1>
      <p name="h1-title " other="other-h1"> XSLT and XQuery </p>
      <h2>
         <p name="h2-title " other="other-h2">XSLT</p>
         <p name="">
            <p1 name="bold">XSLT is used to write stylesheets.
            </p1>
         </p>
      </h2>
      <h2>
         <p name="h2-title " other="other-h2"> XQuery is used to query XML databases    
         </p>
         <p name="">
            <p name="bold"> XQuery is used to query XML databases.</p>
         </p>
         <h3>
            <p name="h3-title " name="other-h3">XQuery and stylesheets</p>
            <p name="">
         <p1 name="bold"> XQuery is used to query XML databases.</p1>
           </p>
        </h3>
      </h2>
</h1>

<h1>
            <p name="h1-title " other="other-h1">XSLT and XQuery</p>
       <h2>   
            <p name="h2"-title other=" other-h2">XSLT</p>
       </h2>
</h1>
</body>

I tried with this. (not working)

<xsl:template match="body">


        <body>
            <xsl:for-each-group select="*" group-starting-with="@h1-title"      >
                <h1>
                    <xsl:for-each select="current-group()[self:: h1-title]">
                        <xsl:value-of select="."/> 
                        </xsl:for-each> 
                </h1>
            </xsl:for-each-group>

            <xsl:for-each-group select="*" group-starting-with="@h2-title"      >
                <h2>
                    <xsl:for-each select="current-group()[self::h2-title/@h2-title]">
                        <xsl:value-of select="."/>
                    </xsl:for-each> 
                </h2>
            </xsl:for-each-group>

            <xsl:for-each-group select="*" group-starting-with="@h3-title"      >
                <h3>
                    <xsl:for-each select="current-group()[self::h2-title/@h3-title]">
                        <xsl:value-of select="."/>
                    </xsl:for-each> 
                </h3>
            </xsl:for-each-group>

        </body>

  </xsl:template>

Кто-нибудь покажет мне правильный способ получить желаемый результат?

Ответы на вопрос(3)

Ваш ответ на вопрос