0

メインおよびサブレベルとしての見出しセクションとして異なる出力クラスを持つパラ

私の入力xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "urn:pubid:doctypes:dita:topic" "topic.dtd">
<topic id="topic_1" xml:lang="en-US" outputclass="Sec-Chapter">
  <title>Sec-Chapter</title>
  <body>
    <p outputclass="Title">Heading Mappings</p>
    <p outputclass="A-Head">A-Head</p>
    <p>Some paragraph text</p>
    <p outputclass="B-Head">B-Head</p>
    <p>Some more paragraph text</p>
    <p outputclass="C-Head">C-Head</p>
    <p>Yet more paragraph text</p>
    <p outputclass="D-Head">D-Head</p>
    <p>Some creative paragraph text</p>
    <p outputclass="E-Head">E-Head</p>
    <p>Now, boing paragraph text</p>
    <p outputclass="F-Head">F-Head</p>
    <p>Finally, end</p>
  </body>
</topic>

見出しレベルの作成に使用した XSL テンプレート:

    <xsl:template match="//body">
    <xsl:copy>
      <xsl:for-each-group select="*" group-starting-with="//p[@outputclass = 'A-head']">
        <h2><xsl:value-of select="//p[@outputclass = 'A-head']"/></h2>
        <section>
<xsl:apply-templates select="."/>
          <xsl:for-each-group select="current-group() except ." group-starting-with="//p[@outputclass = 'B-head']">
            <h3><xsl:value-of select="//p[@outputclass = 'B-head']"/></h3>
            <section>
<xsl:apply-templates select="."/>
              <xsl:for-each-group select="current-group() except ." group-starting-with="//p[@outputclass = 'C-head']">
                <h4><xsl:value-of select="//p[@outputclass = 'C-head']"/></h4>
                <section>
<xsl:apply-templates select="."/>
                  <xsl:for-each-group select="current-group() except ." group-starting-with="//p[@outputclass = 'D-head']">
                    <h5><xsl:value-of select="//p[@outputclass = 'D-head']"/></h5>
                    <section>
<xsl:apply-templates select="."/>
                      <xsl:for-each-group select="current-group() except ." group-starting-with="//p[@outputclass = 'E-head']">
                        <h6><xsl:value-of select="//p[@outputclass = 'E-head']"/></h6>
                        <section>
<xsl:apply-templates select="."/>
                          <xsl:for-each-group select="current-group() except ." group-starting-with="//p[@outputclass = 'F-head']">
                            <h6><xsl:value-of select="//p[@outputclass = 'F-head']"/></h6>
                            <section>
                              <xsl:apply-templates select="."/>
                            </section>
                          </xsl:for-each-group>
                        </section>
                      </xsl:for-each-group>
                    </section>
                  </xsl:for-each-group>
                </section>
              </xsl:for-each-group>
            </section>
          </xsl:for-each-group>
        </section>
      </xsl:for-each-group>
    </xsl:copy>
  </xsl:template>

上記のテンプレートを次のように使用して出力を取得しています。

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en-us" lang="en">
    <head>
        <title>Heading</title>
    </head>
    <body>
        <h2>A-Head</h2>
        <section></section>
        <h2>A-Head</h2>
        <section>
           <h3>B-Head</h3>
           <section></section>
           <h3>B-Head</h3>
           <section>
              <h4>C-Head</h4>
              <section></section>
              <h4>C-Head</h4>
              <section>
                 <h5>D-Head</h5>
                 <section></section>
                 <h5>D-Head</h5>
                 <section>
                    <h6>E-Head</h6>
                    <section></section>
                    <h6>E-Head</h6>
                    <section>
                       <h6>F-Head</h6>
                       <section>
                          <p class="p">Now, boing paragraph text</p>

                       </section>
                       <h6>F-Head</h6>
                       <section>
                          <h6>F-Head</h6>

                       </section>
                    </section>
                 </section>
              </section>
           </section>
        </section>
     </body>
</html>

しかし、以下に示すように、メイン レベル セクション、のサブ レベル セクション、のサブレベル セクション、のサブ レベル セクション、のサブ レベル セクション、同じレベル セクションとしてA-head出力する必要があります。h2B-Headh3h2C-Headh4h3D-Headh5h4E-Headh6h5F-Headh6h6

<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en-us" lang="en">
    <head>
        <title>Heading</title>
    </head>
    <body class="Section" id="topic_1">
        <section>
            <p class="TitleTtl">Heading2</p>
            <h2>A-Head</h2>
            <section>
                <p class="p">Some paragraph text</p>
                <h3>B-Head</h3>
                <section>
                    <p class="p">Some more paragraph text</p>
                    <h4>C-Head</h4>
                    <section>
                        <p class="p">Yet more paragraph text</p>
                        <h5>D-Head</h5>
                        <section>
                            <p class="p">Some creative paragraph text</p>
                            <h6>E-Head</h6>
                            <section>
                                <p class="p">Now, boing paragraph text</p>
                            </section>
                            <h6>F-Head</h6>
                            <section>
                                <p class="p">Finally, end</p>
                            </section>
                        </section>
                    </section>
                </section>
            </section>
        </section>
    </body>
</html>

提案してください。

前もって感謝します

4

0 に答える 0