使用docbook to dita将两个连续的元素转换为单个元素

The two consecutive elements converted into single element using docbook to dita

我的输入文档 xml 具有以下标签:

<section><title>Wing Landing Gear</title>
<section><para>Each wing landing gear has a leg assembly and
a four-wheel bogie beam. The WLG leg includes a Bogie Trim Actuator
(BTA) and an oleo-pneumatic shock absorber.</para>
</section></section>

我希望输出元素为

<section>
<title>Wing Landing Gear</title>
<p>Each wing landing gear has a leg assembly and
    a four-wheel bogie beam. The WLG leg includes a Bogie Trim Actuator
    (BTA) and an oleo-pneumatic shock absorber.</p>
</section>

如何使用 XSLT 将 <section><para> 更改为 <p> 元素。提前致谢

如果你使用

<xsl:template match="section/section[para]">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="para">
  <p>
    <xsl:apply-templates/>
  </p>
</xsl:template>

加上身份转换,然后嵌套在父 section 中的 section 中的 para 被转换为 p 替换内部 section .

所以完整的样式表是

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

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

<xsl:template match="section/section[para]">
  <xsl:apply-templates/>
</xsl:template>



<xsl:template match="para">
  <p>
    <xsl:apply-templates/>
  </p>
</xsl:template>
</xsl:transform>

转换输入

<section><title>Wing Landing Gear</title>
<section><para>Each wing landing gear has a leg assembly and
a four-wheel bogie beam. The WLG leg includes a Bogie Trim Actuator
(BTA) and an oleo-pneumatic shock absorber.</para>
</section></section>

进入输出

<section><title>Wing Landing Gear</title>
<p>Each wing landing gear has a leg assembly and
a four-wheel bogie beam. The WLG leg includes a Bogie Trim Actuator
(BTA) and an oleo-pneumatic shock absorber.</p>
</section>

在线 http://xsltransform.net/94AbWAY