February 28th, 2002, 06:02 PM
<br/> tag in XSL variable
I'm trying to get an HTML <br> tag, embedded into an XSL variable and I'm not sure that it's possible.
In short, I have stylesheet1.xsl which performs a specific function. stylesheet1.xsl includes Language.xsl. Within Language.xsl are all of the text strings that stylesheet1 uses (the reason for this is that there are 45+ stylesheets, however only one needs to be modified to change the language of the entire package.)
Within Language.xsl, I would like to define a variable lit_QuantityReceived. Such as:
<xsl:variable name="lit_QuantityReceived">Quantity Received</xsl:variable>
However, I would like to insert an HTML break in between the two words, so my result from inserting "$lit_QuantityReceived" in HTML would be:
I've tried quite a few options that don't work. < doesn't work because the browser doesn't intepret that as the beginning of a tag, escaping a linefeed actually puts a line break in the HTML instead of a <br> tag, and I can't seem to find a single way to get a < or > symbol into my variable definition.
I've even referenced the xhtml DTD:
<br xmlns:html="http://www.w3.org/1999/xhtml" />
which *does* work when you use it directly in a .xsl, but not when you embed it within the variable as I'm trying to do.
Is this possible?
Thanks in advance.
March 4th, 2002, 05:12 PM
this may help
I am not sure if you can store Document nodes as part of a value, so the next best thing is to apply a separate stylesheet template that will convert characters (in this case a space) to line breaks (<br/>)
heres an example of swapping a space for a break.
<xslaram name="text" select="."/>
<xsl:when test="contains($text, ' ')">
<xsl:value-of select="substring-before($text, ' ')"/>
<xsl:with-param name="text" select="substring-after($text,' ')"/>
to apply this to a value just do this:
<xsl:with-param name="text" select="$yourVariable"/>
March 8th, 2002, 01:56 PM
Can you discuss the positive and negative effects of smileys in XML code?
March 8th, 2002, 01:59 PM
Thanks for the humor Zach.
March 14th, 2002, 03:00 PM
I think you should try this
variable definition :
<xsl:variable name="lit_QuantityReceived"> Quantity <br>Received</xsl:variable>
output variable :
<xsl:value-of disable-output-escaping="yes" select="$lit_QuantityReceived"/>