Hi I need to write an XSL that makes a transformation to an input xml such as: <tag1> <email> test@hotmail.com </email> </tag1> Such that I have an output: <!-- <properties> <email-property key="email" value="test@hotmail.com" /> </properties> --> I tried the following xsl: <xsl:comment> <xsl:element name="properties"> <xsl:element name=" email-property "> <xsl:attribute name="key">email</xsl:attribute> <xsl:attribute name="value"> <xsl:value-of select="//tag1/email"/ > </xsl:attribute> </xsl:element> </xsl:element> </xsl:comment> That gives the comment elements (<!-- -->) without the body. If I remove the <xsl:comment> I get the body without the comment elements in the output! Thanks in advance Mahmoud
khalil_mi@hotmail.com wrote: > Hi > > I need to write an XSL that makes a transformation to an input xml > such as: > <tag1> > <email> test@hotmail.com </email> > </tag1> > > Such that I have an output: > > <!-- > <properties> > <email-property key="email" value="test@hotmail.com" /> > </properties> > --> > > I tried the following xsl: > > <xsl:comment> > <xsl:element name="properties"> > <xsl:element name=" email-property "> > <xsl:attribute name="key">email</xsl:attribute> > <xsl:attribute name="value"> <xsl:value-of select="//tag1/email"/ >> </xsl:attribute> > </xsl:element> > </xsl:element> > </xsl:comment> See <URL:http://www.w3.org/TR/xslt#section-Creating-Comments>, the contents of xsl:comment should be text (nodes), not element nodes. So you need to escape the markup <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="tag1"> <xsl:copy> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="email"> <xsl:comment> <xsl:text><properties> <email-properties> key="email" value="</xsl:text> <xsl:value-of select="normalize-space(.)"/> <xsl:text>" /> </properties></xsl:text> </xsl:comment> </xsl:template> </xsl:stylesheet> -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/