Re: [xsl] Creating and passing XML String to xsl:call-template.

Subject: Re: [xsl] Creating and passing XML String to xsl:call-template.
From: Oleg Tkachenko <olegt@xxxxxxxxxxxxx>
Date: Sun, 27 Jan 2002 11:46:11 +0200
Avula, Raj wrote:

	I want to create a XML String in a template and pass it as a
paramter to xsl:call-template.
There I want to parse that XML String and get the values. Reasons why I want
to do this
is to reduce number of parameters passed to xsl:call-template and other is
to reduce the size of the calling template.

eg:

First template:
	<xsl:template name="FirstTemplate">
		<xsl:variable name="XMLString">

First of all it's not really string but tree (rtf aka result tree fragment, see http://www.w3.org/TR/xslt.html#section-Result-Tree-Fragments).


> <customer>

		<xsl:if test="cust_name1">
			<name>
			<xsl:value-of select="cust_name1" />
			</name>
		<xsl:if>
		<xsl:if test="cust_name2">
			<name>
			<xsl:value-of select="cust_name2" />
			</name>
		<xsl:if>

You forgot </customer>



</xsl:variable>

		<xsl:call-template name="SecondTemplate">
			<xsl:with-param name="xmlstr" select="$XMLString" />
		</xsl:call-template>
	</xsl:template>


<xsl:template name="SecondTemplate> <xsl:param name="xmlstr" />

here something like for each customer/name
-- get the name and print by formattig.

for-each needs node-set, but you have rtf, so the only way is to convert it to node-set by xxx:node-set(rtf) ext function, where xxx - is your processor extension (see your xslt processor's doc).
<xsl:for-each select="xxx:node-set($xmlstr)/customer/name">
....



</xsl:template>

	Can I do something like this. If not Can any body suggest an
alternative of doing this.

I think it's the best way.



-- Oleg Tkachenko Multiconn International, Israel


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread