【问题标题】:XSLT - remove duplicate parent elementXSLT - 删除重复的父元素
【发布时间】:2017-10-23 12:04:49
【问题描述】:

我的输入 XML 如下所示,

<part type="content">
<part type="content">
<title>PART IFundamentals and Basics</title>
................
</part>
<part type="content">
<title>PART IISkin and Soft Tissue</title>
................
</part>
<part type="content">
<title>PART IIIHead and Neck<target id="p003"/><target id="page215"/></title>
................
</part>
</part>

输出应该改变为,

<part type="content">
<title>PART IFundamentals and Basics</title>
................
</part>
<part type="content">
<title>PART IISkin and Soft Tissue</title>
................
</part>
<part type="content">
<title>PART IIIHead and Neck<target id="p003"/><target id="page215"/>    </title>
................
</part>

我的 XSLT 是这样的,

<xsl:template match="part[@type='content']/part[@type='content']">        
<xsl:apply-templates />        
</xsl:template>  

在使用上述 xslt 时,“part”元素正在从“Part II”父元素中移除。请您指导我们。

【问题讨论】:

    标签: xml xslt


    【解决方案1】:

    &lt;xsl:template match="part[@type='content']/part[@type='content']"&gt; 更改为 &lt;xsl:template match="part[@type='content'][part[@type='content']]"&gt; 并确保身份转换或您的其他模板复制其余节点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多