xml - XSL to Copy root node into + add attributes -
i new user xslt , have been struggling problem.
source xml:
<abc x="" y="" z=""/>
result xml:
<cde f=""> <abc x="" y="" z"" g=""/> </cde>
thus need to
- create root node attribute default value in result xml.
- copy node ( source has 1 node only) source result xml.
- add additional attributes node copied source xml.
i able these separately not able of these in 1 xslt.
given assumptions, seems need 1 minimal template:
<xsl:template match="abc"> <cde f=""> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:attribute name="g">hello</xsl:attribute> </xsl:copy> </cde> </xsltemplate>
or, if prefer:
<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>
Comments
Post a Comment