Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Assigning xml string using xsl:copy-of to xml:variable

From: msmsmsms782@-------.--- (--)
To: NULL
Date: 7/8/2004 9:20:00 AM
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message news:<e0uitNAZEHA.3304@T...>...
> ms wrote:
> 
> > I need, within the xsl, to send a fragment of the above xml as an
> > argument to a Javascript funtion:
> > 
> > func('<a att1="dkjf"><b att2="dkf">John's</b><b
> > att2="dkf">Dave's</b></a>');
> > 
> > The xml string first needs to have the " and ' output escaped.  This
> > will need to be done using xsl so that I have the following instead:
> > 
> > func('<a att1=\"dkjf\"><b att2=\"dkf\">John\'s</b><b
> > att2=\"dkf\">Dave\'s</b></a>');
> > 
> > The problem I have is how to retrieve the full xml (elements included)
> > from the source xml.
> 
> I see. The problem is that you need to serialize XML fragment to string. 
> There is no such function in XSLT so you can either have extension 
> function or implement serializing via templates:
> 
>    <xsl:template match="*" mode="serialize">
>      <xsl:value-of select="concat('&lt;', name())"/>
>      <xsl:for-each select="@*">
>        <xsl:value-of select="concat(' ', name(), '=\&quot;', ., 
> '\&quot;')"/>
>      </xsl:for-each>
>      <xsl:text>></xsl:text>
>      <xsl:apply-templates mode="serialize"/>
>      <xsl:value-of select="concat('&lt;/', name(), '>')"/>
>    </xsl:template>
>    <xsl:template match="text()" mode="serialize">
>      <!-- Implement replace in text here -->
>      <xsl:value-of select="."/>
>    </xsl:template>
> 
> Alternatively consider using XML islands to avoid this stuff.

Thanks very much


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