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/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>


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