Re: [xsl] Passing variables into XSLT via parameters ... can't get it to work

Subject: Re: [xsl] Passing variables into XSLT via parameters ... can't get it to work
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 23 May 2006 12:11:51 +0100
    <xsl:value-of select="exslt:node-set($parameters)//*[name() = ....


value-of produces the string value of whatever is selected, so there you
are selecting a node set but coercing it to a string by taking all its
character data and losing the element structure.


You probably want xsl:copy-of

You may or may not need exslt:node-set() it depends on how $parameters
is defined, which you don't show. Since it's not defined in this
template it must be a global parameter or variable in which case
it may well already be a node set.


> [As an aside, I couldn't get the substring-before and -after to work 
> directly in the XPath expression. Am I missing something, or do they 
> need to be assigned to variables like that to be used?]

You can always replace a variable by its value in XPath, no expression
requires variables.

 > I know the string is making it in because 
> <xsl:value-of select="$parameters" /> prints out the escaped string. 

by escape do you mean &lt; etc? value-of does not do any escaping in
that sense. If value-of is producing that then $parameters does not
contain an XML tree but rather a string containing XML markup in which
case you need to parse it with an XML parser first. Some processors
provide extension functions giving access to an XML parser or you could
parse it outside xslt and pass in the parsed document node as a
parameter. (I don't know the details of php/libxslt here)

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread