Re: [xsl] xsl:variable containing xsl:element

Subject: Re: [xsl] xsl:variable containing xsl:element
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 29 Jan 2001 09:41:16 GMT
  The string contains HTML code 

If you think of HTML (or XML) markup being part of a string you'll
always get confused by XSLT. XSLT (unlike, say perl) does not work on
the string representation of an XML document, but on a tree

  // This doesn't work - displays the number BUT not bold
  <xsl:variable name="wholestring">This is my account <xsl:element
name="b">123.456</xsl:element> now closed</xsl:variable>
  <xsl:value-of select="string($wholestring)"/>

as mentioned before, both string() and value-of() are doing the same thing
here, giving the string value of the expreesion, which will throw away
any element nodes.

  The reason for the variable is that I want to pass it to another template
  <xsl:call-template name="getConfirmationPage">
    <xsl:with-param name="Header" select="Title/Text"/>
    <xsl:with-param name="Title" select="$wholestring"/>

That in itself isn't a reason, you could just use
<xsl:with-param name="Title"
 >This is my account <b>123.456</b> now closed</xsl:with-param>

you don't need a variable if it's only used there.

> The <xsl:copy-of select="$wholestring"/> throws the following error
It shouldn't. Are you sure you have that line somewhere in the scope of
the wholestring variable (that is, in teh same template)


This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit

 XSL-List info and archive:

Current Thread