具有不同输出类别的参数作为标题部分作为主级别和子级别
我的输入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
作为h2
主级别部分的输出,将B-Head
作为h3
子级别部分的h2
,C-Head
的输出h4
的{{1}}子级别部分,h3
的{{1}}子级别部分,D-Head
子级别的h5
对于h4
,E-Head
与h6
与h5
处于同一级别,如下所示:
F-Head
请提出建议。
预先感谢