我的输入docbook 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>
元素。提前致谢
答案 0 :(得分:1)
如果您使用
<xsl:template match="section/section[para]">
<xsl:apply-templates/>
</xsl:template>
和
<xsl:template match="para">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
加上身份转换,然后嵌套在父para
内的section
内的section
转换为替换内p
的{{1}}。< / 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>