XSLTのグループ化の例と、高性能XSLTのためのfor-each-groupの使用について説明しました。for-each-groupに問題があります。
私の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>
</ p>
私の欲しい出力
<?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>
これでやってみました。(動作していません)
<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>
誰かが私の望みの結果を得るための正しい方法を教えてくれますか?