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

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -