![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Assigning xml string using xsl:copy-of to xml:variable [Thread Next] Re: Assigning xml string using xsl:copy-of to xml:variableTo: NULL Date: 7/6/2004 10:25:00 AM "Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message news:<eJdYHmzYEHA.644@t...>...
> ms wrote:
>
> > I need to retrieve a large portion of the input xml, character-escape
> > the " and ', and pass the string as an argument to a Javascript
> > function in the xsl.
> > I can't see any way of assigning the xml fragment (retrieved using
> > xsl:copy-of) into an xsl:variable (or sending as an xsl:parameter to a
> > template).
>
> <xsl:variable name="var" select="the-expression-you-would-use-in-copy-of"/>
>
> But it's not really clear what you mean. Provide some samples please.
The best i've managed so far is:
<xsl:template match="/">
<xsl:call-template name="copy" >
<xsl:with-param name="root" select="/root/a" />
</xsl:call-template>
</xsl:template>
<xsl:template name="copy">
<xsl:param name="root"/>
<xsl:apply-templates select="$root" />
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match = "@*">
<xsl:variable name="str" select="."/>
<xsl:attribute name="{name()}" >
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
This outputs the xml of node "a" and its attributes and children as a
string, but I still can't assign this string to a variable for
character replacement.
For example:
<xsl:variable name="var1">
<xsl:call-template name="copy" >
<xsl:with-param name="root" select="/root/a" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$var1"/>
Outputs "John'sDave's"
=====================================================================
The source xml is:
<root>
<a att1="dkjf's">
<b att2="dkf">John's</b>
<b att2="dkf">Dave's</b>
</a>
</root>
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
