2
我想重命名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属性,似乎输出明文剥离标签
完美的作品!谢谢 – Rob