我是XSLT的新用户,并一直在努力解决这个问题.
源XML:
<ABC X="" Y="" Z=""/>
Run Code Online (Sandbox Code Playgroud)
结果XML:
<CDE F="">
<ABC X="" Y="" Z"" G=""/>
</CDE>
Run Code Online (Sandbox Code Playgroud)
因此我需要
我能够单独完成这些,但我无法在一个XSLT中完成所有这些操作.
鉴于您的假设,您似乎需要一个最小模板:
<xsl:template match="ABC">
<CDE F="">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="G">hello</xsl:attribute>
</xsl:copy>
</CDE>
</xsltemplate>
Run Code Online (Sandbox Code Playgroud)
或者,如果您愿意:
<xsl:template match="/">
<CDE F="">
<xsl:apply-templates select="ABC"/>
</CDE>
</xsl:template>
<xsl:template match="ABC">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="G">hello</xsl:attribute>
</xsl:copy>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)