Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Putting xml in attribute

From: "sham" <shamresh@------------------.--->
To: 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>&lt;</xsl:text>
>   <xsl:value-of select="name()" />
>   <xsl:apply-templates select="@*" mode="serialize" />
>   <xsl:text>&gt;</xsl:text>
>   <xsl:apply-templates mode="serialize" />
>   <xsl:text>&lt;/</xsl:text>
>   <xsl:value-of select="name()" />
>   <xsl:text>&gt;</xsl:text>
> </xsl:template>
>
> <xsl:template match="@*" mode="serialize">
>   <xsl:text> </xsl:text>
>   <xsl:value-of select="concat(name(), '=&quot;', ., '&quot;')" />
> </xsl:template>
>
> </xsl:stylesheet>
>
> Applied to your XML sample the result is then
>
> <Row firstattribute="&lt;dataset id=&quot;dataset_1&quot; 
> name=&quot;Client - number unplanned&quot;&gt;&lt;data 
> id=&quot;dataset_1_1&quot; value=&quot;1&quot;&gt;&lt;/data&gt;&lt;data 
> id=&quot;dataset_1_2&quot; value=&quot;2&quot;&gt;&lt;/data&gt;&lt;data 
> id=&quot;dataset_1_3&quot; value=&quot;3&quot;&gt;&lt;/data&gt;&lt;data 
> id=&quot;dataset_1_4&quot; value=&quot;4&quot;&gt;&lt;/data&gt;&lt;data 
> id=&quot;dataset_1_5&quot; value=&quot;5&quot;&gt;&lt;/data&gt;&lt;data 
> id=&quot;dataset_1_6&quot; value=&quot;6&quot;&gt;&lt;/data&gt;&lt;data 
> id=&quot;dataset_1_7&quot; value=&quot;7&quot;&gt;&lt;/data&gt;&lt;data 
> id=&quot;dataset_1_8&quot; value=&quot;8&quot;&gt;&lt;/data&gt;&lt;data 
> id=&quot;dataset_1_9&quot; value=&quot;9&quot;&gt;&lt;/data&gt;&lt;data 
> id=&quot;dataset_1_10&quot; value=&quot;10&quot;&gt;&lt;/data&gt;&lt;data 
> id=&quot;dataset_1_11&quot; value=&quot;11&quot;&gt;&lt;/data&gt;&lt;data 
> id=&quot;dataset_1_12&quot; 
> value=&quot;12&quot;&gt;&lt;/data&gt;&lt;/dataset&gt;"></Row>
>
> -- 
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/ 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent