Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Putting xml in attribute >Thread Next - Re: Putting xml in attribute Re: Putting xml in attributeTo: NULL Date: 5/4/2006 7:39:00 PM Thanks Martin, Just what I needed. We are using a 3rd party component and we have to construct the xml in a certain format. Once again, thanks. Sham. "Martin Honnen" <mahotrash@y...> wrote in message news:OGnDTX5bGHA.3388@T...... > > > sham wrote: > > >> This component handles the escaping. But I need to create an XSLT script >> that will give us the row with the XML apart of the attribute. Can this >> be done? > > I am not sure I understand what you want to achieve. If you want XML to be > a part of an attribute value then you need to escape the XML e.g. like > this stylesheet does > > <xsl:stylesheet > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > > <xsl:template match="dataset"> > <Row> > <xsl:attribute name="firstattribute"><xsl:apply-templates select="." > mode="serialize" /></xsl:attribute> > </Row> > </xsl:template> > > <xsl:template match="*" mode="serialize"> > <xsl:text><</xsl:text> > <xsl:value-of select="name()" /> > <xsl:apply-templates select="@*" mode="serialize" /> > <xsl:text>></xsl:text> > <xsl:apply-templates mode="serialize" /> > <xsl:text></</xsl:text> > <xsl:value-of select="name()" /> > <xsl:text>></xsl:text> > </xsl:template> > > <xsl:template match="@*" mode="serialize"> > <xsl:text> </xsl:text> > <xsl:value-of select="concat(name(), '="', ., '"')" /> > </xsl:template> > > </xsl:stylesheet> > > Applied to your XML sample the result is then > > <Row firstattribute="<dataset id="dataset_1" > name="Client - number unplanned"><data > id="dataset_1_1" value="1"></data><data > id="dataset_1_2" value="2"></data><data > id="dataset_1_3" value="3"></data><data > id="dataset_1_4" value="4"></data><data > id="dataset_1_5" value="5"></data><data > id="dataset_1_6" value="6"></data><data > id="dataset_1_7" value="7"></data><data > id="dataset_1_8" value="8"></data><data > id="dataset_1_9" value="9"></data><data > id="dataset_1_10" value="10"></data><data > id="dataset_1_11" value="11"></data><data > id="dataset_1_12" > value="12"></data></dataset>"></Row> > > -- > > Martin Honnen --- MVP XML > http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
