Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - comments inside XSL [Thread Next] Re: comments inside XSLTo: NULL Date: 2/4/2008 5:32:00 PM
khalil_mi@h... wrote:
> Hi
>
> I need to write an XSL that makes a transformation to an input xml
> such as:
> <tag1>
> <email> test@h... </email>
> </tag1>
>
> Such that I have an output:
>
> <!--
> <properties>
> <email-property key="email" value="test@h..." />
> </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/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
