【发布时间】:2013-07-29 09:39:13
【问题描述】:
我想将 mattext 节点重命名为文本,但保留其属性和所有子节点/属性
输入 XML
<material>
<mattext fontface="Tahoma">
<p style="white-space: pre-wrap">
<font size="11">Why are the astronauts in the video wearing special suits? (Select two)</font>
</p>
</mattext>
</material>
输出
<material>
<text fontface="Tahoma">
<p style="white-space: pre-wrap">
<font size="11">Why are the astronauts in the video wearing special suits? (Select two)</font>
</p>
</text>
</material>
我使用过以下xsl:
<xsl:template name="content">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<!-- Build stem -->
<xsl:template match="mattext">
<text>
<!-- Option text -->
<xsl:call-template name="content"/>
</text>
</xsl:template>
但它不保留初始的fontface属性,并且似乎输出剥离标签的纯文本
【问题讨论】: