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