XSL:删除xml标记但保留其内容

我最近将几个我的.xml文件从docbook更改为dita。转换没问题,但有一些不需要的工件。我难以理解的是.dita没有从docbook中识别出
<para>
标签,而是将其替换为
<p>
。您认为这样会很好,但是这会导致XML在下一行显示项目和有序列表,即: 1  第一项 2  第二项 代替: 1项一 2项目二 所以我该如何改变这个:
<section>
<title>Cool Stuff</title>
<orderedlist>
  <listitem>
    <para>ItemOne</para>
  </listitem>

  <listitem>
    <para>ItemTwo</para>
  </listitem>
</orderedlist>
对此:
<section>
<title>Cool Stuff</title>
<orderedlist>
  <listitem>
    ItemOne
  </listitem>

  <listitem>
    ItemTwo
  </listitem>
</orderedlist>
对不起,我应该更清楚这个问题。我需要从不同深度的doument中删除所有标签,但始终遵循(本地)树listitem / para。我对此有点新意,但是我可以通过将其添加到我的docbook2dita转换中来做错。可以在那个地方吗?     
已邀请:
我会使用这个样式表:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match ="listitem/para">
        <xsl:apply-templates/>
    </xsl:template>
</xsl:stylesheet>
注意:覆盖身份规则。绕过
listitem/para
(这保留了混合内容)     
您可以使用过滤掉
<para>
节点的XSLT处理dita文件:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes"/>

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

  <!-- replace para nodes within an orderedlist with their content -->     
  <xsl:template match ="orderedlist/listitem/para">
    <xsl:value-of select="."/>
  </xsl:template>

</xsl:stylesheet>
    
我有一个类似的问题,但我使用的QtDom并不总是100%像XSLT 2.x规格。 (我想在某个时候切换到Apache库......) 我想在我的代码中用相应的类更改等效的“listitem”:
<xsl:for-each select="/orderedlist/lisitem">
  <div class="listitem">
    <xsl:apply-templates select="node()"/>
  </div>
</xsl:for-each>
这将删除listitem并将其替换为&lt; div class =“listitem”&gt; 然后,在我的情况下,你在&lt; para&gt;中所拥有的模板可以包含标签,因此我无法使用另外两个将所有内容转换为纯文本的示例。相反,我使用了:
<xsl:template match ="para">
  <xsl:copy-of select="node()"/>
</xsl:template>
这删除了“para”标签,但保留所有孩子的原样。所以段落可以包括格式化,并且它在XSLT处理中保留。     

要回复问题请先登录注册